Learn R Programming

rstanarm (version 2.10.1)

stanreg-methods: Methods for stanreg objects

Description

S3 methods for stanreg objects. There are also several methods (listed in See Also, below) with their own individual help pages.

Usage

"coef"(object, ...)
"confint"(object, parm, level = 0.95, ...)
"fitted"(object, ...)
"log_lik"(object, newdata = NULL, ...)
"nobs"(object, ...)
"residuals"(object, ...)
"se"(object, ...)
"update"(object, formula., ..., evaluate = TRUE)
"vcov"(object, correlation = FALSE, ...)
"fixef"(object, ...)
"ngrps"(object, ...)
"ranef"(object, ...)
"sigma"(object, ...)
"VarCorr"(x, sigma = 1, ...)

Arguments

object, x
A fitted model object returned by one of the rstanarm modeling functions. See stanreg-objects.
...
Ignored, except by the update method. See update.
parm
For confint, an optional character vector of parameter names.
level
For confint, a scalar between $0$ and $1$ indicating the confidence level to use.
newdata
For log_lik, an optional data frame of new data (e.g. holdout data) to use when evaluating the log-likelihood. See the description of newdata for posterior_predict.
formula., evaluate
See update.
correlation
For vcov, if FALSE (the default) the covariance matrix is returned. If TRUE, the correlation matrix is returned instead.
sigma
Ignored (included for compatibility with VarCorr).

Details

Most of these methods are similar to the methods defined for objects of class 'lm', 'glm', 'glmer', etc. However there are a few exceptions:
confint
For models fit using optimization, confidence intervals are returned via a call to confint.default. If algorithm is "sampling", "meanfield", or "fullrank", the posterior_interval function should be used to compute Bayesian uncertainty intervals.

log_lik
For models fit using MCMC only, the log_lik function returns the $S$ by $N$ pointwise log-likelihood matrix, where $S$ is the size of the posterior sample and $N$ is the number of data points. Note: we use log_lik rather than defining a logLik method because (in addition to the conceptual difference) the documentation for logLik states that the return value will be a single number, whereas we return a matrix.

residuals
Residuals are always of type "response" (not "deviance" residuals or any other type). However, in the case of stan_polr with more than two response categories, the residuals are the difference between the latent utility and its linear predictor.

coef
Medians are used for point estimates. See the Point estimates section in print.stanreg for more details.

se
The se function returns standard errors based on mad. See the Uncertainty estimates section in print.stanreg for more details.

See Also

Other S3 methods for stanreg objects, which have separate documentation, including as.matrix.stanreg, plot.stanreg, predict.stanreg, print.stanreg, and summary.stanreg.

posterior_interval and posterior_predict for alternatives to confint and predict for models fit using MCMC or variational approximation.