Learn R Programming

rethinking (version 1.35)

sample.qa.posterior: Samples from quadratic posterior densities of models

Description

Samples from the posterior density of a fit model or models, assuming multivariate normal density.

Usage

sample.qa.posterior( model , n = 10000 )
sample.qa.posterior( models , n = 10000 , model.weights = "AICc" , nobs = 0 , add.names = FALSE , fill.na = 0 , verbose = FALSE )

Arguments

model

A fit model object

models

A list of fit models of the same class

n

Number of samples to draw from joint posterior

model.weights

If passing a list of models, method for computing posterior probability of each model family. Can be "AIC","AICc","BIC" or a vector of numeric weights.

nobs

Number of observations used to fit model or all models in list. Sometimes needed for model.weights values, like AICc.

add.names

Adds a column of model names, when passing a list of models

fill.na

Fills missing values with 0, by default, for model families that do not contain a given parameter. Useful for linear models. Hazardous for non-linear ones.

verbose

If TRUE, prints various debugging information

Value

Details

This function provides a way to draw parameter values from a multivariate normal posterior density, estimated from the maximum a posterieri (MAP) estimates and variance-covariance (vcov) of a fit model or models.

When passing a single fit model object, the function returns a data frame in which each row is a sample and each column is a parameter.

When passing a list of fit model objects, the function returns a data frame containing samples from the joint posterior across model families. The fraction of rows drawn from a specific model family is determined by the model.weights parameter. BIC, AIC, or AICc are used to compute approximate predictive probabilities of each model family, and the total samples n is proportioned according to these estimates. The user can also supply a numeric vector of model weights, computed by any method. This vector should sum to 1.

References

McElreath 2011, Statistical Rethinking.

See Also

mvrnorm