`flexreg`
ObjectsMethod that computes various types of predictions from objects of class `flexreg`
.
# S3 method for flexreg
predict(
object,
newdata = NULL,
n.new = NULL,
cluster = FALSE,
type = "response",
estimate = "mean",
q = NULL,
...
)
The function returns a data.frame
of different dimensions depending on the type of prediction.
an object of class `flexreg`
, usually the result of flexreg
or flexreg_binom
functions.
an optional data.frame
containing variables with which to predict. If omitted, the fitted values are used.
an optional vector containing the total number of trials with which to predict. It must be specified if newdata
is not NULL
and the
flexreg
object is the result of the flexreg_binom
function (i.e., the fitted model is binomial, beta-binomial, or flexible beta-binomial). The vector must have the same length as nrow(newdata)
.
a logical (with default FALSE
). The option cluster = TRUE
is available only for "FB"
and "FBB"
models and allows to compute some component-specific predictions (see Details).
a character indicating the type of prediction. Available options are: "response"
, returning the marginal fitted mean of the response/relative response;
"link"
, returning the linear predictor of the mean model;
"precision"
, returning the fitted precision parameter;
"overdispersion"
, returning the fitted overdispersion parameter;
"variance"
, returning the fitted variance of the response.
a character indicating the type of estimate. Available options are "mean"
(default), "median"
, and "quantile"
.
if estimate = "quantile"
, a numeric value of probability in (0, 1).
additional arguments. Currently not used.
The predict
method computes various types of predictions from objects of class `flexreg`
.
If type = "response"
, the function returns the marginal mean, i.e., \(\mu\).
In case of models for continuous bounded responses with augmentation, the function returns also the overall mean
\(q_1+(1-q_0-q_1)\mu\) and the probabilities of augmentation \(q_0\) and/or \(q_1\).
If type = "variance"
, the function returns \(Var(Y|0<Y<1)\) in case of no augmentation and
\((1-q_0-q_1)Var(Y|0<Y<1)+q_1^2+(1-q_0-q_1)\mu^2-(q_1+(1-q_0-q_1)\mu)^2\) in case of augmentation.
If cluster = TRUE
, for FB and FBB models, the function returns the cluster means (\(\lambda_1\) and \(\lambda_2\)) when type = "response"
and the cluster variances when type = "variance"
.
The option type = "overdispersion"
is available only for beta-binomial and flexible beta-binomial models and returns the fitted overdispersion.
Ascari, R., Migliorati, S. (2021). A new regression model for overdispersed binomial data accounting for outliers and an excess of zeros. Statistics in Medicine, 40(17), 3895--3914. doi:10.1002/sim.9005
Di Brisco, A. M., Migliorati, S. (2020). A new mixed-effects mixture model for constrained longitudinal data. Statistics in Medicine, 39(2), 129--145. doi:10.1002/sim.8406
Migliorati, S., Di Brisco, A. M., Ongaro, A. (2018). A New Regression Model for Bounded Responses. Bayesian Analysis, 13(3), 845--872. doi:10.1214/17-BA1079
if (FALSE) {
data("Reading")
FB <- flexreg(accuracy.adj ~ iq, data=Reading, type="FB")
predict(FB, type="response", cluster=TRUE)
}
Run the code above in your browser using DataLab