Skip to content

Commit

Permalink
New bugfix in predict.rosa() and coef.rosa()
Browse files Browse the repository at this point in the history
  • Loading branch information
khliland committed Apr 25, 2023
1 parent 78de2bf commit 8b8a923
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Kristian Hovde Liland

##### Version 0.8.6
Date: 25 April 2023
>> Corrected error in coef.rosa() also affecting predict.rosa() (ncomp did no return all comps up to ncomp).
>> Corrected error in predict.rosa() (wrong intercept when using coefs argument).
>> Extended documentation for coef.rosa() and predict.rosa().

##### Version 0.8.5
Expand Down
8 changes: 4 additions & 4 deletions R/rosa_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#' @param object A \code{rosa} object.
#' @param x A \code{rosa} object.
#' @param newdata Optional new data with the same types of predictor blocks as the ones used for fitting the object.
#' @param ncomp An \code{integer} giving the number of components to use apply (cummulative).
#' @param comps An \code{integer} vector giving the exact components to apply.
#' @param ncomp An \code{integer} giving the number of components to apply (cummulative).
#' @param comps An \code{integer} vector giving the exact components to apply (subset).
#' @param type For \code{predict}: A \code{character} indicating if responses or scores should be predicted (default = "response", or "scores")
#' @param type For \code{blockexpl}: Character indicating which type of explained variance to compute (default = "train", alternative = "CV").
#' @param na.action Function determining what to do with missing values in \code{newdata}.
Expand Down Expand Up @@ -110,7 +110,7 @@ predict.rosa <- function(object, newdata, ncomp = 1:object$ncomp, comps,
} else {
## Predict with a model containing the components `comps'
B <- rowSums(coef(object, comps = comps), dims = 2)
B0 <- object$Ymeans# - object$Xmeans %*% B
B0 <- object$Ymeans - object$Xmeans %*% B
pred <- newX %*% B + rep(c(B0), each = nobs)
if (missing(newdata) && !is.null(object$na.action))
pred <- napredict(object$na.action, pred)
Expand Down Expand Up @@ -140,7 +140,7 @@ coef.rosa <- function(object, ncomp = object$ncomp, comps, intercept = FALSE,
{
if (missing(comps) || is.null(comps)) {
## Cumulative coefficients:
B <- object$coefficients[,,1:ncomp, drop=FALSE]
B <- object$coefficients[,,ncomp, drop=FALSE]
if (intercept == TRUE) { # Intercept has only meaning for
# cumulative coefficients
dB <- dim(B)
Expand Down
24 changes: 22 additions & 2 deletions man/rosa_results.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/multiblock.so
Binary file not shown.

0 comments on commit 8b8a923

Please sign in to comment.