plot_avgsurf: Plot the average intensity surface

Description Usage Arguments Value Author(s) See Also Examples

View source: R/mcmc_plots.R

Description

This function calculates the intensity surface at each posterior realization and then computes the average for the intensity surface over a fine grid. The result is a much smoother posterior estimator of the intensity surface, which is not necessarily the same as the surface of posterior means, which is obtained by GetPMEst.

For examples see

http://faculty.missouri.edu/~micheasa/sppmix/sppmix_all_examples.html#plot_avgsurf

Usage

1
2
3
plot_avgsurf(fit, win = fit$data$window, LL = 100,
  burnin = floor(fit$L/10), zlims = c(0, 0), grayscale = FALSE,
  showplot = TRUE)

Arguments

fit

An object the contains all posterior realizations, e.g., the return value from est_mix_damcmc or est_mix_bdmcmc.

win

An object of class owin.

LL

Length of the side of the square grid. The density or intensity is calculated on an L * L grid. The larger this value is, the slower the calculation, but the better the approximation.

burnin

Number of initial realizations to discard. By default, it is 1/10 of the total number of iterations.

zlims

The limits of the z axis. Defaults to [0,1.1*max(intensity)].

grayscale

Logical flag to request a gray scale plot.

showplot

Logical flag to request that the plot will be shown. Set to FALSE if you want to return the im.object, but do not want to produce the 3d plot.

Value

An image as an object of class im.object.

Author(s)

Jiaxun Chen, Sakis Micheas

See Also

rnormmix, to_int_surf, rsppmix, est_mix_damcmc, plot_density, ggtitle, geom_point, plotmix_3d, GetPMEst

Examples

 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
truemix <- rnormmix(m = 5, sig0 = .1, df = 5, xlim= c(-1, 1), ylim =c(0, 3))
trueintsurf=to_int_surf(truemix, lambda = 200, win =spatstat::owin( c(-1, 1),c(0, 3)))
plot(trueintsurf, main = "True Poisson intensity surface (mixture of normal components)")
pp1 <- rsppmix(trueintsurf)
# Run Data augmentation MCMC and get posterior realizations
postfit=est_mix_damcmc(pp1,m=5)
# Plot the average of the surfaces of the posterior realizations
avgsurf=plot_avgsurf(postfit, LL = 50)
p<-plot_density(as.data.frame(avgsurf))+ggplot2::ggtitle(
 "Average surface of the posterior realization surfaces\n x denotes a true component mean")
#show the point pattern points
pp_df <- data.frame(pp1$x,pp1$y)
names(pp_df) <- c("x", "y")
p<-p + ggplot2::geom_point(data = pp_df,size=0.8)
#show the true means
mean_df <- data.frame(do.call(rbind, trueintsurf$mus))
names(mean_df) <- c("x", "y")
p + ggplot2::geom_point(data = mean_df, color = "red", shape = "x", size = 5)
#repeat for the contour plot
p<-plot_density(as.data.frame(avgsurf),contour = TRUE)+ggplot2::ggtitle(
 "Average surface of the posterior realization surfaces\n x denotes a true component mean")
#show the point pattern points
pp_df <- data.frame(pp1$x,pp1$y)
names(pp_df) <- c("x", "y")
p<-p + ggplot2::geom_point(data = pp_df,size=0.8)
#show the true means
mean_df <- data.frame(do.call(rbind, trueintsurf$mus))
names(mean_df) <- c("x", "y")
p + ggplot2::geom_point(data = mean_df, color = "red", shape = "x", size = 5)
#plot the 3d surface again based on the returned object
plotmix_3d(avgsurf,title1 = paste("Average of", .9*postfit$L,
 "posterior realizations of the intensity surface"))

sppmix documentation built on Jan. 13, 2021, 10:04 p.m.