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, N
, C_{\mathrm{cat}}
, and
C_{\mathrm{lat}}
from help topic refmodel-init-get are used.
Furthermore, let C
denote either C_{\mathrm{cat}}
(if
type = "response"
) or C_{\mathrm{lat}}
(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-
N
vector in case of (i) the traditional projection, (ii) the latent projection withtype = "link"
, or (iii) the latent projection withtype = "response"
andobject$family$cats
beingNULL
;an
N \times C
matrix in case of (i) the augmented-data projection or (ii) the latent projection withtype = "response"
andobject$family$cats
being notNULL
.
If !is.null(ynew)
, the returned object is a length-N
vector of log
posterior predictive densities evaluated at ynew
.