From 6c3d2ff1cb9e7bd3bf1426e1ec4cecd0891ea089 Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Wed, 10 Feb 2016 20:19:51 -0500 Subject: bugfixes, documentation improvements, and generic function agreement --- R/predict.sparsestep.R | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'R/predict.sparsestep.R') 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) } -- cgit v1.2.3