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
)
data.table of NDVI time series. Also optionally starting estimates. See Details.
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 column. default is 'id'. See details.
year column name. default is 'yr'.
starting estimates. see Details. - "spring inflection point"
starting estimates. see Details. - "fall inflection point"
starting estimates. see Details. - "scale parameter for spring green-up portion of the NDVI curve"
starting estimates. see Details. - "scale parameter for fall dry-down portion of the NDVI curve"
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.
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}}}$$
Other model:
model_ndvi()
,
model_start()
# 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
#> <int> <num> <num> <int> <num> <num> <num> <num>
#> 1: 0 0.1864 3 11 2015 0.3076500 0.3076500 0.3076500
#> 2: 1 0.0541 2 3 2015 0.3163400 0.3163400 0.3163400
#> 3: 2 0.1781 3 11 2015 0.2649875 0.2649875 0.2649875
#> 4: 3 0.1024 2 5 2015 0.2301750 0.2301750 0.2301750
#> 5: 4 0.0898 2 3 2015 0.2177150 0.2177150 0.2177150
#> ---
#> 801: 2 0.1179 2 364 2019 0.2649875 0.2649875 0.2649875
#> 802: 3 0.0789 2 364 2019 0.2301750 0.2301750 0.2301750
#> 803: 4 0.1572 2 364 2019 0.2177150 0.2177150 0.2177150
#> 804: 5 0.0763 2 364 2019 0.3163400 0.3163400 0.3163400
#> 805: 6 0.1197 2 362 2019 0.3149325 0.3149325 0.3149325
#> top
#> <num>
#> 1: 0.8735000
#> 2: 0.8632175
#> 3: 0.8707500
#> 4: 0.8635525
#> 5: 0.8476000
#> ---
#> 801: 0.8707500
#> 802: 0.8635525
#> 803: 0.8476000
#> 804: 0.8632175
#> 805: 0.8632000
scale_doy(ndvi)
#> id NDVI SummaryQA DayOfYear yr filtered winter rolled
#> <int> <num> <num> <int> <num> <num> <num> <num>
#> 1: 0 0.1864 3 11 2015 0.3076500 0.3076500 0.3076500
#> 2: 1 0.0541 2 3 2015 0.3163400 0.3163400 0.3163400
#> 3: 2 0.1781 3 11 2015 0.2649875 0.2649875 0.2649875
#> 4: 3 0.1024 2 5 2015 0.2301750 0.2301750 0.2301750
#> 5: 4 0.0898 2 3 2015 0.2177150 0.2177150 0.2177150
#> ---
#> 801: 2 0.1179 2 364 2019 0.2649875 0.2649875 0.2649875
#> 802: 3 0.0789 2 364 2019 0.2301750 0.2301750 0.2301750
#> 803: 4 0.1572 2 364 2019 0.2177150 0.2177150 0.2177150
#> 804: 5 0.0763 2 364 2019 0.3163400 0.3163400 0.3163400
#> 805: 6 0.1197 2 362 2019 0.3149325 0.3149325 0.3149325
#> top t
#> <num> <num>
#> 1: 0.8735000 0.027397260
#> 2: 0.8632175 0.005479452
#> 3: 0.8707500 0.027397260
#> 4: 0.8635525 0.010958904
#> 5: 0.8476000 0.005479452
#> ---
#> 801: 0.8707500 0.994520548
#> 802: 0.8635525 0.994520548
#> 803: 0.8476000 0.994520548
#> 804: 0.8632175 0.994520548
#> 805: 0.8632000 0.989041096
scale_ndvi(ndvi)
#> id NDVI SummaryQA DayOfYear yr filtered winter rolled
#> <int> <num> <num> <int> <num> <num> <num> <num>
#> 1: 0 0.1864 3 11 2015 0.3076500 0.3076500 0.3076500
#> 2: 1 0.0541 2 3 2015 0.3163400 0.3163400 0.3163400
#> 3: 2 0.1781 3 11 2015 0.2649875 0.2649875 0.2649875
#> 4: 3 0.1024 2 5 2015 0.2301750 0.2301750 0.2301750
#> 5: 4 0.0898 2 3 2015 0.2177150 0.2177150 0.2177150
#> ---
#> 801: 2 0.1179 2 364 2019 0.2649875 0.2649875 0.2649875
#> 802: 3 0.0789 2 364 2019 0.2301750 0.2301750 0.2301750
#> 803: 4 0.1572 2 364 2019 0.2177150 0.2177150 0.2177150
#> 804: 5 0.0763 2 364 2019 0.3163400 0.3163400 0.3163400
#> 805: 6 0.1197 2 362 2019 0.3149325 0.3149325 0.3149325
#> top t scaled
#> <num> <num> <num>
#> 1: 0.8735000 0.027397260 0
#> 2: 0.8632175 0.005479452 0
#> 3: 0.8707500 0.027397260 0
#> 4: 0.8635525 0.010958904 0
#> 5: 0.8476000 0.005479452 0
#> ---
#> 801: 0.8707500 0.994520548 0
#> 802: 0.8635525 0.994520548 0
#> 803: 0.8476000 0.994520548 0
#> 804: 0.8632175 0.994520548 0
#> 805: 0.8632000 0.989041096 0
# Guess starting parameters for xmidS and xmidA
model_start(ndvi)
#> Key: <scaled>
#> id NDVI SummaryQA DayOfYear yr filtered winter rolled top
#> <int> <num> <num> <int> <num> <num> <num> <num> <num>
#> 1: 4 0.1262 3 38 2015 0.217715 0.2177150 NA 0.8476000
#> 2: 1 0.0599 2 38 2016 0.316340 0.3163400 NA 0.8632175
#> 3: 3 0.0714 2 38 2016 0.230175 0.2301750 NA 0.8635525
#> 4: 4 0.0433 2 38 2016 0.217715 0.2177150 NA 0.8476000
#> 5: 5 0.0599 2 38 2016 0.316340 0.3163400 NA 0.8632175
#> ---
#> 801: 1 0.8755 1 225 2015 0.875500 0.3163400 0.8671 0.8632175
#> 802: 2 0.8740 1 225 2015 0.874000 0.2649875 0.8732 0.8707500
#> 803: 3 0.8643 1 225 2015 0.864300 0.2301750 0.8643 0.8635525
#> 804: 5 0.8755 1 225 2015 0.875500 0.3163400 0.8671 0.8632175
#> 805: 6 0.8729 1 225 2015 0.872900 0.3149325 0.8688 0.8632000
#> t scaled xmidS_start xmidA_start
#> <num> <num> <num> <num>
#> 1: 0.1013699 NA 0.3808219 0.7808219
#> 2: 0.1013699 NA 0.3643836 0.7095890
#> 3: 0.1013699 NA 0.3643836 0.7095890
#> 4: 0.1013699 NA 0.3643836 0.7095890
#> 5: 0.1013699 NA 0.3643836 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
)