View source: R/04_MCMC_compute_psm.R
compute_psm | R Documentation |
The function computes and plots the posterior similarity matrix (PSM), either for the whole dataset, or separately for each group.
The function takes as input an object from fit_CAM
, fit_fiSAN
, or fit_fSAN
,
used with the est_method = "MCMC"
argument.
compute_psm(
object,
distributional = FALSE,
group_specific = FALSE,
plot = TRUE,
ncores = 0
)
object |
An object of class |
distributional |
Logical (default |
group_specific |
Logical (default |
plot |
Logical (default |
ncores |
A parameter to pass to the |
The function compute_psm
returns and plots the posterior similarity matrix.
When distributional = FALSE
, if group_specific = FALSE
, the output is a matrix of dimension N x N
;
if group_specific = TRUE
, the output is a list on length J
(the number of groups), where each entry contains a matrix of dimension Nj x Nj
.
If distributional = TRUE
, the output is a matrix of dimension J x J
.
# Generate example data
set.seed(123)
y <- c(rnorm(100),rnorm(100,5))
g <- rep(1:2,rep(100,2))
plot(y,col=g)
# Fitting fiSAN via MCMC
est <- fit_fiSAN(y, g, est_method = "MCMC")
est
# Estimate PSM
psm_overall <- compute_psm(est)
# Estimate distributional PSM
psm_distrib <- compute_psm(est, distributional = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.