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 = μ + AB′x + Dz + innov, where for each realization
The matrix resulted from AB′ will be a reduced rank coefficient matrix with rank of r. The function estimates parameters μ, 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
#>
#> Coefficients:
#> mu A B D Sigma1 Sigma2 Sigma3
#> 1 0.10000 -0.86245 -0.17768 -0.27616 1.00000 0.00000 0.00000
#> 2 0.10000 1.10019 -1.22766 -0.72719 0.00000 1.00000 0.00000
#> 3 0.10000 -1.78883 -0.04880 -2.85203 0.00000 0.00000 1.00000
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.862 1.1 -1.789
#> ..$ B : num [1:3, 1] -0.1777 -1.2277 -0.0488
#> ..$ mu : num [1:3] 0.1 0.1 0.1
#> ..$ D : num [1:3, 1] -0.276 -0.727 -2.852
#> ..$ 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.16 1.352 -0.322 0.77 -1.267 ...
#> $ y : num [1:1000, 1:3] 0.32 1.915 -0.608 -0.34 0.373 ...
#> $ x : num [1:1000, 1:3] -0.177 1.3004 1.0156 0.0436 1.8677 ...
#> $ z : num [1:1000] 1.678 0.979 1.196 -0.501 0.207 ...
#> - 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.087648 -1.033414 -0.107367 -0.219972 2.308285 -0.069386 0.163176
#> 2 0.138203 1.500268 -0.956866 -0.679975 -0.069386 2.466314 -0.141644
#> 3 0.157867 -2.318500 -0.057238 -2.915350 0.163176 -0.141644 2.079108
The matrix z and the constant μ 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 μ 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.098722 -0.530366 -0.257934 -0.241567 0.690966 -0.013147 0.028854
#> 2 0.092231 0.704872 -1.909565 -0.706124 -0.013147 0.655978 0.035020
#> 3 0.096387 -1.139750 -0.056461 -2.868711 0.028854 0.035020 0.688868
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
× 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.
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:
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 μ 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)
#> Loading required namespace: lazybar
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.098952 -0.535421 -0.255247 -0.240615 0.707746 -0.014477 0.029848
#> 2 0.089240 0.709857 -1.893922 -0.707962 -0.014477 0.672519 0.036224
#> 3 0.095903 -1.150363 -0.056305 -2.867751 0.029848 0.036224 0.703040
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
.
When using SAA, there are two sub solver supported in each iteration.
optim
function from the stats
package, andres_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.158292 -0.258096 -0.342369 -0.580689 1.467511 -0.023547 -0.485638
#> 2 0.042518 0.632266 -2.029709 -0.366442 -0.023547 1.693622 -0.114939
#> 3 0.080117 -0.893575 -0.494176 -2.098692 -0.485638 -0.114939 2.691655
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.
This package is free and open source software, licensed under GPL-3