Skip to content

Commit

Permalink
Fix how outputs of c-lasso are extracted
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbien committed Aug 9, 2021
1 parent 0ac626c commit 392a209
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions R/log_contrast.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ sparse_log_contrast <- function(Z, y, C = NULL, fraclist = NULL, nlam = 20, min_
prob$solve()

# extract outputs
beta <- purrr::map(prob$solution$PATH$BETAS, as.numeric) %>%
rlang::set_names(paste0("V", 1:length(prob$solution$PATH$BETAS))) %>%
dplyr::bind_cols() %>%
as.matrix()
beta <- t(prob$solution$PATH$BETAS)
# purrr::map(prob$solution$PATH$BETAS, as.numeric) %>%
# rlang::set_names(paste0("V", 1:length(prob$solution$PATH$BETAS))) %>%
# dplyr::bind_cols() %>%
# as.matrix()
lambda_classo <- prob$model_selection$PATHparameters$lambdas
beta0 <- ybar - crossprod(beta, v)
rownames(beta) <- colnames(Z)
Expand Down
9 changes: 5 additions & 4 deletions R/trac.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ trac <- function(Z, y, A, fraclist = NULL, nlam = 20, min_frac = 1e-4, w = NULL)
prob$solve()

# extract outputs
delta <- purrr::map(prob$solution$PATH$BETAS, as.numeric) %>%
rlang::set_names(paste0("V", 1:length(prob$solution$PATH$BETAS))) %>%
dplyr::bind_cols() %>%
as.matrix()
delta <- t(prob$solution$PATH$BETAS)
# purrr::map(prob$solution$PATH$BETAS, as.numeric) %>%
# rlang::set_names(paste0("V", 1:length(prob$solution$PATH$BETAS))) %>%
# dplyr::bind_cols() %>%
# as.matrix()
# gammahat = W^-1 deltahat and betahat = A gammahat
gamma <- diag(1 / w[[iw]]) %*% delta
beta <- A %*% gamma
Expand Down

0 comments on commit 392a209

Please sign in to comment.