predict.refmodel {projpred} | R Documentation |
Predictions or log posterior predictive densities from a reference model
Description
This is the predict()
method for refmodel
objects (returned by
get_refmodel()
or init_refmodel()
). It offers three types of output which
are all based on the reference model and new (or old) observations: Either
the linear predictor on link scale, the linear predictor transformed to
response scale, or the log posterior predictive density.
Usage
## S3 method for class 'refmodel'
predict(
object,
newdata = NULL,
ynew = NULL,
offsetnew = NULL,
weightsnew = NULL,
type = "response",
...
)
Arguments
object |
An object of class |
newdata |
Passed to argument |
ynew |
If not |
offsetnew |
Passed to argument |
weightsnew |
Passed to argument |
type |
Usually only relevant if |
... |
Currently ignored. |
Details
Argument weightsnew
is only relevant if !is.null(ynew)
.
In case of a multilevel reference model, group-level effects for new group
levels are drawn randomly from a (multivariate) Gaussian distribution. When
setting projpred.mlvl_pred_new
to TRUE
, all group levels from newdata
(even those that already exist in the original dataset) are treated as new
group levels (if is.null(newdata)
, all group levels from the original
dataset are considered as new group levels in that case).
Value
In the following, ,
, and
from help topic refmodel-init-get are used.
Furthermore, let
denote either
(if
type = "response"
) or (if
type = "link"
).
Then, if is.null(ynew)
, the returned object contains the reference
model's predictions (with the scale depending on argument type
) as:
a length-
vector in case of (i) the traditional projection, (ii) the latent projection with
type = "link"
, or (iii) the latent projection withtype = "response"
andobject$family$cats
beingNULL
;an
matrix in case of (i) the augmented-data projection or (ii) the latent projection with
type = "response"
andobject$family$cats
being notNULL
.
If !is.null(ynew)
, the returned object is a length- vector of log
posterior predictive densities evaluated at
ynew
.