mcnnm_cv: This function computes the best model fitted to the data....

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

This function computes the best model fitted to the data. Best value of lambda_L is chosen via cross-validation using all observed entries. It creates some folds, divides the observed entry to training and validation on each fold, computes the best model on training sets and finds root mean squared error on validation sets. Finally, it chooses the model which gives the smallest average RMSE.

Usage

1
2
3
mcnnm_cv(M, mask, to_estimate_u = 1L, to_estimate_v = 1L,
  num_lam_L = 100L, niter = 400L, rel_tol = 1e-05, cv_ratio = 0.8,
  num_folds = 5L, is_quiet = 1L)

Arguments

M

Matrix of observed entries. The input should be N (number of units) by T (number of time periods).

mask

Binary mask with the same shape as M containing observed entries.

to_estimate_u

Optional boolean input for wheter estimating fixed unit effects (row means of M) or not. Default is 1.

num_lam_L

Optional parameter on the number of lambda_Ls to consider for learning. The default number is 100 and lambda_L values are from minimum number which makes L zero to 1e-3 times this minimum number.

niter

Optional parameter on the number of iterations taken in the algorithm for each fixed value of lambda_L. The default value is 1000 and it is sufficiently large as the algorithm is using warm-start strategy.

rel_tol

Optional parameter on the stopping rule. Once the relative improve in objective value drops below rel_tol, execution is halted. Default value is 1e-5.

cv_ratio

Optional parameter indicating what percentage of observed entries to be used for training. 1-cv_ratio will be dedicated to validation set. For each fold these two sets are chosen randomly. Default value is 80/20 for training/validation.

num_folds

Optional parameter indicating the number of cross-validation folds. Default value is 5. For larger size problems we recommend decreasing this number for a faster cross-validation.

is_quiet

Optional boolean input which indicates whether to print the status of learning and convergence results for Cyclic Coordinate Descent algorithm or not. The default value is 1 (no output is printed).

Value

The best model fitted using lambda_L chosen via cross-validation. The final model is fitted to all observed entries (not only training set). The output also includes the vector of average root mean squared error for different values of lambda_L.

Examples

1
mcnnm_cv(M = replicate(5,rnorm(5)), mask = matrix(rbinom(5*5,1,0.8),5,5))

susanathey/MCPanel documentation built on May 29, 2019, 9:51 a.m.