predictive_error: In-sample or out-of-sample predictive errors

Description Usage Arguments Value Elements for stapreg objects Note See Also

Description

This is a convenience function for computing y - yrep (in-sample, for observed y) or y - ytilde (out-of-sample, for new or held-out y). The method for stapreg objects calls posterior_predict internally, whereas the method for objects with class "ppd" accepts the matrix returned by posterior_predict as input and can be used to avoid multiple calls to posterior_predict.

The rstap model-fitting functions return an object of class 'stapreg', which is a list containing at a minimum the components listed below. Each stapreg object will also have additional classes (e.g. 'glm') and several additional components depending on the model and estimation algorithm.

Usage

1
2
3
4
## S3 method for class 'stapreg'
predictive_error(object, newsubjdata = NULL,
  newdistdata = NULL, newtimedata = NULL, draws = NULL,
  re.form = NULL, seed = NULL, offset = NULL, ...)

Arguments

object

Either a fitted model object returned by one of the rstap modeling functions (a stapreg object) or, for the "ppd" method, a matrix of draws from the posterior predictive distribution returned by posterior_predict.

newsubjdata, newdistdata, newtimedata, draws, seed, offset, re.form

Optional arguments passed to posterior_predict. For binomial models, please see the Note section below if newsubjdata will be specified.

...

Currently ignored.

Value

A draws by nrow(newsubjdata) matrix. If newsubjdata is not specified then it will be draws by nobs(object).

Elements for stapreg objects

coefficients

Point estimates, as described in print.stapreg.

ses

Standard errors based on mad, as described in print.stapreg.

residuals

Residuals of type 'response'.

fitted.values

Fitted mean values. For GLMs the linear predictors are transformed by the inverse link function.

linear.predictors

Linear fit on the link scale. For linear models this is the same as fitted.values.

covmat

Variance-covariance matrix for the coefficients based on draws from the posterior distribution, the variational approximation, or the asymptotic sampling distribution, depending on the estimation algorithm.

model,x,y,z

If requested, the the model frame, model matrix and response variable used, respectively. Note that z corresponds to the fixed covariates, z to the spatial aggregated covariates, and y the response.

family

The family object used.

call

The matched call.

formula

The model formula.

data,offset,weights

The data, offset, and weights arguments.

prior.info

A list with information about the prior distributions used.

stapfit,stan_summary

The object of stanfit-class returned by RStan and a matrix of various summary statistics from the stapfit object.

rstan_version

The version of the rstan package that was used to fit the model.

Note

The Note section in posterior_predict about nnewsubjdata for binomial models also applies for predictive_error, with one important difference. For posterior_predict if the left-hand side of the model formula is cbind(successes, failures) then the particular values of successes and failures in newsubjdata don't matter, only that they add to the desired number of trials. This is not the case for predictive_error. For predictive_error the particular value of successes matters because it is used as y when computing the error.

See Also

posterior_predict to draw from the posterior predictive distribution without computing predictive errors.


Biostatistics4SocialImpact/rstap documentation built on Aug. 13, 2019, 7:43 p.m.