% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/model.R
\name{evaluate_predictor}
\alias{evaluate_predictor}
\title{Evaluate component effects or expressions}
\usage{
evaluate_predictor(
  model,
  state,
  data,
  data_extra,
  effects,
  predictor,
  used = NULL,
  format = "auto",
  n_pred = NULL
)
}
\arguments{
\item{state}{A list where each element is a list of named latent state
information, as produced by \code{\link[=evaluate_state]{evaluate_state()}}}

\item{data}{A \code{list}, \code{data.frame}, or \code{Spatial*DataFrame}, with coordinates
and covariates needed to evaluate the model.}

\item{data_extra}{Additional data for the predictor evaluation. Variables
with the same name as in \code{data} will be ignored, unless accessed via
\code{.data_extra.[["name"]]} or \code{.data_extra.$name}, or via pronouns;
see Details.}

\item{effects}{A list where each element is list of named evaluated effects,
each computed by \code{\link[=evaluate_effect_single_state.bru_comp_list]{evaluate_effect_single_state.bru_comp_list()}}}

\item{predictor}{Either a formula or \link{bru_pred_expr} expression}

\item{used}{A \code{\link[=bru_used]{bru_used()}} object, or NULL (default)}

\item{format}{character; determines the storage format of the output.
Available options:
\itemize{
\item \code{"auto"} If the first evaluated result is a vector or single-column matrix,
the "matrix" format is used, otherwise "list".
\item \code{"matrix"} A matrix where each column contains the evaluated predictor
expression for a state.
\item \code{"list"} A list where each column contains the evaluated predictor
expression for a state.
}

Default: "auto"}

\item{n_pred}{integer. If provided, scalar predictor results are expanded to
vectors of length \code{n_pred}.}
}
\value{
A list or matrix is returned, as specified by \code{format}
}
\description{
Evaluate component effects or expressions, based on a bru model and one or
several states of the latent variables and hyperparameters.
}
\details{
For each component, e.g. "name", the latent state values are
available as \code{name_latent}, and arbitrary evaluation can be done with
\code{name_eval(...)}, see \code{\link[=bru_comp_eval]{bru_comp_eval()}}.

The evaluation supports several \code{\link[rlang:as_data_mask]{rlang::as_data_pronoun()}} data masking
pronouns, to access variables from different data sources, and some of
these also have corresponding full objects, with an appended \code{.} in the
name. The full objects can be passed as arguments to functions.
\describe{
\item{.effect/.effect.}{refers to the \code{effects} vectors}
\item{.latent/.latent.}{refers to the latent state vectors}
\item{.data/.data.}{refers to the main \code{data} argument}
\item{.data_extra/.data_extra.}{refers to the \code{data_extra} argument}
\item{.env}{refers to the evaluation environment of the predictor}
}
}
\keyword{internal}
