Learn R Programming

CARrampsOcl (version 0.1.4)

plotCAR1plus1Q: Plot 3-dimensional data modeled with a 2-dimensional CAR1 plus a 1-dimensional structure matrix

Description

Plot 3-dimensional data modeled with a 2-dimensional CAR1 plus a 1-dimensional structure matrix

Usage

plotCAR1plus1Q(objname, numcols = 64, col = rev(terrain.colors(numcols)), 
    plotdim = 1, cardims, rev.inds = c(FALSE, FALSE), blocks = NULL, 
    animate = FALSE, intv = 3, 
    title = c("Raw data", "Estimated underlying truth"), sub = NULL)

Arguments

objname
name of output object produced by CARrampsOcl.fit
numcols
number of shades from the color palette to be used
col
color palette to be used in plotting; the default plots high values in green and low values in pink.
plotdim
This function produces a sequence of two-dimensional plots. The plotdim argument is a scalar identifying which dimension appears in the rows and columns of each two-dimensional plot. The number refers to the order of the structure matrices
cardims
Two-vector specifying the number of rows and columns in the CAR1 structure matrix; same as dimension of CAR1 Q matrix provided to CARrampsOcl.fit.
rev.inds
Should the plotting indices on each two-dimensional plot be reversed? Setting rev.inds = c(TRUE,FALSE) flips the plots from left to right; rev.inds = c(FALSE,TRUE) turns the plots upside down.
blocks
Subset which two-dimensional plots are displayed. Default is that the corresponding two-dimensional plot is displayed for each value of the third dimension. To subset, set blocks to a set of integers. For example, blocks = 1:5
animate
If animate = FALSE, the user is prompted to press a key to move to the next plot. Otherwise, the next plot will automatically appear after intv seconds.
intv
How many seconds to wait before displaying next plot (ignored if animate=FALSE).
title
Vector of character values; the titles of the two plots.
sub
Vector of subtitles for plots.

Value

  • For each value in blocks, this function plots two two-dimensional plots side-by-side. The left plot is of the raw data input into the CARrampsOcl.fit function, and the right plot is of the estimated means of the of the posterior distributions of the corresponding random effects.

Details

For each value in blocks, this function plots two two-dimensional plots side-by-side. The left plot is of the raw data input into the CARrampsOcl.fit function, and the right plot is of the estimated means of the of the posterior distributions of the corresponding random effects.

Examples

Run this code
data(iowaSW97_06small)

na<- 17
nb <- 12
nc <- 10
Q <- list( list(type="CAR1",content=c(na,nb)), list(type="RW1",content=nc))
alpha <- beta <- rep(0.01,3)
X<- matrix( rep(1, na * nb * nc), ncol=1)

y <- iowaSW97_06small/100 + rnorm(na*nb*nc,sd=6)   # add noise
print(system.time(outputSW2 <- CARrampsOcl.fit(alpha, beta, Q, y, nsamp=50,
     seed=2, fixed = FALSE, coefs = TRUE,
     randeffs = TRUE, designMat = X, mult = 2000, filename = "params.txt")))

plotCAR1plus1Q( objname=outputSW2, numcols=64, col=rev(terrain.colors(64)),
   plotdim=1, cardims=c(na,nb),
   rev.inds=c(FALSE,TRUE), blocks=NULL, animate=FALSE, intv=3, 
   title=c("Raw data","Estimated underlying truth"), sub=1997:2006 )

Run the code above in your browser using DataLab