venkmurthy

glmmLasso Reproducible Example of Penalties Applied Incorrectly

May 8th, 2022 (edited)
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.71 KB | None | 0 0
  1. library(glmmLasso)
  2. library(tidyverse)
  3. data(knee)
  4.  
  5. knee.scaled <- knee %>% mutate(across(-c("id"),scale))
  6.  
  7. # The output of this shows penalty applied to time (i.e. the first term in the formula)
  8. glmmLasso(pain ~ time + th + age:sex,rnd=list(id=~1),lambda=1e6,data=knee.scaled,control=list(index=c(NA, NA, 1)))
  9.  
  10. # The output of this shows the penalty applied to time (i.e. the first term in the formula)
  11. glmmLasso(pain ~ time + th + age:sex,rnd=list(id=~1),lambda=1e6,data=knee.scaled,control=list(index=c(1, NA, NA)))
  12.  
  13. # The output of this shows penalty applied to age (i.e. the last term in the formula)
  14. glmmLasso(pain ~ time + th + age,rnd=list(id=~1),lambda=1e6,data=knee.scaled,control=list(index=c(NA, NA, 1)))
  15.  
  16.  
Add Comment
Please, Sign In to add comment