EM | R Documentation |
Compute the nonparametric maximum likelihood estimate given a likelihood matrix. The matrix A is structured so that A_{ij} = f(X_i | theta_j) for some grid of potential parameter values theta_1, ..., theta_p and observations X_1, ..., X_n. The parameters, theta_j, can be multidimensional because all that is required is the likelihood. Convergence is achieved when the relative improvements of the log-likelihood is below the provided tolerance level.
EM(A, maxiter = 10000L, rtol = 1e-06)
A |
numeric matrix likelihoods |
maxiter |
early stopping condition |
rtol |
convergence tolerance: abs(loss_new - loss_old)/abs(loss_old) |
the estimated prior distribution (a vector of masses corresponding to the columns of A)
set.seed(1)
t = sample(c(0,5), size = 100, replace = TRUE)
x = t + stats::rnorm(100)
gr = seq(from = min(x), to = max(x), length.out = 50)
A = stats::dnorm(outer(x, gr, "-"))
EM(A)
## Not run:
# compare to solution from rmosek (requires additional library installation):
all.equal(
REBayes::KWPrimal(A = A, d = rep(1, 50), w = rep(1/100, 100))$f,
EM(A, maxiter = 1e+6, rtol = 1e-16), # EM alg converges slowly
tolerance = 0.01
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.