Estimate DFM with Maximum Likelihood
Usage
estimate_ml(
dfm,
data,
standardized = FALSE,
input_standardization = NULL,
pca_init = TRUE,
em_init = TRUE,
em_max_iter = 100,
em_eps = 1e-09,
max_iter = 1000,
max_block_iter = 5,
simpl_model_iter = 15,
independent_var_shocks = FALSE,
mixedEstimation = TRUE,
eps = 1e-09,
re_estimate = TRUE
)
Arguments
- dfm
an object of class 'JD3_DfmModel'. Typically generated by the create_model() function.
- data
an mts object.
- standardized
Boolean. Indicate whether the input series were already standardized or not. Default is FALSE, meaning that a standardization of the series will be preliminary applied as part of the process.
- input_standardization
Matrix. Mean and standard deviation of the variables to consider for the pre-processing step of standardization. Default is NULL, meaning that they will be re-calculated based on the data. Typically, it can be filled with the output of the function `get_results()$preprocessing$sample_mean_stdev` applied on a previous estimate of the model. If provided manually, it must be a two columns matrix with the mean in the first column and the standard deviation in the second column. In the rows, the order of the variables should also be respected (similar to the data). Note that this argument must be filled if the re_estimate argument is set to FALSE. On the other hand, it is ignored if the standardized argument is set to TRUE.
- pca_init
Boolean. Indicate whether a principal components analysis is performed beforehand and used as initial condition for either the EM algorithm (if em_init=TRUE) or directly for the ML estimation.
- em_init
Boolean. Indicate whether the EM algorithm is performed beforehand and used as initial condition for the ML estimation.
- em_max_iter
Integer. Maximum number of iterations of the EM algorithm. Ignored if em_init = FALSE.
- em_eps
Numeric. EM algorithm is run until the percentage likelihood does not increase by more than the eps value (1e-9 is the default) or until the maximum number of iterations is hit. Ignored if em_init = FALSE.
- max_iter
Integer. Maximum number of iterations for the ML estimation.
- max_block_iter
Integer. Maximum number of iterations in optimization by block. The model parameters are divided in two blocks: one related to the measurement equations and one to the VAR equations. While the EM algorithm requires one iteration per block, the numerical optimization allows us to set the number of iterations desired per block.
- simpl_model_iter
Integer. Number of simplified model iterations allowed.
- independent_var_shocks
Boolean. Whether we assume that shocks in the VAR block are independent.
- mixedEstimation
Boolean. The mixed estimation option alternates between the iterations for the VAR block alone and simultaneous iterations for the two blocks.
- eps
Numeric. ML estimation is run until the percentage likelihood does not increase by more than the eps value (1e-9 is the default) or until the maximum number of iterations is hit.
- re_estimate
Boolean. Indicate whether the model will be re-estimated or not. Default is TRUE. Could be set to FALSE if, for some reasons during the production process, we wanted to freeze to model for some periods of time. It is not recommended to freeze the model for a long period.
Examples
set.seed(100)
data<-ts(matrix(rnorm(500), 100, 5), frequency = 12, start = c(2010,1))
data[100,1]<-data[99:100,2]<-data[(1:100)[-seq(3,100,3)],5]<-NA
dfm <- create_model(nfactors=2,
nlags=2,
factors_type = c("M", "M", "YoY", "M", "Q"),
factors_loading = matrix(data=TRUE, 5, 2),
var_init = "Unconditional")
est_ml<-estimate_ml(dfm, data)
#est_ml<-estimate_ml(dfm, data, re_estimate=FALSE) # model not re-estimated