FixLS_da: Fix Label Switching

Description Usage Arguments Author(s) References See Also Examples

View source: R/label_switching.R

Description

Permutes the posterior realizations in order to fix the labels by either applying an identifiability constraint or by minimizing the squared error loss to find the best permutation.

For examples see

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

Usage

1
2
FixLS_da(fit, burnin = floor(fit$L/10), xlab = "x", ylab = "y",
  approx = TRUE, plot_result = FALSE, run_silent = FALSE)

Arguments

fit

Object of class damcmc_res or bdmcmc_res.

burnin

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

xlab

The label for the x-axis.

ylab

The label for the y-axis.

approx

Logical flag to request use of the identifiability constraint to permute all realizations. If FALSE, minimizing the loss function can be very slow for moderate to large number of components (m>10), since the algorithm goes through all m! permutations for each posterior realization.

plot_result

Logical flag for requesting plots of the point pattern and intensity surface based on the permuted realizations. The default is FALSE.

run_silent

Logical flag to hide progress messages. Default is FALSE.

Author(s)

Jiaxun Chen, Sakis Micheas

References

Jasra, A., Holmes, C.C. and Stephens, D. A. (2005). Markov Chain Monte Carlo Methods and the Label Switching Problem in Bayesian Mixtures. Statistical Science, 20, 50-67.

See Also

normmix, rsppmix, est_mix_damcmc, plot_chains, check_labels

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
# generate data
mix1 <- normmix(ps=c(.4, .2,.4), mus=list(c(0.3, 0.3), c(.5,.5),c(0.7, 0.7)),
 sigmas = list(.02*diag(2),.05*diag(2), .02*diag(2)),lambda = 100, win = spatstat::square(1))
#plot the true mixture
plot(mix1,main = "True Poisson intensity surface (mixture of normal components)")
pp1 <- rsppmix(mix1)
# Run Data augmentation MCMC and get posterior realizations
postfit = est_mix_damcmc(pp1, m=3, truncate=TRUE)
#plot the chains
plot_chains(postfit)
plot_chains(postfit,separate = FALSE)
# get the intensity of posterior means
post_mean = GetPMEst(postfit)
# plot the estimated intensity surface
plot(post_mean)
#check labels
check_labels(postfit)
# Fix label switching, start with approx=TRUE
post_fixed = FixLS_da(postfit, plot_result = TRUE)
plot_chains(post_fixed)
plot_chains(post_fixed, separate = FALSE)
#this one works better in theory
post_fixed = FixLS_da(postfit, approx=FALSE, plot_result = TRUE)
plot_chains(post_fixed)
plot_chains(post_fixed, separate = FALSE)

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