Description Usage Arguments Details Note Author(s) See Also Examples
Generic functions for plotting objects of class "bayesx"
and model term classes
"geo.bayesx"
, "linear.bayesx"
, "mrf.bayesx"
, "random.bayesx"
and
"sm.bayesx"
.
1 2 |
x |
a fitted |
model |
for which model the plot should be provided, either an integer or a character, e.g.
|
term |
the term that should be plotted, either an integer or a character, e.g.
|
which |
choose the type of plot that should be drawn, possible options are: |
ask |
... |
... |
other graphical parameters passed to |
Depending on the class of the term that should be plotted, function plot.bayesx
calls one
of the following plotting functions in the end:
plotblock
,
plotsamples
,
plotmap
,
plot2d
,
plot3d
,
acf
,
density
,
For details on argument specifications, please see the help sites for the corresponding function.
If argument x
contains of more than one model and e.g. term = 2
, the second terms
of all models will be plotted
If a model is specified with a structured and an unstructured spatial effect, e.g. the model
formula is something like y ~ sx(id, bs = "mrf", map = MapBnd) + sx(id, bs = "re")
, the
model output contains of one additional total spatial effect, named with "sx(id):total"
.
Also see the last example.
Nikolaus Umlauf, Thomas Kneib, Stefan Lang, Achim Zeileis.
plotblock
, plotsamples
, plotmap
, plot2d
,
plot3d
, bayesx
, read.bayesx.output
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | ## Not run:
## generate some data
set.seed(111)
n <- 500
## regressors
dat <- data.frame(x = runif(n, -3, 3), z = runif(n, -3, 3),
w = runif(n, 0, 6), fac = factor(rep(1:10, n/10)))
## response
dat$y <- with(dat, 1.5 + sin(x) + cos(z) * sin(w) +
c(2.67, 5, 6, 3, 4, 2, 6, 7, 9, 7.5)[fac] + rnorm(n, sd = 0.6))
## estimate model
b1 <- bayesx(y ~ sx(x) + sx(z, w, bs = "te") + fac,
data = dat, method = "MCMC")
## plot p-spline term
plot(b1, term = 1)
## same with
plot(b1, term = "sx(x)")
## with residuals
plot(b1, term = "sx(x)", residuals = TRUE)
## plot tensor term
plot(b1, term = "sx(z,w)")
## use other palette
plot(b1, term = "sx(z,w)", col.surface = heat.colors)
## swap colors
plot(b1, term = "sx(z,w)", col.surface = heat.colors, swap = TRUE)
## plot tensor term with residuals
plot(b1, term = "sx(z,w)", residuals = TRUE)
## plot image and contour
plot(b1, term = "sx(z,w)", image = TRUE)
plot(b1, term = "sx(z,w)", image = TRUE, contour = TRUE)
## increase the grid
plot(b1, term = "sx(z,w)", image = TRUE, contour = TRUE, grid = 100)
## plot factor term
plot(b1, term = "fac")
## plot factor term with residuals
plot(b1, term = "fac", resid = TRUE, cex = 0.5)
## plot residual dignostics
plot(b1, which = 5:8)
## plot variance sampling path of term sx(x)
plot(b1, term = 1, which = "var-samples")
## plot coefficients sampling paths of term sx(x)
plot(b1, term = 1, which = "coef-samples")
## plot the sampling path of the intercept
par(mfrow = c(1, 1))
plot(b1, which = "intcpt-samples")
## plot the autcorrelation function
## of the sampled intercept
plot(b1, which = "intcpt-samples",
acf = TRUE, lag.max = 50)
## increase lags
plot(b1, which = "intcpt-samples",
acf = TRUE, lag.max = 200)
## plot maximum autocorrelation
## of all sampled parameters in b1
plot(b1, which = "max-acf")
## plot maximum autocorrelation of
## all sampled coefficients of term sx(x)
plot(b1, term = "sx(x)", which = "coef-samples",
max.acf = TRUE, lag.max = 100)
## now a spatial example
set.seed(333)
## simulate some geographical data
data("MunichBnd")
N <- length(MunichBnd); names(MunichBnd) <- 1:N
n <- N*5
## regressors
dat <- data.frame(id = rep(1:N, n/N), x1 = runif(n, -3, 3))
dat$sp <- with(dat, sort(runif(N, -2, 2), decreasing = TRUE)[id])
dat$re <- with(dat, rnorm(N, sd = 0.6)[id])
## response
dat$y <- with(dat, 1.5 + sin(x1) + sp + re + rnorm(n, sd = 0.6))
## estimate model
b2 <- bayesx(y ~ sx(x1) + sx(id, bs = "mrf", map = MunichBnd) +
sx(id, bs = "re"), method = "MCMC", data = dat)
## summary statistics
summary(b2)
## plot structured spatial effect
plot(b2, term = "sx(id)", map = MunichBnd)
## plot unstructured spatial effect
plot(b2, term = "sx(id):re", map = MunichBnd)
## now without map
## generates a kernel density plot
## of the effects
plot(b2, term = "sx(id):mrf", map = FALSE)
plot(b2, term = "sx(id):re", map = FALSE)
## with approximate quantiles of the
## kernel density estimate
plot(b2, term = "sx(id):re", map = FALSE,
kde.quantiles = TRUE, probs = c(0.025, 0.5, 0.975))
## plot the total spatial effect
plot(b2, term = "sx(id):total")
plot(b2, term = "sx(id):total", map = MunichBnd)
## combine model objects
b <- c(b1, b2)
## plot first term of second model
plot(b, model = 2, term = 1)
plot(b, model = "b2", term = "sx(x1)")
## plot second term of both models
plot(b, term = 2, map = MunichBnd)
## plot everything
plot(b)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.