LPR: Lasso and Partial Ridge

Description Usage Arguments Value Examples

View source: R/LPR.R

Description

This package contains a function called "LPR" to estimate coefficients using "Lasso and Partial Ridge" method and to calculate confidence intervals through bootstrap.

Usage

1
LPR(x, y, lambda2, B, type.boot=c("residual","paired"), alpha = 0.05)

Arguments

x

explanatory variables

y

dependent variable

lambda2

tuning parameter for partial ridge, suggested value is 1/n

B

the times of bootstrap

type.boot

the type of bootstrap, "paired" or "residual"

alpha

confidence level

Value

lambda.opt

chosen tuning parameter for LASSO

Beta

regression coefficients estimated by LASSO

Beta.LPR

regression coefficients estimated by LASSO and Partial Ridge(LPR)

selectset

coefficients set selected by LASSO

interval.LPR

confidence interval through bootstrap

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#generate dataset	
set.seed(2015)
n <- 100    
p <- 250
B <- 100
s <- 10
rho <- 0.5
z <- matrix(rnorm(n*p),ncol=p)
x <- matrix(0,n,p)
x[,1] <- z[,1]
for(j in 2:p){
  x[,j] <- rho*x[,j-1]+sqrt(1-rho^2)*z[,j]
}

#beta is decaying
beta <- rep(0,p)
ind.s <- sample(1:p,s)
beta[ind.s] <- rnorm(s,1,sqrt(0.001))
for( j in setdiff(1:p,ind.s) ){
  beta[j]<-1/(j+3)^2
}
#generate y
epsilon <- rep(0,n)
epsilon <- rnorm(n,0,0.1)
y <- x%*%beta + epsilon
#use LPR
LPR.obj <- LPR(x, y, 1/n, B, type.boot="paired", alpha=0.05)

Example output



LPR documentation built on May 29, 2017, 11:37 p.m.

Related to LPR in LPR...