Description Usage Arguments Details Value Author(s) References Examples
Standardizes feature matrix including categorical features and fits a group lasso model
1 |
eqn |
|
dat |
|
lambda |
Penalty parameter (scalar) |
model |
an object of class |
nonpen |
|
standardize |
logical. If true, the design matrix of the continuous features will be centered and standardized to unit norm |
... |
additional arguments to be passed to the |
Design matrices of the categorical features and interactions between categorical features are centered and standardized by column-wise scaling. After fitting a group lasso model to the standardized desgin matrix, coefficients are re-scaled and centered to the original scale of the data. Interactions between categorical and continuous features are standardized by a singular value decomposition.
A dataframe containing the coefficients of the fitted group lasso model that have been re-scaled to the original scale of the data is returned. Coefficients of interaction terms for which no observations are included in dat are returned as NA.
Felicitas Detmer, fdetmer@gmu.edu
Detmer, Felicitas J., and Martin Slawski. "A Note on Coding and Standardization of Categorical Variables in (Sparse) Group Lasso Regression." arXiv preprint arXiv:1805.06915 (2018).
1 2 3 4 5 6 7 8 9 10 11 12 13 | data(dattest)
#---set datatype of categorical features to factor=----
dattest$X1cut=as.factor(dattest$X1cut)
dattest$X2cut=as.factor(dattest$X2cut)
dattest$X3cut=as.factor(dattest$X3cut)
table(dattest[,c("X1cut", "X2cut", "X3cut")])
#--fit group lasso models
coefs1=fit_grp(y~X1cut * X2cut +X1cut * X3cut +X2cut * X3cut, dattest, lambda=0.5, model=LinReg())
coefs2=fit_grp(y~X1cut * X2cut +X1cut * X3cut +X2cut * X3cut, dattest, lambda=0.5, model=LinReg(),
nonpen=~X1cut)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.