vis.pfr | R Documentation |
Produces perspective or contour plot views of an estimated surface corresponding smooths over two or more dimensions. Alternatively plots “slices” of the estimated surface or estimated second derivative surface with one of its arguments fixed. Corresponding twice-standard error “Bayesian” confidence bands are constructed using the method in Marra and Wood (2012). See the details.
vis.pfr(
object,
select = 1,
xval = NULL,
tval = NULL,
deriv2 = FALSE,
theta = 50,
plot.type = "persp",
ticktype = "detailed",
...
)
object |
an |
select |
index for the smooth term to be plotted, according to its position
in the model formula (and in |
xval |
a number in the range of functional predictor to be plotted. The surface will be plotted with the first argument of the estimated surface fixed at this value |
tval |
a number in the domain of the functional predictor to be plotted. The surface will be
plotted with the second argument of the estimated surface fixed at this value. Ignored if |
deriv2 |
logical; if |
theta |
numeric; viewing angle; see |
plot.type |
one of |
ticktype |
how to draw the tick marks if |
... |
other options to be passed to |
The confidence bands used when plotting slices of the estimated surface or second derivative surface are the ones proposed in Marra and Wood (2012). These are a generalization of the "Bayesian" intervals of Wahba (1983) with an adjustment for the uncertainty about the model intercept. The estimated covariance matrix of the model parameters is obtained from assuming a particular Bayesian model on the parameters.
Simply produces a plot
Mathew W. McLean mathew.w.mclean@gmail.com
McLean, M. W., Hooker, G., Staicu, A.-M., Scheipl, F., and Ruppert, D. (2014). Functional generalized additive models. Journal of Computational and Graphical Statistics, 23(1), pp. 249-269.
Marra, G., and Wood, S. N. (2012) Coverage properties of confidence intervals for generalized additive model components. Scandinavian Journal of Statistics, 39(1), pp. 53–74.
Wabha, G. (1983) "Confidence intervals" for the cross-validated smoothing spline. Journal of the Royal Statistical Society, Series B, 45(1), pp. 133–150.
{vis.gam}
, {plot.gam}
, {pfr}
, {persp}
,
{levelplot}
################# DTI Example #####################
data(DTI)
## only consider first visit and cases (since no PASAT scores for controls),
## and remove missing data
DTI <- DTI[DTI$visit==1 & DTI$case==1 & complete.cases(DTI$cca),]
## Fit the PFR using FA measurements along corpus
## callosum as functional predictor with PASAT as response
## using 8 cubic B-splines for each marginal bases with
## third order marginal difference penalties.
## Specifying gamma>1 enforces more smoothing when using GCV
## to choose smoothing parameters
fit <- pfr(pasat ~ af(cca, basistype="te", k=c(8,8), m=list(c(2,3),c(2,3)), bs="ps"),
method="GCV.Cp", gamma=1.2, data=DTI)
## contour plot of the fitted surface
vis.pfr(fit, plot.type='contour')
## similar to Figure 5 from McLean et al.
## Bands seem too conservative in some cases
xval <- runif(1, min(fit$pfr$ft[[1]]$Xrange), max(fit$pfr$ft[[1]]$Xrange))
tval <- runif(1, min(fit$pfr$ft[[1]]$xind), max(fit$pfr$ft[[1]]$xind))
par(mfrow=c(2, 2))
vis.pfr(fit, deriv2=FALSE, xval=xval)
vis.pfr(fit, deriv2=FALSE, tval=tval)
vis.pfr(fit, deriv2=TRUE, xval=xval)
vis.pfr(fit, deriv2=TRUE, tval=tval)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.