Description Usage Arguments Details Value Author(s) References Examples
This function fits a spatial scale (SS) LARS model.
1 |
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 |
This function estimates coefficients using the SS LARS modeling approach. The function also provides summary details and plots a coefficient path plot.
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 |
Lauren Grant, David Wheeler
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
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_LARS.ss <- lars.ss(y, X, ss, a.lst, S.v, C.v, c("black", "red", "green"))
|
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
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.
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
[1] 2
[1] 48.42314
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: 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.
Gamma values: 0.4194236 0 0 0 0
Gamma hat: 0.4194236
Step 6: Update betas and r.
Beta.new: 0 0.3320495 0 0 0.06366526
[1] 2 5
[1] 45.96404
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: 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.
Gamma hat: 2.681512
Step 6: Update betas and r.
Beta.new: 0.4703167 0.6784187 0 0 0.4442981
[1] 2 5 1
[1] 36.09188
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"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.