predict.betareg | R Documentation |
Extract various types of predictions from beta regression models: First, GLM-style predictions on the scale of responses in (0, 1) or the scale of the linear predictor are provided. Second, various quantities based on the predicted beta distributions are available, e.g., moments, quantiles, probabilities, densities, etc.
## S3 method for class 'betareg'
predict(object, newdata = NULL,
type = c("response", "link", "precision", "variance", "parameters",
"distribution", "density", "probability", "quantile"),
na.action = na.pass, at = 0.5, elementwise = NULL, ...)
object |
fitted model object of class |
newdata |
optionally, a data frame in which to look for variables with which to predict. If omitted, the original observations are used. |
type |
character indicating type of predictions: fitted means of the response
(default, |
na.action |
function determining what should be done with missing values
in |
at |
numeric vector at which the predictions should be evaluated if
|
elementwise |
logical. Should each element of the distribution only be evaluated at the
corresponding element of |
... |
further arguments when |
Each prediction for a betareg
model internally first computes the parameters
for all observations in newdata
(or the original data if newdata
is missing).
These parameters correspond to a predicted beta distribution (or extended-support beta distribution)
for each observation. Then the actual predictions can also be moments of the distributions
or standard quantities such as densities, cumulative probabilities, or quantiles.
The latter are computed with the d
/p
/q
functions such as
dbetar
(or dxbetax
or dxbeta
).
Either a vector or matrix of predictions with the same number of observations as rows
in newdata
.
options(digits = 4)
data("GasolineYield", package = "betareg")
gy2 <- betareg(yield ~ batch + temp | temp, data = GasolineYield)
cbind(
predict(gy2, type = "response"),
predict(gy2, type = "link"),
predict(gy2, type = "precision"),
predict(gy2, type = "variance"),
predict(gy2, type = "quantile", at = c(0.25, 0.5, 0.75))
)
## evaluate cumulative _p_robabilities for (small) new data set
gyd <- GasolineYield[c(1, 5, 10), ]
## CDF at 0.1 for each observation
predict(gy2, newdata = gyd, type = "probability", at = 0.1)
## CDF at each combination of 0.1/0.2 and observations
predict(gy2, newdata = gyd, type = "probability", at = c(0.1, 0.2))
## CDF at elementwise combinations of 0.1/0.2/0.3 and observations
predict(gy2, newdata = gyd, type = "probability", at = c(0.1, 0.2, 0.3))
predict(gy2, newdata = gyd, type = "probability", at = c(0.1, 0.2, 0.3), elementwise = TRUE)
## CDF at all combinations of 0.1/0.2/0.3 and observations
predict(gy2, newdata = gyd, type = "probability", at = c(0.1, 0.2, 0.3), elementwise = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.