| derive_timeseries | R Documentation |
Derive the time series used in the AR1 model.
derive_timeseries(model, AR.start = NULL)
model |
GAMM model that includes an AR1 model. |
AR.start |
Vector with AR.start information, necessary for the AR1 model. Optional, defaults to NULL. |
A vector with time series indication based on the AR1 model.
Jacolien van Rij
Other functions for model criticism:
acf_n_plots(),
acf_plot(),
acf_resid(),
resid_gam(),
start_event(),
start_value_rho()
data(simdat)
# add missing values to simdat:
simdat[sample(nrow(simdat), 15),]$Y <- NA
simdat <- start_event(simdat, event=c('Subject', 'Trial'))
## Not run:
# Run GAMM model:
m1 <- bam(Y ~ te(Time, Trial)+s(Subject, bs='re'), data=simdat,
rho=.5, AR.start=simdat$start.event)
simdat$Event <- NA
simdat[!is.na(simdat$Y),]$Event <- derive_timeseries(m1)
acf_resid(m1, split_pred=list(Event=simdat$Event))
# And this works too:
simdat$Event <- derive_timeseries(simdat$start.event)
acf_resid(m1, split_pred=list(Event=simdat$Event))
# Note that acf_resid automatically makes use of derive_timeseries:
acf_resid(m1, split_pred='AR.start')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.