Create Dynamic Factor Model
Usage
create_model(
nfactors,
nlags,
factors_type,
factors_loading,
var_init = c("Unconditional", "Zero"),
var_coefficients = NULL,
var_errors_variance = NULL,
measurement_coefficients = NULL,
measurement_errors_variance = NULL
)
Arguments
- nfactors
Integer. Number of factors.
- nlags
Integer. Number of lags in VAR equations.
- factors_type
Character vector. Respecting the order of the series in the input data, you must refer here the link between the (transformed) series and the factors. Three options are possible:
"M": Variables expressed in terms of monthly growth rates can be linked to a factor representing the underlying monthly growth rate of the economy if "M" is selected
"Q": Monthly or quarterly variables that are correlated with the the underlying quarterly growth rate of the economy can be linked to a weighted average of the factors representing the underlying monthly growth rate of the economy. Such a weighted average is meant to represent quarterly growth rates, and it is implemented by selecting "Q"
"YoY": The variables can also be linked to the cumulative sum of the last 12 monthly factors. If the model is designed in such a way that the monthly factors represent monthly growth rates, the resulting cumulative sum boils down to the year-on-year growth rate. Thus, variables expressed in terms of year-on-year growth rates or surveys that are correlated with the year-on-year growth rates of the reference series should be linked to the factors using "YoY".
- factors_loading
Boolean matrix. It represents the factor loading structure. The dimension of the matrix should be 'number of series' x 'number of factors'. For each row representing each series, the user must mention whether the corresponding factor loads on this series.
- var_init
Character. The first unobserved factors values in the sample is assumed to be either equal to zero or consistent with a normal distribution with mean zero and a variance corresponding to the unconditional variance of the VAR. The latter is the default.
- var_coefficients
Matrix. The default is NULL meaning that the VAR coefficients will be estimated from scratch. Alternatively, a matrix of pre-defined values can be passed in. Those would come typically from a previous model estimate and will serve as a starting point for the estimation step. The format of the matrix should be the same as the one produced by default by the create_model() function while keeping the `var_coefficients` argument to its default value NULL.
- var_errors_variance
Matrix. The default is NULL meaning that the VAR errors variance will be estimated from scratch. Alternatively, a matrix of pre-defined values can be passed in. Those would come typically from a previous model estimate and will serve as a starting point for the estimation step. The format of the matrix should be the same as the one produced by default by the create_model() function while keeping the `var_errors_variance` argument to its default value NULL.
- measurement_coefficients
Matrix. The default is NULL meaning that the measurement coefficients will be estimated from scratch. Alternatively, a matrix of pre-defined values can be passed in. Those would come typically from a previous model estimate and will serve as a starting point for the estimation step. The format of the matrix should be the same as the one produced by default by the create_model() function while keeping the `measurement_coefficients` argument to its default value NULL.
- measurement_errors_variance
Numeric vector. The default is NULL meaning that the measurement errors variance will be estimated from scratch. Alternatively, a vector of pre-defined values can be passed in. Those would come typically from a previous model estimate and will serve as a starting point for the estimation step. The format of the vector should be the same as the one produced by default by the create_model() function while keeping the `measurement_errors_variance` argument to its default value NULL.
Examples
# From scratch
dfm1 <- create_model(nfactors=2,
nlags=2,
factors_type = c("M", "M", "YoY", "M", "Q"),
factors_loading = matrix(data=TRUE, 5, 2),
var_init = "Unconditional")
# From a previous estimate
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
est1<-estimate_em(dfm1, data)
dfm2 <- create_model(nfactors=2,
nlags=2,
factors_type = c("M", "M", "YoY", "M", "Q"),
factors_loading = matrix(data=TRUE, 5, 2),
var_init = "Unconditional",
var_coefficients = est1$dfm$var_coefficients,
var_errors_variance = est1$dfm$var_errors_variance,
measurement_coefficients = est1$dfm$measurement_coefficients,
measurement_errors_variance = est1$dfm$measurement_errors_variance)
#est2<-estimate_em(dfm2, data)