aboutsummaryrefslogtreecommitdiff
path: root/R/predict.sparsestep.R
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2016-02-10 20:19:51 -0500
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2016-02-10 20:19:51 -0500
commit6c3d2ff1cb9e7bd3bf1426e1ec4cecd0891ea089 (patch)
tree0cf43714e1252ae833e473dc6beed6ddad953663 /R/predict.sparsestep.R
parentadded authors and dependencies (diff)
downloadsparsestep-6c3d2ff1cb9e7bd3bf1426e1ec4cecd0891ea089.tar.gz
sparsestep-6c3d2ff1cb9e7bd3bf1426e1ec4cecd0891ea089.zip
bugfixes, documentation improvements, and generic function agreement
Diffstat (limited to 'R/predict.sparsestep.R')
-rw-r--r--R/predict.sparsestep.R13
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)
}