predict.qrjoint {qrjoint}R Documentation

Posterior predictive summary for quantile estimation

Description

Extract quantile functions for qrjoint

Usage

 
## S3 method for class 'qrjoint'
predict(object, newdata=NULL, summarize=TRUE, burn.perc = 0.5, nmc = 200, ...)

Arguments

object

a fitted model of the class 'qrjoint'.

newdata

an optional data frame containing variables on which to predict. If omitted, the fitted data are used.

summarize

a logical indicating whether the quantile functions should be summarized across posterior draws into a single estimate (TRUE) or be left as individual samples (FALSE)

burn.perc

a positive fraction indicating what fraction of the saved draws are to be discarded as burn-in

nmc

integer giving the number of samples, post burn-in, to be used in Monte Carlo averaging

...

currently no additional arguments are allowed

Value

Either returns a matrix of posterior quantile-function estimates if summarize=TRUE. Dimensions are n (number of rows in predicted data) x L (length of regularized tau.grid); or a three dimensional array of posterior quantile-function samples if summarize=FALSE. Dimensions are n (number of rows in predicted data) x L (length of regularized tau.grid) x nmc (retained posterior draws).

Note

When supplying newdata, new covariate values should lie within the convex hull of the original fit's covariate space; otherwise, it is possible that extrapolated quantile functions will not obey the quantile monotonicity constraint. For information on expanding the convex hull of the original fit see Detail section of qrjoint.

Additional functionality is planned in future release to provide density function estimates given a set of input covariates.

See Also

qrjoint and summary.qrjoint.

Examples

 
## Plasma data analysis

# recoding variables
data(plasma)
plasma$Sex <- as.factor(plasma$Sex)
plasma$SmokStat <- as.factor(plasma$SmokStat)
plasma$VitUse <- 3 - plasma$VitUse
plasma$VitUse <- as.factor(plasma$VitUse)

# Model fitting with 40 posterior samples from 80 iterations (thin = 2) is for
# illustration only. For practical model fitting, increase iterations, 
# e.g. nsamp = 500, thin = 20
## Not run: 
fit.qrj <- qrjoint(BetaPlasma ~ Age + Sex + SmokStat + Quetelet + VitUse + Calories + 
        Fat + Fiber + Alcohol + Cholesterol + BetaDiet, plasma, nsamp = 40, thin = 2)

quants <- predict(fit.qrj)
matplot(fit.qrj$tau.g[fit.qrj$reg.ix], t(quants), type="l", xlab="p",
ylab="Quantile Function", col="lightgray", lty=1)

## End(Not run)

[Package qrjoint version 2.0-9 Index]