mls: Modified Least Squares

Description Usage Arguments Details Value Examples

View source: R/mls.R

Description

Computes modified Least Squares estimate.

Usage

1
mls(x, y, tau = 0, standardize = TRUE, intercept = TRUE)

Arguments

x

Input matrix as in glmnet, of dimension nobs x nvars; each row is an observation vector.

y

Response variable.

tau

Tuning parameter in modified Least Squares (mls). Default value is 0, which corresponds to Ordinary Least Squares (OLS).

standardize

Logical flag for x variable standardization, prior to fitting the model. Default is standardize=TRUE.

intercept

Should intercept be fitted (default is TRUE) or set to zero (FALSE).

Details

The function is used to compute the modified Least Squares (mLS) estimator defined in the paper: Liu H, Yu B. Asymptotic Properties of Lasso+mLS and Lasso+Ridge in Sparse High-dimensional Linear Regression. Electronic Journal of Statistics, 2013, 7.

Value

A list consisting of the following elements is returned.

beta

The mLS coefficient of variables/predictors.

beta0

A value of intercept term.

meanx

The mean vector of variables/predictors if intercept=TRUE, otherwise is a vector of 0's.

mu

The mean of the response if intercept=TRUE, otherwise is 0.

normx

The vector of standard error of variables/predictors if standardize=TRUE, otherwise is a vector of 1's.

tau

The tuning parameter in mLS.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
library("mvtnorm") 

## generate the data
set.seed(2015)
n <- 200      # number of obs
p <- 500
s <- 10
beta <- rep(0, p)
beta[1:s] <- runif(s, 1/3, 1)
x <- rmvnorm(n = n, mean = rep(0, p), method = "svd")
signal <- sqrt(mean((x %*% beta)^2))
sigma <- as.numeric(signal / sqrt(10))  # SNR=10
y <- x %*% beta + rnorm(n)

## modified Least Squares
set.seed(0)
obj <- mls(x = x[, 1:20], y = y)
# the OLS estimate of the regression coefficients
obj$beta
# intercept term
obj$beta0
# prediction
mypredict(obj, newx = matrix(rnorm(10*20), 10, 20))

xinxuyale/HDCI documentation built on May 23, 2019, 9:51 a.m.