Fit double logistic model to NDVI time series given parameters estimated with model_params.

model_ndvi(DT, observed = TRUE)

Arguments

DT

data.table of model parameters (output from model_params).

observed

boolean indicating if a full year of fitted values should be returned (observed = FALSE) or if only observed values will be fit (observed = TRUE)

Value

Model parameter data.table appended with 'fitted' column of double logistic model of NDVI for a full year. Calculated at the daily scale with the following formula from Bischoff et al. (2012).

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

(See the "Getting started with irg vignette" for a better formatted formula.)

References

https://www.journals.uchicago.edu/doi/abs/10.1086/667590

See also

Examples

# Load data.table library(data.table) # Read in example data ndvi <- fread(system.file("extdata", "ndvi.csv", package = "irg")) # Filter and scale NDVI time series filter_ndvi(ndvi)
#> id yr DayOfYear NDVI SummaryQA filtered winter rolled top #> 1: 7652 2002 3 -1367 3 4099 4099 4099 7443.400 #> 2: 7035 2002 14 -304 3 5382 5382 5382 7462.900 #> 3: 4368 2002 1 374 2 3702 3702 3702 6709.800 #> 4: 5196 2002 15 635 3 5180 5180 5180 7288.100 #> 5: 12377 2002 9 685 2 4621 4621 4621 7645.100 #> --- #> 2526: 13322 2012 356 1257 2 4708 4708 4708 7776.250 #> 2527: 9537 2012 356 144 2 4536 4536 4536 7155.475 #> 2528: 18592 2012 362 1031 2 4011 4011 4011 7184.300 #> 2529: 2163 2012 356 2172 2 5022 5022 5022 7566.600 #> 2530: 2941 2012 356 -197 2 2839 2839 2839 5491.750
scale_doy(ndvi)
#> id yr DayOfYear NDVI SummaryQA filtered winter rolled top #> 1: 7652 2002 3 -1367 3 4099 4099 4099 7443.400 #> 2: 7035 2002 14 -304 3 5382 5382 5382 7462.900 #> 3: 4368 2002 1 374 2 3702 3702 3702 6709.800 #> 4: 5196 2002 15 635 3 5180 5180 5180 7288.100 #> 5: 12377 2002 9 685 2 4621 4621 4621 7645.100 #> --- #> 2526: 13322 2012 356 1257 2 4708 4708 4708 7776.250 #> 2527: 9537 2012 356 144 2 4536 4536 4536 7155.475 #> 2528: 18592 2012 362 1031 2 4011 4011 4011 7184.300 #> 2529: 2163 2012 356 2172 2 5022 5022 5022 7566.600 #> 2530: 2941 2012 356 -197 2 2839 2839 2839 5491.750 #> t #> 1: 0.005479452 #> 2: 0.035616438 #> 3: 0.000000000 #> 4: 0.038356164 #> 5: 0.021917808 #> --- #> 2526: 0.972602740 #> 2527: 0.972602740 #> 2528: 0.989041096 #> 2529: 0.972602740 #> 2530: 0.972602740
#> id yr DayOfYear NDVI SummaryQA filtered winter rolled top #> 1: 7652 2002 3 -1367 3 4099 4099 4099 7443.400 #> 2: 7035 2002 14 -304 3 5382 5382 5382 7462.900 #> 3: 4368 2002 1 374 2 3702 3702 3702 6709.800 #> 4: 5196 2002 15 635 3 5180 5180 5180 7288.100 #> 5: 12377 2002 9 685 2 4621 4621 4621 7645.100 #> --- #> 2526: 13322 2012 356 1257 2 4708 4708 4708 7776.250 #> 2527: 9537 2012 356 144 2 4536 4536 4536 7155.475 #> 2528: 18592 2012 362 1031 2 4011 4011 4011 7184.300 #> 2529: 2163 2012 356 2172 2 5022 5022 5022 7566.600 #> 2530: 2941 2012 356 -197 2 2839 2839 2839 5491.750 #> t scaled #> 1: 0.005479452 0 #> 2: 0.035616438 0 #> 3: 0.000000000 0 #> 4: 0.038356164 0 #> 5: 0.021917808 0 #> --- #> 2526: 0.972602740 0 #> 2527: 0.972602740 0 #> 2528: 0.989041096 0 #> 2529: 0.972602740 0 #> 2530: 0.972602740 0
# Guess starting parameters for xmidS and xmidA model_start(ndvi)
#> id yr DayOfYear NDVI SummaryQA filtered winter rolled top #> 1: 7035 2003 NA NA NA NA 5382 NA 7462.900 #> 2: 7035 2009 NA NA NA NA 5382 NA 7462.900 #> 3: 7035 2011 NA NA NA NA 5382 NA 7462.900 #> 4: 7035 2011 NA NA NA NA 5382 NA 7462.900 #> 5: 5196 2002 61 375 2 NA 5180 NA 7288.100 #> --- #> 2526: 18592 2007 257 7245 0 7245 4011 7245 7184.300 #> 2527: 9537 2012 257 7292 0 7292 4536 7292 7155.475 #> 2528: 12377 2012 262 7773 1 7773 4621 7905 7645.100 #> 2529: 9537 2009 271 6508 0 6508 4536 7256 7155.475 #> 2530: 18592 2009 271 6360 0 6360 4011 7255 7184.300 #> t scaled xmidS_start xmidA_start #> 1: NA NA 0.4767123 0.7150685 #> 2: NA NA 0.4575342 NA #> 3: NA NA 0.4986301 0.7780822 #> 4: NA NA 0.4986301 0.7780822 #> 5: 0.1643836 NA 0.4328767 0.8164384 #> --- #> 2526: 0.7013699 1 0.4493151 0.7753425 #> 2527: 0.7013699 1 0.4000000 0.8027397 #> 2528: 0.7150685 1 0.3342466 NA #> 2529: 0.7397260 1 0.4630137 NA #> 2530: 0.7397260 1 0.4575342 NA
## Two options: fit to full year or observed data # Option 1 - returns = 'models' # 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 ) # Fit to the whole year (requires assignment) fit <- model_ndvi(mods, observed = FALSE) # Option 2 - returns = 'columns' model_params( ndvi, returns = 'columns', xmidS = 'xmidS_start', xmidA = 'xmidA_start', scalS = 0.05, scalA = 0.01 )
#> id yr DayOfYear NDVI SummaryQA filtered winter rolled top #> 1: 7035 2003 NA NA NA NA 5382 NA 7462.900 #> 2: 7035 2009 NA NA NA NA 5382 NA 7462.900 #> 3: 7035 2011 NA NA NA NA 5382 NA 7462.900 #> 4: 7035 2011 NA NA NA NA 5382 NA 7462.900 #> 5: 5196 2002 61 375 2 NA 5180 NA 7288.100 #> --- #> 2526: 18592 2007 257 7245 0 7245 4011 7245 7184.300 #> 2527: 9537 2012 257 7292 0 7292 4536 7292 7155.475 #> 2528: 12377 2012 262 7773 1 7773 4621 7905 7645.100 #> 2529: 9537 2009 271 6508 0 6508 4536 7256 7155.475 #> 2530: 18592 2009 271 6360 0 6360 4011 7255 7184.300 #> t scaled xmidS_start xmidA_start xmidS xmidA scalS #> 1: NA NA 0.4767123 0.7150685 0.4964268 0.7941240 0.05571006 #> 2: NA NA 0.4575342 NA NA NA NA #> 3: NA NA 0.4986301 0.7780822 0.4755532 0.7792491 0.03967694 #> 4: NA NA 0.4986301 0.7780822 0.4755532 0.7792491 0.03967694 #> 5: 0.1643836 NA 0.4328767 0.8164384 0.4575765 0.7936199 0.04381232 #> --- #> 2526: 0.7013699 1 0.4493151 0.7753425 0.4473886 0.7817564 0.05412130 #> 2527: 0.7013699 1 0.4000000 0.8027397 0.4142526 0.8117557 0.05817057 #> 2528: 0.7150685 1 0.3342466 NA NA NA NA #> 2529: 0.7397260 1 0.4630137 NA NA NA NA #> 2530: 0.7397260 1 0.4575342 NA NA NA NA #> scalA #> 1: 0.020099805 #> 2: NA #> 3: 0.001239339 #> 4: 0.001239339 #> 5: 0.022093920 #> --- #> 2526: 0.005443712 #> 2527: 0.014209651 #> 2528: NA #> 2529: NA #> 2530: NA
# Fit double logistic curve to NDVI time series for the observed days model_ndvi(ndvi, observed = TRUE)
#> id yr DayOfYear NDVI SummaryQA filtered winter rolled top #> 1: 7035 2003 NA NA NA NA 5382 NA 7462.900 #> 2: 7035 2009 NA NA NA NA 5382 NA 7462.900 #> 3: 7035 2011 NA NA NA NA 5382 NA 7462.900 #> 4: 7035 2011 NA NA NA NA 5382 NA 7462.900 #> 5: 5196 2002 61 375 2 NA 5180 NA 7288.100 #> --- #> 2526: 18592 2007 257 7245 0 7245 4011 7245 7184.300 #> 2527: 9537 2012 257 7292 0 7292 4536 7292 7155.475 #> 2528: 12377 2012 262 7773 1 7773 4621 7905 7645.100 #> 2529: 9537 2009 271 6508 0 6508 4536 7256 7155.475 #> 2530: 18592 2009 271 6360 0 6360 4011 7255 7184.300 #> t scaled xmidS_start xmidA_start xmidS xmidA scalS #> 1: NA NA 0.4767123 0.7150685 0.4964268 0.7941240 0.05571006 #> 2: NA NA 0.4575342 NA NA NA NA #> 3: NA NA 0.4986301 0.7780822 0.4755532 0.7792491 0.03967694 #> 4: NA NA 0.4986301 0.7780822 0.4755532 0.7792491 0.03967694 #> 5: 0.1643836 NA 0.4328767 0.8164384 0.4575765 0.7936199 0.04381232 #> --- #> 2526: 0.7013699 1 0.4493151 0.7753425 0.4473886 0.7817564 0.05412130 #> 2527: 0.7013699 1 0.4000000 0.8027397 0.4142526 0.8117557 0.05817057 #> 2528: 0.7150685 1 0.3342466 NA NA NA NA #> 2529: 0.7397260 1 0.4630137 NA NA NA NA #> 2530: 0.7397260 1 0.4575342 NA NA NA NA #> scalA fitted #> 1: 0.020099805 NA #> 2: NA NA #> 3: 0.001239339 NA #> 4: 0.001239339 NA #> 5: 0.022093920 0.001239236 #> --- #> 2526: 0.005443712 0.990921908 #> 2527: 0.014209651 0.992443689 #> 2528: NA NA #> 2529: NA NA #> 2530: NA NA