Description Usage Arguments Details Examples
Add a penalty term to a latent variable model
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | penalize(x, ...)
penalize(x, ...) <- value
## S3 method for class 'lvm'
penalize(x, value = NULL, ...)
## S3 replacement method for class 'lvm'
penalize(x, group, add = TRUE, reduce = FALSE,
Vlasso = TRUE, Vridge = TRUE, Vgroup = TRUE, intercept = FALSE,
regression = TRUE, variance = FALSE, covariance = FALSE,
latent = FALSE, ...) <- value
penalizeNuclear(x, ...)
penalizeNuclear(x, ...) <- value
## S3 method for class 'lvm'
penalizeNuclear(x, value = NULL, ...)
## S3 replacement method for class 'lvm'
penalizeNuclear(x, coords = NULL, lambdaN = NULL,
...) <- value
|
x |
|
value |
the name of the link to be penalized |
group |
the groups defining the group lasso penalty |
add |
should value be added to the existing penalty term ? Otherwise it will overwrite it. |
reduce |
should for each regression the penalised link be aggregated into a linear predictor. |
Vlasso |
the matrix defining lasso penalties. Otherwise must be logical to indicate whether to add lasso penalties. |
Vridge |
the matrix defining ridge penalties. Otherwise must be logical to indicate whether to add ridge penalties. |
Vgroup |
the matrix defining group lasso penalties. Otherwise must be logical to indicate whether to add group lasso penalties. |
intercept |
should all intercept be penalized. Disregarded if value is specified. |
regression |
should all regression parameters be penalized. Disregarded if value is specified. |
variance |
should all covariance links be penalized. Disregarded if value is specified. |
latent |
If FALSE, no link related to the latent variable will be penalized. Disregarded if value is specified. |
coords |
the (spatial) position of the links to penalize |
By default categorical variables are penalised using a group lasso penalty. penalize functions can be used to add lasso or/and ridge penalty terms to the model. penaltyNuclear functions can be used to add a nuclear penalty to the model.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #### lasso penalty ####
set.seed(10)
n <- 500
formula.lvm <- as.formula(paste0("Y~",paste(paste0("X",1:5), collapse = "+")))
lvm.modelSim <- lvm()
regression(lvm.modelSim, formula.lvm) <- as.list( c(rep(0,2),1:3) )
distribution(lvm.modelSim, ~Y) <- normal.lvm(sd = 2)
df.data <- sim(lvm.modelSim,n)
lvm.model <- lvm(formula.lvm)
plvm.model <- penalize(lvm.model)
#### group penalty ####
m <- lvm(Y1 ~ X1+X2+X3+X4)
categorical(m, labels = c("A","B","C")) <- "X1"
categorical(m, labels = c("A","B","C")) <- "X2"
pm <- penalize(m, value = c("Y1~X1","Y1~X3","Y1~X4"))
pm$penalty
pm1 <- penalize(m, value = c("Y1~X1"))
pm1 <- penalize(pm1, value = c("Y1~X2","Y1~X3"))
m <- lvm(list(Y1 ~ X1+X2+X3+X4+eta, Y2 ~ X1+X2+X3+eta, Y3 ~ eta))
categorical(m, labels = c("A","B","C")) <- "X1"
latent(m) <- ~eta
penalize(m)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.