plotCurveEstimate: Generic function for plotting a fractional polynomial curve...

plotCurveEstimateR Documentation

Generic function for plotting a fractional polynomial curve estimate

Description

Plot a fractional polynomial curve estimate for either a single model or a Bayesian model average over BayesMfp objects. Optionally, credible intervals and / or bands can be added to the plot.

Usage

plotCurveEstimate(model, termName, plevel = 0.95, slevel = plevel,
plot = TRUE, legendPos = "topleft", rug = FALSE, partialResids=TRUE, 
hpd=TRUE,..., main = NULL) 

Arguments

model

an object of class BayesMfp or BmaSamples

termName

string denoting an FP term, as written by the summary method

plevel

credible level for pointwise intervals, and NULL means no pointwise intervals (default: 0.95)

slevel

credible level for simultaneous credible band (SCB), NULL means no SCB (defaults to plevel)

plot

if FALSE, only return values needed to produce the plot, but do not plot (default is TRUE, so a plot is made)

legendPos

position of coefficient estimates (for BayesMfp) or sample size (for BmaSamples) in the plot, NULL suppresses the printing (default is “topleft”)

rug

add a rug to the plot? (default: FALSE)

partialResids

add partial residuals to the plot? (default: TRUE)

hpd

use HPD intervals (TRUE, default) or quantile-based (FALSE) intervals?

...

further arguments in case of a BayesMfp object (see details) and arguments for plotting with matplot

main

optional main argument for the plot

Details

Further arguments for application on a BayesMfp object:

grid

vector of unscaled abscissae, default is a length gridSize grid over the observed range specified by providing the argument NULL.

post

list with posterior parameters of the model, which may be provided manually to accelerate plotting in a loop

gridSize

default number of grid points used when no grid is supplied (default is 201)

numSim

number of simulations for estimation of the SCB (default is 500)

Value

a list of various plotting information:

original

grid on the original covariate scale

grid

grid on the transformed scale

mode

mode curve values, only for BayesMfp object

mean

pointwise mean curve values, only for BmaSamples object

median

pointwise median curve values, only for BmaSamples object

plower

lower boundaries for pointwise intervals

pupper

upper boundaries for pointwise intervals

slower

lower boundaries for SCB

supper

upper boundaries for SCB

obsVals

observed values of the covariate on the original scale

sampleSize

sample size underlying the curve estimate, only for BmaSamples object

partialResids

partial residuals

transform

vector of shift and scale parameter

See Also

BayesMfp, BmaSamples

Examples

## construct a BayesMfp object
set.seed(19)
x1 <- rnorm (n=15)
x2 <- rbinom (n=15, size=20, prob=0.5) 
x3 <- rexp (n=15)
y <- rt (n=15, df=2)

test <- BayesMfp (y ~ bfp (x2, max = 4) + uc (x1 + x3), nModels = 100,
method="exhaustive")

## plot the x2 curve estimate for the 20-th best model
p1 <- plotCurveEstimate (test[20], "x2")

## look at the returned list
str(p1)

## plot the BMA curve estimate for the same covariate
testBma <- BmaSamples (test)
p2 <- plotCurveEstimate (testBma, "x2")

## look at the returned list
str(p2)

## try the new options:
plotCurveEstimate (testBma, "x2", partialResids=FALSE, hpd=FALSE)

bfp documentation built on March 19, 2024, 3:07 a.m.

Related to plotCurveEstimate in bfp...