# \donttest{
# generate data from a logistic regression model with n = 100, p = 50, and K = 3
set.seed(0, kind = "L'Ecuyer-CMRG")
n <- 100
p <- 50
K <- 3
Sigma <- outer(1:p, 1:p, function(x,y) {
0.9^(abs(x-y))
})
R <- chol(Sigma)
s <- 3
beta_coef <- matrix(0, nrow = p+1, ncol = K-1)
beta_coef[1+1:s, 1] <- c(3, 3, 3)
beta_coef[1+1:s+s, 2] <- c(3, 3, 3)
x <- matrix(rnorm(n*p), ncol = p) %*% R
y <- sapply(1:n, function(j){
prob_i <- c(sapply(1:(K-1), function(k){
exp(sum(x[j, ]*beta_coef[-1, k]))
}), 1)
prob_i <- prob_i/sum(prob_i)
sample(1:K, size = 1, replace = TRUE, prob = prob_i)
})
# fit the l1-penalized multinomial regression model
fit <- cv.pemultinom(x, y, ncores = 2)
beta <- fit$beta.min
# run the debiasing approach
fit_debiased <- debiased_lasso(x, y, beta = beta, ncores = 2)
# }
Run the code above in your browser using DataLab