| predict.qrjoint | R Documentation |
Extract quantile functions for qrjoint
## S3 method for class 'qrjoint'
predict(object, newdata=NULL, summarize=TRUE, burn.perc = 0.5, nmc = 200, ...)
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 |
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).
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.
qrjoint and summary.qrjoint.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.