dllm | R Documentation |
Fits a dynamic linear model (DLM) using maximum likelihood estimation.
dllm(
data,
obs_cols,
S = c("univariate", "kvariate"),
log10 = FALSE,
date = NULL,
prior = list(),
equal.state.var = FALSE,
equal.obs.var = FALSE,
init_params = NULL,
auto_init = TRUE,
control = list(maxit = 500)
)
data |
A data frame containing observed time series data. |
obs_cols |
Character vector of column names in |
S |
Character; the structure of latent states. |
log10 |
logical; if TRUE, a log10 transformation is applied to the whole data. |
date |
Optional; the name of the column in |
prior |
A list of prior specifications. Default priors are used if not supplied. |
equal.state.var |
logical; if TRUE the variance is the same across all wastewater state. |
equal.obs.var |
logical; if TRUE the variance is the same across all wastewater observation. |
init_params |
Optional numeric vector of initial parameters. |
auto_init |
Logical; if |
control |
List of control parameters for the optimization routine ( |
The function prepares the data, validates inputs, and (if necessary) automatically initializes parameters.
It then defines a helper function to build the model via build_dlm
and fits the model using
maximum likelihood estimation (dlmMLE
). Filtering and smoothing are applied to obtain state estimates.
An object of class dllm
containing the fitted model, filtered and smoothed estimates,
along with fit statistics (log-likelihood, AIC, BIC) and other diagnostic information.
The input data.
The input vector of date.
Character vector of column names in data
to be used as observations.
Character; the structure of latent states.
A list of estimated parameters by maximum likelihood estimation.
The loglikelihood of the fitted model.
AIC of the fitted model.
BIC of the fitted model.
An integer code returned by optim
An dlm
object of the fitted dynamic linear model.
The corresponding dynamic linear filter returned by dlmFilter
The corresponding dynamic linear smoother returned by dlmSmooth
A matrix of the filtered observed response variables.
A matrix of the smoothed observed response variables.
data<- wastewater[wastewater$Code == "TC",]
data$SampleDate <- as.Date(data$SampleDate)
fit <- dllm(
equal.state.var=TRUE,
equal.obs.var=FALSE,
log10=TRUE,
data = data,
date = "SampleDate",
obs_cols = c("ORFlab", "Nlab"),
S = 'kvariate')
summary(fit)
plot(fit, type='smoother', plot_data = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.