plot.gamselBayes {gamselBayes}R Documentation

Plot components of the selected generalized additive model from a gamselBayes() fit

Description

The estimated non-linear components of the generalized additive model selected via gamselBayes are plotted.

Usage

## S3 method for class 'gamselBayes'
plot(x,credLev = 0.95,gridSize = 251,nMC = 5000,varBand = TRUE,
     shade = TRUE,yscale = "response",rug = TRUE,rugSampSize = NULL,estCol = "darkgreen",
     varBandCol = NULL,rugCol = "dodgerblue",mfrow = NULL,xlim = NULL,ylim = NULL,
     xlab = NULL,ylab = NULL,mai = NULL,pages = NULL,cex.axis = 1.5,cex.lab = 1.5,...)

Arguments

x

A gamselBayes() fit object.

credLev

A number between 0 and 1 such that the credible interval band has (100*credLev)% approximate pointwise coverage. The default value is 0.95.

gridSize

A number of grid points used to display the density estimate curve and the pointwise credible interval band. The default value is 251.

nMC

The size of the Monte Carlo sample, a positive integer, for carrying out approximate inference from the mean field variational Bayes-approximate posterior distributions when the method is mean field variational Bayes. The default value is 5000.

varBand

Boolean flag specifying whether or not a variability band is included:
TRUE = add a pointwise approximate (100*credLev)% credible set variability band (the default)
FALSE = only plot the density estimate, without a variability band.

shade

Boolean flag specifying whether or not the variability band is displayed using shading:
TRUE = display the variability band using shading (the default)
FALSE = display the variability band using dashed curves.

yscale

Character string specifying the vertical axis scale for display of estimated non-linear functions:
"response" = display on the response scale)
"link" = display on the link scale.

rug

Boolean flag specifying whether or not rug-type displays for predictor data are used:
TRUE = show the predictor data using rug-type displays (the default)
FALSE = do not show the predictor data.

rugSampSize

The size of the random sample sample of each predictor to be used in rug-type displays.

estCol

Colour of the density estimate curve. The default value is "darkgreen".

varBandCol

Colour of the pointwise credible interval variability band. If shade=TRUE then the default value is "palegreen". If shade=FALSE then the default value is estCol.

rugCol

Colour of rug plot that shows values of the predictor data. The default value is "dodgerblue".

mfrow

An optional two-entry vector for specifying the layout of the nonlinear fit displays.

xlim

An optional two-column matrix for specification of horizontal frame limits in the plotting of the estimated non-linear predictor effects. The number of rows in xlim must equal length(effectTypesVector(x)=="nonlin"). If any of the rorows of xlim contain NA then the default horizontal frame limits value for that predictor is used. Therefore, if there are several predictors selected as non-linear and horizontal frame adjustments are required for a few of them then then xlim can be a matrix with mainly NA values, and with non-NA frame specification limits in the relevant rows.

ylim

The same as xlim, except for vertical frame limits.

xlab

An optional vector of character strings containing labels for the horizontal axes. The number of entries in xlab must equal length(effectTypesVector(x)=="nonlin").

ylab

The same as xlab, except for vertical axis labels.

mai

An optional numerical vector of length 4 for specification of inner margin dimensions of each panel, ordered clockwise from below the panel.

pages

An optional positive integer that specifies the number of pages used to display the non-linear function estimates.

cex.axis

An optional positive scalar value for specification of the character expansion factor for the axis values.

cex.lab

An optional positive scalar value for specification of the character expansion factor for the labels.

...

Place-holder for other graphical parameters.

Details

The estimated non-linear components of the selected generalized additive model are plotted. Each plot corresponds to a slice of the selected generalized additive model surface with all other predictors set to their median values. Pointwise credible intervals unless varBand is FALSE.

Value

Nothing is returned.

Author(s)

Virginia X. He virginia.x.he@student.uts.edu.au and Matt P. Wand matt.wand@uts.edu.au

Examples

library(gamselBayes) 

# Generate some simple regression-type data:

set.seed(1) ; n <- 1000 ; x1 <- rbinom(n,1,0.5) ; 
x2 <- runif(n) ; x3 <- runif(n) ; x4 <- runif(n)
y <- x1 + sin(2*pi*x2) - x3 + rnorm(n)
Xlinear <- data.frame(x1) ; Xgeneral <- data.frame(x2,x3,x4)

# Obtain a gamselBayes() fit for the data and print out a summary:

fit <- gamselBayes(y,Xlinear,Xgeneral)
summary(fit)

# Plot the predictor effect(s) estimated as being non-linear:

plot(fit)

# Plot the same fit(s) but with different colours and style:

plot(fit,shade = FALSE,estCol = "darkmagenta",varBandCol = "plum",
     rugCol = "goldenrod")

if (require("Ecdat"))
{
   # Obtain a gamselBayes() fit for data on schools in California, U.S.A.:

   Caschool$log.avginc <- log(Caschool$avginc)
   mathScore <- Caschool$mathscr
   Xgeneral <- Caschool[,c("mealpct","elpct","calwpct","compstu","log.avginc")]
   fit <- gamselBayes(y = mathScore,Xgeneral = Xgeneral)
   summary(fit)

   # Plot the predictor effect(s) estimated as being non-linear:

   plot(fit)
}

[Package gamselBayes version 2.0-1 Index]