Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/utility_functions.R
This function runs the first iteration of the fitting algorithm
just to get the sequence of lambda_gamma
and lambda_beta
1 2 3 |
x |
Design matrix of dimension |
y |
response variable (matrix form) of dimension |
main.effect.names |
character vector of main effects names |
interaction.names |
character vector of interaction names. MUST be
separated by a colon (e.g. |
initialization.type |
The procedure used to estimate the regression
coefficients and used in the |
nlambda.gamma |
number of tuning parameters for gamma |
nlambda.beta |
number of tuning parameters for beta |
lambda.factor |
The factor for getting the minimal lambda in lambda
sequence, where |
A unique sequence of tuning parameters for the main effects (lambda.beta) is calculated for each tuning parameter for the interaction terms (lambda.gamma)
list of length 2, first element is lambda_gamma
and second
element is lambda_beta
Sahir Bhatnagar
Maintainer: Sahir Bhatnagar sahir.bhatnagar@mail.mcgill.ca
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 30 31 32 | # number of observations
n <- 100
# number of predictors
p <- 5
# environment variable
e <- sample(c(0,1), n, replace = T)
# main effects
x <- cbind(matrix(rnorm(n*p), ncol = p), e)
# need to label columns
dimnames(x)[[2]] <- c("x1","x2","x3","x4","x5","e")
# design matrix without intercept (can be user defined interactions)
X <- model.matrix(~(x1+x2+x3)*e+x1*x4+x3*x5-1, data = as.data.frame(x))
# names must appear in the same order as X matrix
interaction_names <- grep(":", colnames(X), value = T)
main_effect_names <- setdiff(colnames(X), interaction_names)
# response
Y <- X %*% rbinom(ncol(X), 1, 0.6) + 3*rnorm(n)
# standardize data
data_std <- standardize(X,Y)
shim_once(x = data_std$x, y = data_std$y,
main.effect.names = main_effect_names,
interaction.names = interaction_names,
nlambda.gamma = 5, nlambda.beta = 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.