View source: R/rlassoEffects.R
coef.rlassoEffects | R Documentation |
rlassoEffects
Method to extract coefficients from objects of class rlassoEffects
## S3 method for class 'rlassoEffects'
coef(
object,
complete = TRUE,
selection.matrix = FALSE,
include.targets = FALSE,
...
)
object |
an object of class |
complete |
general option of the function |
selection.matrix |
if TRUE, a selection matrix is returned that indicates the selected variables from each auxiliary regression. Default is set to FALSE. |
include.targets |
if FALSE (by default) only the selected control variables are listed in the |
... |
further arguments passed to functions coef or print. |
Printing coefficients and selection matrix for S3 object rlassoEffects
. Interpretation of entries in the selection matrix
"-"
indicates a target variable,
"x"
indicates that a variable has been selected with rlassoEffects (coefficient is different from zero),
"."
indicates that a variable has been de-selected with rlassoEffects (coefficient is zero).
library(hdm)
set.seed(1)
n = 100 #sample size
p = 100 # number of variables
s = 7 # number of non-zero variables
X = matrix(rnorm(n*p), ncol=p)
colnames(X) <- paste("X", 1:p, sep="")
beta = c(rep(3,s), rep(0,p-s))
y = 1 + X%*%beta + rnorm(n)
data = data.frame(cbind(y,X))
colnames(data)[1] <- "y"
lasso.effect = rlassoEffects(X, y, index=c(1,2,3,50),
method = "double selection")
coef(lasso.effect) # standard use of coef() - without selection matrix
# with selection matrix
coef(lasso.effect, selection.matrix = TRUE)
# prettier output with print_coef (identical options as coef())
print_coef(lasso.effect, selection.matrix = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.