vis.fgam | R Documentation |
Produces perspective or contour plot views of an estimated surface corresponding to {af}
terms fit using {fgam}
or plots “slices” of the estimated surface or estimated
second derivative surface with one of its arguments fixed and corresponding twice-standard error
“Bayesian” confidence bands constructed using the method in Marra and Wood (2012). See the details.
vis.fgam(
object,
af.term,
xval = NULL,
tval = NULL,
deriv2 = FALSE,
theta = 50,
plot.type = "persp",
ticktype = "detailed",
...
)
object |
an |
af.term |
character; the name of the functional predictor to be plotted. Only important
if multiple |
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}
, {fgam}
, {persp}
,
{levelplot}
################# DTI Example #####################
data(DTI)
## only consider first visit and cases (since no PASAT scores for controls)
y <- DTI$pasat[DTI$visit==1 & DTI$case==1]
X <- DTI$cca[DTI$visit==1 & DTI$case==1,]
## remove samples containing missing data
ind <- rowSums(is.na(X))>0
y <- y[!ind]
X <- X[!ind,]
## fit the fgam 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 <- fgam(y~af(X,splinepars=list(k=c(8,8),m=list(c(2,3),c(2,3)))),gamma=1.2)
## contour plot of the fitted surface
#vis.fgam(fit,plot.type='contour')
## similar to Figure 5 from McLean et al.
## Bands seem too conservative in some cases
#xval <- runif(1, min(fit$fgam$ft[[1]]$Xrange), max(fit$fgam$ft[[1]]$Xrange))
#tval <- runif(1, min(fit$fgam$ft[[1]]$xind), max(fit$fgam$ft[[1]]$xind))
#par(mfrow=c(4, 1))
#vis.fgam(fit, af.term='X', deriv2=FALSE, xval=xval)
#vis.fgam(fit, af.term='X', deriv2=FALSE, tval=tval)
#vis.fgam(fit, af.term='X', deriv2=TRUE, xval=xval)
#vis.fgam(fit, af.term='X', deriv2=TRUE, tval=tval)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.