predict.flexreg function

Predict Method for flexreg Objects

Predict Method for flexreg Objects

Method that computes various types of predictions from objects of class flexreg.

## S3 method for class 'flexreg' predict( object, newdata = NULL, n.new = NULL, cluster = FALSE, type = "response", estimate = "mean", q = NULL, ... )

Arguments

  • object: an object of class flexreg, usually the result of flexreg or flexreg_binom functions.
  • newdata: an optional data.frame containing variables with which to predict. If omitted, the fitted values are used.
  • n.new: 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).
  • cluster: 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).
  • type: 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.
  • estimate: a character indicating the type of estimate. Available options are "mean" (default), "median", and "quantile".
  • q: if estimate = "quantile", a numeric value of probability in (0, 1).
  • ...: additional arguments. Currently not used.

Returns

The function returns a data.frame of different dimensions depending on the type of prediction.

Details

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 q1+(1q0q1)μq_1+(1-q_0-q_1)\mu and the probabilities of augmentation q0q_0 and/or q1q_1. If type = "variance", the function returns Var(Y0<Y<1)Var(Y|0<Y<1) in case of no augmentation and (1q0q1)Var(Y0<Y<1)+q12+(1q0q1)μ2(q1+(1q0q1)μ)2(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 (λ1\lambda_1 and λ2\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.

Examples

## Not run: data("Reading") FB <- flexreg(accuracy.adj ~ iq, data=Reading, type="FB") predict(FB, type="response", cluster=TRUE) ## End(Not run)

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

  • Maintainer: Roberto Ascari
  • License: GPL (>= 2)
  • Last published: 2023-09-29

Useful links