% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/metahunt.R
\name{predict.metahunt}
\alias{predict.metahunt}
\title{Predict target functions (or scalar summaries) from a MetaHunt fit}
\usage{
\method{predict}{metahunt}(object, newdata, wrapper = NULL, grid_weights = NULL, ...)
}
\arguments{
\item{object}{A \code{"metahunt"} object from \code{\link[=metahunt]{metahunt()}}.}

\item{newdata}{A matrix or data frame of new study-level covariates.}

\item{wrapper}{Optional reduction function. If \code{NULL}, returns the full
predicted function matrix (\code{nrow(newdata)}-by-\code{G_grid}). If a function,
applied to each predicted function to return a scalar per new target;
see \code{\link[=apply_wrapper]{apply_wrapper()}}.}

\item{grid_weights}{Optional length-\code{G_grid} non-negative numeric vector
used only when \code{wrapper = NULL} with the default weighted-mean path.
Defaults to the \code{grid_weights} stored in \code{object}.}

\item{...}{Ignored.}
}
\value{
Either an \code{nrow(newdata)}-by-\code{G_grid} matrix of predicted
functions (when \code{wrapper = NULL}) or a length-\code{nrow(newdata)} numeric
vector of scalar summaries.
}
\description{
Predict target functions (or scalar summaries) from a MetaHunt fit
}
\examples{
set.seed(1)
G <- 25; m <- 40
x <- seq(0, 1, length.out = G)
basis <- rbind(sin(pi * x), cos(pi * x), x)
W <- data.frame(w1 = rnorm(m), w2 = rnorm(m))
eta <- as.matrix(W) \%*\% cbind(c(1, -0.8), c(-0.5, 1.2), c(0, 0))
pi_true <- exp(eta) / rowSums(exp(eta))
F_hat <- pi_true \%*\% basis + matrix(rnorm(m * G, sd = 0.05), m, G)

fit <- metahunt(F_hat, W, K = 3, dfspa_args = list(denoise = FALSE))
f_pred <- predict(fit, newdata = W[1:3, ])
dim(f_pred)                                       # 3 x G
predict(fit, newdata = W[1:3, ], wrapper = mean)  # scalar summaries

}
