diff options
Diffstat (limited to 'R/predict.sparsestep.R')
| -rw-r--r-- | R/predict.sparsestep.R | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/R/predict.sparsestep.R b/R/predict.sparsestep.R index 8a4be1a..b2ebd77 100644 --- a/R/predict.sparsestep.R +++ b/R/predict.sparsestep.R @@ -5,7 +5,8 @@ #' #' @param object Fitted "sparsestep" object #' @param newx Matrix of new values for `x` at which predictions are to be made. -#' +#' @param ... further argument are ignored +#' #' @return a matrix of numerical predictions of size nobs x nlambda #' #' @export @@ -15,13 +16,13 @@ #' x <- matrix(rnorm(100*20), 100, 20) #' y <- rnorm(100) #' fit <- sparsestep(x, y) -#' yhat <- predict(fit) +#' yhat <- predict(fit, x) #' -predict.sparsestep <- function(obj, newx) +predict.sparsestep <- function(object, newx, ...) { - yhat <- newx %*% as.matrix(obj$beta) - if (obj$intercept) { - yhat <- yhat + rep(1, nrow(yhat)) %*% obj$a0 + yhat <- newx %*% as.matrix(object$beta) + if (object$intercept) { + yhat <- yhat + rep(1, nrow(yhat)) %*% object$a0 } return(yhat) } |
