pdlm | R Documentation |
Constructs a dynamic linear model (DLM) object using the dlm package.
pdlm(
data,
formula,
lags = 0,
log10 = TRUE,
date = NULL,
prior = list(),
equal.state.var = TRUE,
equal.obs.var = TRUE,
init_params = list(),
auto_init = TRUE,
control = list(maxit = 500)
)
data |
A data frame containing the variables in the model. |
formula |
An object of class "formula" describing the model to be fitted. |
lags |
A nonnegative integer indicating the lag of the latent state in the model. |
log10 |
Logical; if TRUE, a log10 transformation is applied to the entire dataset. |
date |
An optional vector of date indices of the data. |
prior |
An optional list specifying the prior mean vector and covariance structure of the latent state. If not provided, a naive prior is used. |
equal.state.var |
Logical; if TRUE, the same variance is assumed across all state components. |
equal.obs.var |
Logical; if TRUE, the same variance is assumed across all observation components. |
init_params |
An optional list of initial parameters for the model. Should include Ft, Wt, and Vt: transition coefficients, state variance, and observation variance components respectively. |
auto_init |
Logical; if TRUE, naive initial parameters are used. |
control |
An optional list of control parameters for |
A dlm
object with additional attributes:
The fitted formula.
Number of lags.
The input data.
The input vector of dates.
A list of estimated parameters.
Log-likelihood of the fitted model.
Akaike Information Criterion.
Bayesian Information Criterion.
The convergence code from optim
.
The final dlm
object.
Output from dlmFilter
.
One-step-ahead predictions.
Variance of the predictions.
data <- wastewaterhealthworker[wastewaterhealthworker$Code == "TC",]
data$SampleDate <- as.Date(data$SampleDate)
fit <- pdlm(
formula=HealthWorkerCaseCount~WW.tuesday+WW.thursday,
data = data,
lags = 2,
equal.state.var=FALSE,
equal.obs.var=FALSE,
log10=TRUE,
date = "SampleDate")
summary(fit)
plot(fit, conf.int = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.