library(RRRR)

The R package *RRRR* provides methods for estimating online Robust Reduced-Rank Regression.

If you use any code from the `RRRR`

package in a publication, please use the following citation:

Yangzhuoran Yang and Ziping Zhao (2020). RRRR: Online Robust Reduced-Rank Regression Estimation. R package version 1.1.0. https://pkg.yangzhuoranyang.com/RRRR/.

This vignette aims to provide illustrations to estimate and update (Online) Reduced-Rank Regression using various methods contained in the package.

The formulation of the reduced-rank regression is as follow: \[y = \mu +AB' x + D z+innov,\] where for each realization

- \(y\) is a vector of dimension \(P\) for the \(P\) response variables,
- \(x\) is a vector of dimension \(Q\) for the \(Q\) explanatory variables that will be projected to reduce the rank,
- \(z\) is a vector of dimension \(R\) for the \(R\) explanatory variables that will not be projected,
- \(\mu\) is the constant vector of dimension \(P\),
- \(innov\) is the innovation vector of dimension \(P\),
- \(D\) is a coefficient matrix for \(z\) with dimension \(P*R\),
- \(A\) is the so called exposure matrix with dimension \(P*r\), and
- \(B\) is the so called factor matrix with dimension \(Q*r\).

The matrix resulted from \(AB'\) will be a reduced rank coefficient matrix with rank of \(r\). The function estimates parameters \(\mu\), \(A\), \(B\), \(D\), and \(Sigma\), the covariance matrix of the innovation’s distribution.

To simulate example data that can be used to estimate reduced-rank regression, use function `RRR_sim`

.

data <- RRR_sim() data #> Simulated Data for Reduced-Rank Regression #> ------------ #> Specifications: #> N P Q R r #> 1000 3 3 1 1 #> mu A B D Sigma1 Sigma2 Sigma3 #> [1,] 0.1 -0.57972 0.66836 -1.14262 1 0 0 #> [2,] 0.1 1.23951 0.90302 0.38585 0 1 0 #> [3,] 0.1 -1.57065 0.14896 0.36981 0 0 1

A number of parameters can be specified. See `?RRR_sim`

. The default arguments are set in such a way that the matrix resulted from \(AB'\) will be a reduced rank coefficient matrix with rank of \(r\).

str(data) #> List of 4 #> $ spec:List of 11 #> ..$ P : num 3 #> ..$ N : num 1000 #> ..$ Q : num 3 #> ..$ R : num 1 #> ..$ A : num [1:3, 1] -0.58 1.24 -1.57 #> ..$ B : num [1:3, 1] 0.668 0.903 0.149 #> ..$ mu : num [1:3] 0.1 0.1 0.1 #> ..$ D : num [1:3, 1] -1.143 0.386 0.37 #> ..$ r : num 1 #> ..$ Sigma: num [1:3, 1:3] 1 0 0 0 1 0 0 0 1 #> ..$ innov: num [1:1000, 1:3] 0.915 1.198 -1.929 0.865 -6.269 ... #> $ y : num [1:1000, 1:3] -0.0381 1.0467 -2.2335 0.8475 -8.4003 ... #> $ x : num [1:1000, 1:3] -1.343 0.558 0.673 -0.43 -0.425 ... #> $ z : num [1:1000] 1.3283 -0.0353 -0.5644 0.1415 1.461 ... #> - attr(*, "class")= chr [1:2] "RRR_data" "list"

The returned list of `RRR_sim`

contains the input specifications and the data points \(y\), \(x\) and \(z\).

`RRR`

The Gaussian Maximum Likelihood Estimation method is described in Johansen, S. (1991). This method is not robust in the sense that it assumes a Gaussian distribution for the innovations which does not take into account the heavy-tailedness of the true distribution and outliers.

res_gmle <- RRR(y=data$y, x=data$x, z = data$z) res_gmle #> Reduced-Rank Regression #> ------------ #> Specifications: #> N P Q R r #> 1000 3 3 1 1 #> #> Coefficients: #> mu A B D Sigma1 Sigma2 Sigma3 #> [1,] 0.14662 0.70211 -0.612255 -1.14929 3.10307 -0.11446 1.5703 #> [2,] 0.11145 -1.37839 -0.796612 0.36732 -0.11446 2.60204 -1.1242 #> [3,] 0.21744 1.73995 -0.095007 0.23867 1.57034 -1.12418 6.3238

The matrix \(z\) and the constant \(\mu\) term are optional.

`RRRR`

The Majorisation-Minimisation estimation method is partly described in Zhao, Z., & Palomar, D. P. (2017). This method is robust in the sense that it assumes a heavy-tailed Cauchy distribution for the innovations. As before the matrix \(z\) and the constant term \(\mu\) are optional.

res_mm <- RRRR(y=data$y, x=data$x, z = data$z, itr = 100, earlystop = 1e-4) res_mm #> Robust Reduced-Rank Regression #> ------ #> Majorisation-Minimisation #> ------------ #> Specifications: #> N P Q R r #> 1000 3 3 1 1 #> #> Coefficients: #> mu A B D Sigma1 Sigma2 Sigma3 #> [1,] 0.046554 -0.32689 1.16009 -1.15647 0.673157 0.0647023 -0.0126817 #> [2,] 0.126129 0.72817 1.51463 0.42336 0.064702 0.6399788 0.0050693 #> [3,] 0.148851 -0.92452 0.23707 0.29770 -0.012682 0.0050693 0.6340696

Additional arguments that are worth noticing are `itr`

, which control the maximum number of iteration, and `earlystop`

, which is the criteria to stop the algorithm early. The algorithm will stop if the improvement on objective value is small than `earlystop`

\(\times\ objective\_from\_last\_iteration\).

This method is an iterative optimization algorithm so we can use the inbuilt `plot.RRRR`

method to see the convergence plot of the algorithm.

plot(res_mm, aes_x = "iteration", xlog10 = TRUE)

Argument `aes_x`

can set the x axis to be the number of iteration or the run time. Argument `xlog10`

can indicate whether the scale of x axis is log 10 transformed.

`ORRRR`

The description of the generic Stochastic Successive Upper-bound Minimisation method and the Sample Average Approximation can be found in Razaviyayn, M., Sanjabi, M., & Luo, Z. Q. (2016).

There are two major estimation methods supported:

- SMM: Stochastic Majorisation-Minimisation
- SAA: Sample Average Approximation

The algorithm is online in the sense that the data is continuously incorporated and the algorithm can update the parameters accordingly. As before the matrix \(z\) and the constant term \(\mu\) are optional.

At each iteration of SAA, a new realisation of the parameters is achieved by solving the minimisation problem of the sample average of the desired objective function using the data currently incorporated. This can be computationally expensive when the objective function is highly nonconvex. The SMM method overcomes this difficulty by replacing the objective function by a well-chosen majorising surrogate function which can be much easier to optimise.

By default the function `ORRRR`

uses SMM.

res_smm <- ORRRR(y=data$y, x=data$x, z=data$z, initial_size = 100, addon = 10) res_smm #> Online Robust Reduced-Rank Regression #> ------ #> Stochastic Majorisation-Minimisation #> ------------ #> Specifications: #> N P R r initial_size addon #> 1000 3 1 1 100 10 #> #> Coefficients: #> mu A B D Sigma1 Sigma2 Sigma3 #> [1,] 0.045878 -0.32953 1.15124 -1.15618 0.687683 0.0661849 -0.0122914 #> [2,] 0.125692 0.73310 1.50476 0.42329 0.066185 0.6524464 0.0051605 #> [3,] 0.148649 -0.93105 0.23552 0.29812 -0.012291 0.0051605 0.6466301

The simulated data set is of size 1000. In the above command, in the first iteration 100 realisations are used in the estimation with 10 more data points in each of the following iteration. Because of the increasing data size, the estimation will be slower the longer the algorithm run. Therefore, the estimated time left in the progress bar is not very accurate in this sense.

The output from `ORRRR`

can also plotted using `plot.RRRR`

.

plot(res_smm)

When using SAA, there are two sub solver supported in each iteration.

- optim: the
`optim`

function from the`stats`

package, and - MM: Majorisation-Minimisation method with ten subiterations by default.

res_saa_optim <- ORRRR(y=data$y, x=data$x, z=data$z, method = "SAA", SAAmethod = "optim") res_saa_mm <- ORRRR(y=data$y, x=data$x, z=data$z, method = "SAA", SAAmethod = "MM")

`optim`

is a general purpose solver which means it will be quite slow for this specific problem, especially when the number of parameters is large. Embedding majorisation-minimisation into subiteration of SAA is more like a heuristic without solid theory backing up its efficiency. Due to the time constraint we do not show the estimated result here.

`update.RRRR`

With the result from `ORRRR`

, user can still update it with newly achieved data using function `update`

. Note the result from `RRRR`

can also be updated where it simply takes the result from `RRRR`

as the starting point in online estimation.

newdata <- RRR_sim() res2_smm <- update(res_smm, newy=newdata$y, newx=newdata$x, newz=newdata$z) res2_smm #> Online Robust Reduced-Rank Regression #> ------ #> Stochastic Majorisation-Minimisation #> ------------ #> Specifications: #> N P R r initial_size addon #> 2000 3 1 1 1010 10 #> #> Coefficients: #> mu A B D Sigma1 Sigma2 Sigma3 #> [1,] 0.072885 0.077666 -1.28133 -0.732230 2.22321 -0.59630 0.50239 #> [2,] 0.084728 -0.423691 -1.79656 0.241904 -0.59630 1.20205 -0.43277 #> [3,] 0.137870 0.546366 -0.28312 -0.083234 0.50239 -0.43277 1.73372

Without other arguments specified, `update`

will just take the original specification in the model. If it applies to output of `RRRR`

, then the default would be the default arguments in `ORRRR`

, i.e., with `method`

set to “SMM” and `addon`

set to 10.