constructModel {multivar} | R Documentation |
Construct an object of class multivar
Description
Construct an object of class multivar
Usage
constructModel(
data = NULL,
lag = 1,
horizon = 0,
t1 = NULL,
t2 = NULL,
lambda1 = NULL,
lambda2 = NULL,
nlambda1 = 30,
nlambda2 = 30,
depth = 1000,
tol = 1e-04,
window = 1,
standardize = T,
weightest = "lasso",
canonical = FALSE,
threshold = FALSE,
lassotype = "adaptive",
intercept = FALSE,
W = NULL,
ratios = NULL,
cv = "blocked",
nfolds = 10,
thresh = 0,
lamadapt = FALSE
)
Arguments
data |
List. A list (length = k) of T by d multivariate time series |
lag |
Numeric. The VAR order. Default is 1. |
horizon |
Numeric. Desired forecast horizon. Default is 1. ZF Note: Should probably be zero. |
t1 |
Numeric. Index of time series in which to start cross validation. If NULL, default is floor(nrow(n)/3) where nk is the time series length for individual k. |
t2 |
Numeric. Index of times series in which to end cross validation. If NULL, default is floor(2*nrow(n)/3) where nk is the time series length for individual k. |
lambda1 |
Matrix. Regularization parameter 1. Default is NULL. |
lambda2 |
Matrix. Regularization parameter 2. Default is NULL. |
nlambda1 |
Numeric. Number of lambda1 values to search over. Default is 30. |
nlambda2 |
Numeric. Number of lambda2 values to search over. Default is 30. |
depth |
Numeric. Depth of grid construction. Default is 1000. |
tol |
Numeric. Optimization tolerance (default 1e-4). |
window |
Numeric. Size of rolling window. |
standardize |
Logical. Default is true. Whether to standardize the individual data. |
weightest |
Character. Default is "mlr" for multiple linear regression. "sls" for simple linear regression also available. How to estimate the first-stage weights. |
canonical |
Logical. Default is false. If true, individual datasets are fit to a VAR(1) model. |
threshold |
Logical. Default is false. If true, and canonical is true, individual transition matrices are thresholded based on significance. |
lassotype |
Character. Default is "adaptive". Choices are "standard" or "adaptive" lasso. |
intercept |
Logical. Default is FALSE. |
W |
Matrix. Default is NULL. |
ratios |
Numeric vector. Default is NULL. |
cv |
Character. Default is "rolling" for rolling window cross-validation. "blocked" is also available for blocked folds cross-validation. If "blocked" is selected the nfolds argument should bbe specified. |
nfolds |
Numeric. The number of folds for use with "blocked" cross-validation. |
thresh |
Numeric. Post-estimation threshold for setting the individual-level coefficients to zero if their absolute value is smaller than the value provided. Default is zero. |
lamadapt |
Logical. Should the lambdas be calculated adaptively. Default is FALSE. |
Examples
sim <- multivar_sim(
k = 2, # individuals
d = 3, # number of variables
n = 20, # number of timepoints
prop_fill_com = 0.1, # proportion of paths common
prop_fill_ind = 0.1, # proportion of paths unique
lb = 0.1, # lower bound on coefficient magnitude
ub = 0.9, # upper bound on coefficient magnitude
sigma = diag(3) # noise
)
plot_sim(sim, plot_type = "common")
model <- constructModel(data = sim$data, weightest = "ols")