weighted.sparsenet: Fit penalized weighted least square regression

Description Usage Arguments Details Value Author(s) Examples

Description

weighted.sparsenet is a function to fit the penalized weighted least square regression using coordinate descent algorithm.

Usage

1
weighted.sparsenet(X, y, delta = 1, n_lambda = 100, n_kappa = 1, kappa0 = 1/3, lambda0 = -1, eps = 1e-06, max.iter = 1000, method = "include", name.list = NA, weight = NA, AFT = TRUE, penalty = "MCP")

Arguments

X

Design matrix of size n by p, where n is the sample size and p is the number of variables.

y

response vector of length n.

delta

indicator vector of length n. Useful when AFT is TRUE. If δ_i equals 1, y_i is log failure time. If δ_i equals 0, y_i is log censored time.

n_lambda

number of lambda values in the grid. Default value is 100. Either delta or weight has to be specified by user.

n_kappa

number of kappa values in the grid. Default value is 1.

kappa0

Maximum value of κ. If penalty = "MCP" or "SCAD", it defaults 1/3, and the range of kappa is (0, kappa0). If penalty = "adaptive", it defaults 2, and range of kappa is (1, kappa0). In the adaptive LASSO case, kappa is the power to which the initial estimator is raised.

lambda0

Maximum value of λ. Default value is -1. If lambda0 = -1, the maximum value of λ will be the minimum λ such that all estimates of β are zero.

eps

Convergence threshhold. The algorithm iterates until the relative change in any coefficient is less than eps. Default is 1e-6.

max.iter

Maximum number of iteration. Default is 100.

method

Character. Either "exclude" or "include". If method equals "exclude", after the LASSO step, the function will automatically exclude all the zero estimates from LASSO and pass only the variables associated with non-zero estimates to MCP step. If method equals "include", then LASSO estimates will serve as a warm start value and all variables will be included in the MCP step. Default is "include".

name.list

vector to specify the names of rows of matrix X. Default is NA.

weight

Only useful when AFT is FALSE. Specifies the user defined weights associated with observations. Default is NA. Either delta or weight has to be specified by user.

AFT

logical. If TRUE, the function uses the accelerated failure time model to fit the response variable and weight will be calculated as Kaplan-Meier weights. If FALSE, weight will be the user specified weights for each observation. Default is TRUE.

penalty

The penalty to be added to the objective function. Values could be "MCP" (the default), "SCAD" or "adaptive" for MCP, SCAD and adaptive LASSO penalties, respectively. LASSO result is automatically computed.

Details

The function weighted.sparsenet computes the solutions to the penalized least square problem. It minimizes

L_{λ, γ}(β_0, β) = 1/2∑_{i=1}^nω_{ni}(Y_i-β_0 -X'_iβ)^2+∑\limits_{j=1}^pρ(r_{nj}|β_j|;λ, γ),

where ω_{n1}=δ_{(1)}/n, ω_{ni}=δ_{(i)}/(n-i+1)∏_{j=1}^{i-1}((n-j)/(n-j+1))^{δ_{(j)}} for i=2, 3, …, n, and r_{nj}=√{∑\limits_{i=1}^nω_{ni}(X_{ij}-\bar X_{ω j})^2}. For t>0, when the penalty is LASSO, ρ(t;λ)=|t|. When the penalty is MCP, ρ(t;λ,κ)=\int_0^tλ(1-\frac{κ x}{λ})_+dx. In the first step, it computes the solutions with LASSO penalty along λ. In the second step, it uses the LASSO solution as a warm start value to compute the solution with MCP penalty. At each point on the λ - κ surface, the function will return the corresponding solutions. To form the grid, a sequence of values of length n_lambda is computed, equally spaced on the log scale and is assigned to λ, and a sequence of values of length n_kappa is computed, equally spaced and is assigned to λ. The minimum of λ is 0 and the maximum of λ is lambda0. The minimum of κ is 0 and the maximum of κ is kappa0.

Value

A list of results.

omega

vector of length n. It contains the weights associated with n observations.

X

normalized design matrix. Useful when use the convexity function in this package.

betalasso

The fitted matrix of coefficients with LASSO penalty. The number of rows is equal to the number of coefficients in the model, and the number of columns is the number of λ.

betamcp

The fitted matrix of coefficients with MCP penalty if penalty = "MCP". The number of rows is equal to the number of coefficients in the model, and the number of columns is n_lambda times n_kappa. The uth column is the solution when λ equals the u mod n_lambdath element of vector lambda and κ equals the floor(u / n_lambda + 1)th element of vector kappa. See lambda and kappa below for more information.

betascad

The fitted matrix of coefficients with SCAD penalty if penalty = "SCAD". The number of rows is equal to the number of coefficients in the model, and the number of columns is n_lambda times n_kappa. The uth column is the solution when λ equals the u mod n_lambdath element of vector lambda and κ equals the floor(u / n_lambda + 1)th element of vector kappa. See lambda and kappa below for more information.

betaadap

The fitted matrix of coefficients with adaptive LASSO penalty if penalty = "adaptive". The number of rows is equal to the number of coefficients in the model, and the number of columns is n_lambda times n_kappa. The uth column is the solution when λ equals the u mod n_lambdath element of vector lambda and κ equals the floor(u / n_lambda + 1)th element of vector kappa. See lambda and kappa below for more information.

iter

number of iterations in each MCP/SCAD solution.

lambda

vector of length n_lambda. The sequence of parameter λ in the grid.

kappa

vector of length n_kappa. The sequence of parameter κ in the grid.

n_lambda

number of lambda values in the grid.

n_kappa

number of kappa values in the grid.

r

vector of length p. It contains normlizing constants for each column of design matrix X.

n

number of rows of matrix X.

p

number of columsn of matrix X.

name

The names associated with the selected variables.

Author(s)

Hao Chai <hao.chai@yale.edu>

Examples

1
2
3
4
5
6
X = matrix(rnorm(8000), nrow = 20)
beta0 = c(rep(10, 5), rep(0, 395))
y = rnorm(20) + X %*% beta0
delta = rep(1, 20)
result = weighted.sparsenet(X, y, delta,
n_kappa = 40, kappa0 = 0.99)

andrewchay/aft-hd documentation built on May 14, 2019, 8:21 a.m.