# Note we use here a very small example data set and few candidate lambda1
# and lambda2 to expedite examples.
# load toy dataset
data("CNVCOVY")
# prepare data format for regression analysis
## Continuous outcome Y_QT
frag_data <- prep(CNV = CNV, Y = Y_QT, Z = Cov, rare.out = 0.05)
QT_tune <- cvfit_WTSMTH(frag_data,
lambda1 = seq(-4.75, -5.25, -0.25),
lambda2 = seq(18, 22, 1),
weight = "eql",
family = "gaussian")
## Binary outcome Y_BT
# We can directly replace frag_data$Y with Y_BT in the correct format,
# ensuring that the ordering matches that of the prepared object.
rownames(Y_BT) <- Y_BT$ID
frag_data$Y <- Y_BT[names(frag_data$Y), "Y"] |> drop()
names(frag_data$Y) <- rownames(frag_data$Z)
# Or, we can also repeat the prep() call
# frag_data <- prep(CNV = CNV, Y = Y_BT, Z = Cov, rare.out = 0.05)
BT_tune <- cvfit_WTSMTH(frag_data,
lambda1 = c(-5.25, -5, -4.75),
lambda2 = c(5, 6, 7),
weight = "eql",
family = "binomial")
Run the code above in your browser using DataLab