Learn R Programming

CARrampsOcl (version 0.1.4)

plot3Q: Plot 3-dimensional data modeled with 3 separate structure matrices

Description

Plot 3-dimensional data modeled with 3 separate structure matrices.

Usage

plot3Q(objname, numcols = 64, col = rev(terrain.colors(numcols)), 
plotdims = c(1, 2), 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.
plotdims
This function produces a sequence of two-dimensional plots. The plotdims argument is a 2-vector identifying which two dimensions appear in the rows and columns of each two-dimensional plot. The numbers refer to the order of the structure mat
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 of a third dimension, 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="RW1",content=na), list(type="RW1",content=nb), 
list(type="RW1",content=10))
alpha <- beta <- rep(0.01,4)
X<- matrix( rep(1, na * nb * nc), ncol=1)

# Add noise to data to see whether fitting method can extract true image
y <- iowaSW97_06small/100 + rnorm(na*nb*nc,sd=6)

outputSW <- CARrampsOcl.fit(alpha, beta, Q, y, nsamp=50,                  
     seed=2, fixed = FALSE, coefs = TRUE,
     randeffs = TRUE, designMat = X, mult = 2000, filename = "params.txt")
require(coda)
summary( as.mcmc(1/sqrt(outputSW$params)))

plot3Q( objname=outputSW, numcols=64, col=rev(terrain.colors(64)),
plotdims=c(1,2), rev.inds=c(FALSE,TRUE), blocks=NULL, animate=TRUE,
intv=3, title=c("Raw data","Estimated underlying truth"), sub=1997:2006 )

Run the code above in your browser using DataLab