Learn R Programming

FlexReg (version 1.2)

predict.flexreg: Prediction Method for flexreg Objects

Description

Method that computes various types of prediction from objects of class `flexreg`. If the model type is "FB" without augmentation or "FBB" and cluster = T, the function returns also cluster means.

Usage

# S3 method for flexreg
predict(
  object,
  newdata = NULL,
  cluster = F,
  type = "response",
  estimate = "mean",
  q = NULL,
  ...
)

Arguments

object

an object of class `flexreg`, usually the result of flexreg or flexreg_binom.

newdata

an optional data frame containing variables with which to predict. If omitted, the fitted values are used.

cluster

logical. If the model is "FB" without augmentation or "FBB", cluster = T returns the cluster means. By default, cluster = F.

type

a character indicating the type of predictions. Available options are: "response", that returns the marginal fitted means of response/relative response; "link", the linear predictor of the mean model; "precision", the fitted precision parameter \(phi\); "overdispersion", the fitted overdispersion parameter \(theta\); "variance", the fitted variance of the response.

estimate

the type of estimate: "mean" (default), "median" or "quantile".

q

if estimate = "quantile", numeric value of probability in (0, 1).

...

additional arguments. Currently not used.

Details

If type="response" the function returns the marginal mean that is \(\mu\) in case of no augmentation and \(q_1+(1-q_0-q_1)\mu\) in case of augmentation. 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. See Di Brisco and Migliorati (2020) for details. The option type = "overdispersion" is available only for beta-binomial and flexible beta-binomial models.

References

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

Examples

Run this code
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