lasso.ss: Spatial scale lasso

Description Usage Arguments Details Value Author(s) References Examples

View source: R/lasso.ss.R

Description

This function fits a spatial scale (SS) lasso model.

Usage

1
lasso.ss(y, X, ss, a.lst, S.v, C.v, col.plot, verbose=TRUE, plot=TRUE)

Arguments

y

A numeric response vector

X

A data frame of numeric variables

ss

A vector of names to identify the different levels of covariates available as potential candidates for model input

a.lst

A list of identity matrices, where each column indicates a particular level or spatial scale for a specified covariate (e.g., ss1_x2)

S.v

A vector of positive integers, where each number denotes the number of spatial scales associated with a particular covariate

C.v

A vector, where all values are initialized to 0

col.plot

A vector of colors (corresponding to each SS) used in the coefficient path plot

verbose

If TRUE, details are printed as the algorithm progresses

plot

If TRUE, a coefficient path plot is generated

Details

This function estimates coefficients using the SS lasso modeling approach. The function also provides summary details and plots a coefficient path plot.

Value

A list with the following items:

beta

Regression coefficient estimates from all set of model solutions

beta.aic

Regression coefficient estimates from final model

ind.v

Vector of indices to denote the corresponding columns of X associated with each active predictor

aic.v

Vector of Akaike information criterion (AIC) values

stack.ss

Vector of indices to indicate the level at which each covariate enters the model

Author(s)

Lauren Grant, David Wheeler

References

Grant LP, Gennings C, Wheeler, DC. (2015). Selecting spatial scale of covariates in regression models of environmental exposures. Cancer Informatics, 14(S2), 81-96. doi: 10.4137/CIN.S17302

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(y)
data(X)

names.X <- colnames(X)

ss <- c("ind", "ss1", "ss2")

a.lst <- list(NULL)
a.lst[[1]] <- 1
dim(a.lst[[1]]) <- c(1,1)
dimnames(a.lst[[1]]) <- list(NULL, names.X[1])

a.lst[[2]] <- diag(2)
dimnames(a.lst[[2]]) <- list(NULL, names.X[c(2,3)])

a.lst[[3]] <- diag(2)
dimnames(a.lst[[3]]) <- list(NULL, names.X[c(4,5)])

S.v <- c(1,2,2)
C.v <- rep(0,length(a.lst))

mod_lasso.ss <- lasso.ss(y, X, ss, a.lst, S.v, C.v, c("black", "red", "green"))

Example output

Loading required package: tester
Loading required package: magic
Loading required package: abind
Loading required package: pracma

Attaching package: 'pracma'

The following object is masked from 'package:magic':

    magic

Step 1: Set r=y and initialize all betas to 0. 
Step 2: Find the predictor that has the greatest absolute correlation with r. 
	 Note that LARS picks the maximal absolute current correlation. 
 
LARS Iteration 1
	Variable 2 added
	  Step 3: Compute c.hat.v and C.hat. 
            [,1]
x1      4.580816
ss1_x2 12.486376
ss1_x3  2.576488
ss2_x3  8.111859
	  Step 4: Set s.j=sign{c.hat.v}, and calculate X.in, A.in, u.in, and a. 
	  Step 5: Calculate gamma.hat and d.v. 
maximal abs current cor 7.387076 
	 	  Gamma values: 1.537737 0 0 2.235952 1.16986 
	 	  Gamma hat: 1.16986 
	  Step 6: Update betas and r. 
	 	  Beta.new: 0 0.2683842 0 0 0 
 
ind.v 2 5 
col.ind 1 
LARS Iteration 2
	Variable 5 added
	  Step 3: Compute c.hat.v and C.hat. 
           [,1]
x1     5.495804
ss1_x2 7.387076
ss2_x3 7.387076
	  Step 4: Letting s.j=sign{c.hat.v}, update X.in, A.in, and u.in and calculate a=t(X)*u.in. 
	  Step 5: Calculate gamma.hat and d.v. 
gamma.hat.v 0.4194236 0 0 0 0 
gamma.hat 0.4194236 
maximal abs current cor 6.005505 
	 	  Gamma values: 0.4194236 0 0 0 0 
	 	  Gamma hat: 0.4194236 
beta.old[i,][ind.v] 0.2683842 0 
gamma.j -1.768102 0 
gamma.tilda Inf 
gamma.tilda.index  
beta.new[ind.v] 0.3320495 0.06366526 
beta.new[ind.v] 0.3320495 0.06366526 
	  Step 6: Update betas and r.
	 	  Beta.new: 0 0.3320495 0 0 0.06366526 
ind.v 2 5 1 
col.ind  
LARS Iteration 3
	Variable 1 added
	  Step 3: Compute c.hat.v and C.hat. 
           [,1]
x1     6.005505
ss1_x2 6.005505
ss2_x3 6.005505
	  Step 4: Letting s.j=sign{c.hat.v}, update X.in, A.in, and u.in and calculate a=t(X)*u.in. 
	  Step 5: Calculate gamma.hat and d.v. 
[1] 2.681512
maximal abs current cor 0 
	 	  Gamma hat: 2.681512 
beta.old[i,][ind.v] 0.3320495 0.06366526 0 
gamma.j -2.570651 -0.448514 0 
gamma.tilda Inf 
gamma.tilda.index  
beta.new[ind.v] 0.6784187 0.4442981 0.4703167 
beta.new[ind.v] 0.6784187 0.4442981 0.4703167 
	  Step 6: Update betas and r.
	 	  Beta.new: 0.4703167 0.6784187 0 0 0.4442981 
       x1    ss1_x2    ss2_x3 
0.4703167 0.6784187 0.4442981 
[1] "No. of vars in model = 3"
[1] "Total no. of vars considered = 5"
Warning messages:
1: In min(gamma.j[gamma.j > 0]) :
  no non-missing arguments to min; returning Inf
2: In min(gamma.j[gamma.j > 0]) :
  no non-missing arguments to min; returning Inf
3: In min(gamma.j[gamma.j > 0]) :
  no non-missing arguments to min; returning Inf
4: In min(gamma.j[gamma.j > 0]) :
  no non-missing arguments to min; returning Inf

spselect documentation built on May 2, 2019, 3:32 a.m.