R/methods.R
changed.
R/lspath_strong.R
changed.
R/lspath_strong_weights.R
changed.
Other files ignored by Codecov
50 | 50 | #' predict(fit, s = 0.45) # predicted response for a single lambda value |
|
51 | 51 | #' predict(fit, s = c(2.15, 0.32, 0.40), type="nonzero") # nonzero coefficients |
|
52 | 52 | #' @seealso \code{\link{predict.cv.sail}} |
|
53 | + | #' @note When the coef method is called, the alpha values, which represent the |
|
54 | + | #' interaction term are returned. This alpha is the product of beta_e,gamma_j |
|
55 | + | #' and theta_j |
|
53 | 56 | #' @rdname predict.sail |
|
54 | 57 | #' @export |
|
55 | 58 | predict.sail <- function(object, newx, newe, s = NULL, |
60 | 60 | # this is used for the predict function |
|
61 | 61 | design <- expansion$design |
|
62 | 62 | ||
63 | - | nulldev <- as.numeric(crossprod(y - mean(y))) |
|
63 | + | nulldev <- as.numeric(crossprod(sqrt(weights)*(y - mean(y)))) |
|
64 | 64 | ||
65 | 65 | # Initialize ------------------------------------------------------------- |
|
66 | 66 | # the initial values here dont matter, since at Lambda_max everything is 0 |
430 | 430 | if (abs(environ[lambdaIndex]) > 0) "E" |
|
431 | 431 | ) |
|
432 | 432 | ||
433 | - | deviance <- crossprod(R.star) |
|
433 | + | deviance <- crossprod(sqrt(weights)*R.star) |
|
434 | 434 | devRatio <- 1 - deviance / nulldev |
|
435 | 435 | dfbeta <- sum(abs(betaMat[, lambdaIndex]) > 0) / ifelse(expand, ncols, 1) |
|
436 | 436 | dfalpha <- sum(abs(alphaMat[, lambdaIndex]) > 0) / ifelse(expand, ncols, 1) |
59 | 59 | # this is used for the predict function |
|
60 | 60 | design <- expansion$design |
|
61 | 61 | ||
62 | - | nulldev <- as.numeric(crossprod(y - mean(y))) |
|
62 | + | nulldev <- as.numeric(crossprod(sqrt(weights)*(y-mean(y)))) |
|
63 | 63 | ||
64 | 64 | # Initialize ------------------------------------------------------------- |
|
65 | 65 | # the initial values here dont matter, since at Lambda_max everything is 0 |
253 | 253 | # |
|
254 | 254 | # R.star <- R.star + Delta |
|
255 | 255 | ||
256 | - | ||
257 | - | ||
258 | - | ||
259 | 256 | # converged_theta <- FALSE |
|
260 | 257 | # k <- 1 |
|
261 | 258 | # while (!converged_theta && k < maxit){ |
269 | 266 | gglasso = coef(gglasso::gglasso( |
|
270 | 267 | x = x_tilde_2[[j]], |
|
271 | 268 | y = R, |
|
272 | - | weights=weights, |
|
269 | + | weight=diag(weights), |
|
273 | 270 | # eps = 1e-12, |
|
274 | 271 | maxit = 100000, |
|
275 | 272 | group = if (expand) rep(1, ncols) else rep(1, ncols[j]), |
315 | 312 | gglasso = coef(gglasso::gglasso( |
|
316 | 313 | x = x_tilde_2[[j]], |
|
317 | 314 | y = R, |
|
315 | + | ||
318 | 316 | # eps = 1e-12, |
|
319 | - | weights=weights, |
|
317 | + | weight=diag(weights), |
|
320 | 318 | group = if (expand) rep(1, ncols) else rep(1, ncols[j]), |
|
321 | 319 | pf = wj[j], |
|
322 | 320 | lambda = LAMBDA * (1 - alpha), |
448 | 446 | if (abs(environ[lambdaIndex]) > 0) "E" |
|
449 | 447 | ) |
|
450 | 448 | ||
451 | - | deviance <- crossprod(R.star) |
|
449 | + | deviance <- crossprod(sqrt(weights)*R.star) |
|
452 | 450 | devRatio <- 1 - deviance / nulldev |
|
453 | 451 | dfbeta <- sum(abs(betaMat[, lambdaIndex]) > 0) / ifelse(expand, ncols, 1) |
|
454 | 452 | dfalpha <- sum(abs(alphaMat[, lambdaIndex]) > 0) / ifelse(expand, ncols, 1) |
Files | Coverage |
---|---|
R | 53.53% |
Project Totals (11 files) | 53.53% |