spEM(x, mu0, blockid = 1:ncol(x),
bw = bw.nrd0(as.vector(as.matrix(x))), constbw = TRUE,
h = bw, eps = 1e-8,
maxiter = 500, stochastic = FALSE, verb = TRUE)
x
) that are
assumed to be identically distributed (i.e., in the same block). For instance,
the default has all distinct elements, indicating that no two coordinates
are assbw.nrd0
bandwidth used by
TRUE
, use the same bandwidth for
each iteration and for each component and block. If FALSE
,
use a separate bandwidth for each component and block, and update
this bandwidth at each iteration of the algorithm lambda
vector (of mixing proportion estimates) does not exceed
eps
.stochastic = FALSE
), convergence
may be declared before maxiter
iterations (see eps
abmaxiter
spEM
returns a list of class spEM
with the following items:stochastic = TRUE
, this matrix is computed
from an average over the maxiter
iterations.constbw==TRUE
,
same as the bw
input argument; otherwise, value of bw
matrix
at final iteration (since for now this algorithm only implements
model (4.7) in Benaglia et al, the bandwidth matrix is reduced to a single
bandwith scalar).
This
information is needed by any method that produces density estimates from the
output.blockid
input argument, but recoded to have
positive integer values. Also needed by any method that produces density
estimates from the output.stochastic = FALSE
,
or the average mixing proportions if stochastic = TRUE
.stochastic = FALSE
,
or the average location parameters if stochastic = TRUE
.stochastic = FALSE
,
or the average scale parameters if stochastic = TRUE
.plot.spEM
, normmixrm.sim
, spEMsymloc
,
npEM
, plotseq.npEM
## simulate a 2-component gaussian mixture with 3 iid repeated measures
set.seed(100)
mu <- matrix(c(0, 15), 2, 3)
sigma <- matrix(c(1, 5), 2, 3)
x <- rmvnormmix(300, lambda = c(.4,.6), mu = mu, sigma = sigma)
## apply spEM with or without an iterative bandwidth selection
d <- spEM(x, mu0 = 2, blockid = rep(1,3), constbw = FALSE)
d2 <- spEM(x, mu0 = 2, blockid = rep(1,3), constbw = TRUE)
plot(d, xlim=c(-10, 40), ylim = c(0, .16), xlab = "", breaks = 30,
cex.lab=1.5, cex.axis=1.5, addlegend=FALSE)
plot(d2, newplot=FALSE, addlegend=FALSE, lty=2)
Run the code above in your browser using DataLab