Model estimated parameters for fitting double logistic curve.

model_params(
  DT,
  returns = NULL,
  id = "id",
  year = "yr",
  xmidS = NULL,
  xmidA = NULL,
  scalS = NULL,
  scalA = NULL
)

Arguments

DT

data.table of NDVI time series. Also optionally starting estimates. See Details.

returns

either 'models' or 'columns'. 'models' will return a data.table of model outcomes by id and year. 'columns' will append model estimate parameters to the input DT.

id

id column. default is 'id'. See details.

year

year column name. default is 'yr'.

xmidS

starting estimates. see Details. - "spring inflection point"

xmidA

starting estimates. see Details. - "fall inflection point"

scalS

starting estimates. see Details. - "scale parameter for spring green-up portion of the NDVI curve"

scalA

starting estimates. see Details. - "scale parameter for fall dry-down portion of the NDVI curve"

Value

data.table of model estimated parameters for double logistic model. If any rows are NULL, nls could not fit a model given starting parameters to the data provided.

Details

Arguments xmidS, xmidA, scalS, scalA allow users to provide either group level or global starting estimates to be used for all models.

Either: a character indicating the column name which stores a group level starting parameter (possibly created by model_start OR a numeric value used as a global value for all models. See nls for more details on starting parameters.

Default value for the year column is 'yr'. If you only have one year of data, set to NULL.

The id argument is used to split between sampling units. This may be a point id, polygon id, pixel id, etc. depending on your analysis. This should match the id provided to filtering functions.

Formula and arguments xmidS, xmidA, scalS, scalA following this from Bischoff et al. (2012).

$$fitted = \frac{1}{1 + \exp{\frac{xmidS - t}{scalS}}} - \frac{1}{1 + \exp{\frac{xmidA - t}{scalA}}}$$

See also

Other model: model_ndvi(), model_start()

Examples

# Load data.table
library(data.table)

# Read in example data
ndvi <- fread(system.file("extdata", "sampled-ndvi-MODIS-MOD13Q1.csv", package = "irg"))

# Filter and scale NDVI time series
filter_ndvi(ndvi)
#>      id   NDVI SummaryQA DayOfYear   yr  filtered    winter    rolled       top
#>   1:  0 0.1864         3        11 2015 0.3076500 0.3076500 0.3076500 0.8735000
#>   2:  1 0.0541         2         3 2015 0.3163400 0.3163400 0.3163400 0.8632175
#>   3:  2 0.1781         3        11 2015 0.2649875 0.2649875 0.2649875 0.8707500
#>   4:  3 0.1024         2         5 2015 0.2301750 0.2301750 0.2301750 0.8635525
#>   5:  4 0.0898         2         3 2015 0.2177150 0.2177150 0.2177150 0.8476000
#>  ---                                                                           
#> 801:  2 0.1179         2       364 2019 0.2649875 0.2649875 0.2649875 0.8707500
#> 802:  3 0.0789         2       364 2019 0.2301750 0.2301750 0.2301750 0.8635525
#> 803:  4 0.1572         2       364 2019 0.2177150 0.2177150 0.2177150 0.8476000
#> 804:  5 0.0763         2       364 2019 0.3163400 0.3163400 0.3163400 0.8632175
#> 805:  6 0.1197         2       362 2019 0.3149325 0.3149325 0.3149325 0.8632000
scale_doy(ndvi)
#>      id   NDVI SummaryQA DayOfYear   yr  filtered    winter    rolled       top
#>   1:  0 0.1864         3        11 2015 0.3076500 0.3076500 0.3076500 0.8735000
#>   2:  1 0.0541         2         3 2015 0.3163400 0.3163400 0.3163400 0.8632175
#>   3:  2 0.1781         3        11 2015 0.2649875 0.2649875 0.2649875 0.8707500
#>   4:  3 0.1024         2         5 2015 0.2301750 0.2301750 0.2301750 0.8635525
#>   5:  4 0.0898         2         3 2015 0.2177150 0.2177150 0.2177150 0.8476000
#>  ---                                                                           
#> 801:  2 0.1179         2       364 2019 0.2649875 0.2649875 0.2649875 0.8707500
#> 802:  3 0.0789         2       364 2019 0.2301750 0.2301750 0.2301750 0.8635525
#> 803:  4 0.1572         2       364 2019 0.2177150 0.2177150 0.2177150 0.8476000
#> 804:  5 0.0763         2       364 2019 0.3163400 0.3163400 0.3163400 0.8632175
#> 805:  6 0.1197         2       362 2019 0.3149325 0.3149325 0.3149325 0.8632000
#>                t
#>   1: 0.027397260
#>   2: 0.005479452
#>   3: 0.027397260
#>   4: 0.010958904
#>   5: 0.005479452
#>  ---            
#> 801: 0.994520548
#> 802: 0.994520548
#> 803: 0.994520548
#> 804: 0.994520548
#> 805: 0.989041096
scale_ndvi(ndvi)
#>      id   NDVI SummaryQA DayOfYear   yr  filtered    winter    rolled       top
#>   1:  0 0.1864         3        11 2015 0.3076500 0.3076500 0.3076500 0.8735000
#>   2:  1 0.0541         2         3 2015 0.3163400 0.3163400 0.3163400 0.8632175
#>   3:  2 0.1781         3        11 2015 0.2649875 0.2649875 0.2649875 0.8707500
#>   4:  3 0.1024         2         5 2015 0.2301750 0.2301750 0.2301750 0.8635525
#>   5:  4 0.0898         2         3 2015 0.2177150 0.2177150 0.2177150 0.8476000
#>  ---                                                                           
#> 801:  2 0.1179         2       364 2019 0.2649875 0.2649875 0.2649875 0.8707500
#> 802:  3 0.0789         2       364 2019 0.2301750 0.2301750 0.2301750 0.8635525
#> 803:  4 0.1572         2       364 2019 0.2177150 0.2177150 0.2177150 0.8476000
#> 804:  5 0.0763         2       364 2019 0.3163400 0.3163400 0.3163400 0.8632175
#> 805:  6 0.1197         2       362 2019 0.3149325 0.3149325 0.3149325 0.8632000
#>                t scaled
#>   1: 0.027397260      0
#>   2: 0.005479452      0
#>   3: 0.027397260      0
#>   4: 0.010958904      0
#>   5: 0.005479452      0
#>  ---                   
#> 801: 0.994520548      0
#> 802: 0.994520548      0
#> 803: 0.994520548      0
#> 804: 0.994520548      0
#> 805: 0.989041096      0

# Guess starting parameters for xmidS and xmidA
model_start(ndvi)
#>      id   NDVI SummaryQA DayOfYear   yr filtered    winter rolled       top
#>   1:  0 0.0791         2        61 2016       NA 0.3076500     NA 0.8735000
#>   2:  1 0.0526         2        61 2016       NA 0.3163400     NA 0.8632175
#>   3:  2 0.0707         2        61 2016       NA 0.2649875     NA 0.8707500
#>   4:  3 0.0456         2        61 2016       NA 0.2301750     NA 0.8635525
#>   5:  5 0.0526         2        61 2016       NA 0.3163400     NA 0.8632175
#>  ---                                                                       
#> 801:  1 0.8755         1       225 2015   0.8755 0.3163400 0.8671 0.8632175
#> 802:  2 0.8740         1       225 2015   0.8740 0.2649875 0.8732 0.8707500
#> 803:  3 0.8643         1       225 2015   0.8643 0.2301750 0.8643 0.8635525
#> 804:  5 0.8755         1       225 2015   0.8755 0.3163400 0.8671 0.8632175
#> 805:  6 0.8729         1       225 2015   0.8729 0.3149325 0.8688 0.8632000
#>              t scaled xmidS_start xmidA_start
#>   1: 0.1643836     NA   0.3452055   0.7095890
#>   2: 0.1643836     NA   0.3452055   0.7095890
#>   3: 0.1643836     NA   0.3452055   0.7095890
#>   4: 0.1643836     NA   0.3452055   0.7095890
#>   5: 0.1643836     NA   0.3452055   0.7095890
#>  ---                                         
#> 801: 0.6136986      1   0.4000000   0.7123288
#> 802: 0.6136986      1   0.3808219   0.7123288
#> 803: 0.6136986      1   0.3808219   0.7808219
#> 804: 0.6136986      1   0.4000000   0.7123288
#> 805: 0.6136986      1   0.3808219   0.7808219

# Double logistic model parameters
#   given global starting parameters for scalS, scalA
#   and output of model_start for xmidS, xmidA
mods <- model_params(
  ndvi,
  returns = 'models',
  xmidS = 'xmidS_start',
  xmidA = 'xmidA_start',
  scalS = 0.05,
  scalA = 0.01
)