compute_posterior_probs | R Documentation |
These functions allow for more fine-grained fitting of Ultimate Deconvolution models. Only minimal argument checking is performed and this interface should only be used by experienced users.
compute_posterior_probs(fit, version = c("Rcpp", "R"))
update_mixture_weights(fit, update = c("em", "none"), zero.threshold = 1e-15)
assign_prior_covariance_updates(fit, control = list())
update_prior_covariances(
fit,
covupdates = assign_prior_covariance_updates(fit)$covupdates,
control = assign_prior_covariance_updates(fit)$control
)
update_resid_covariance(
fit,
update = c("em", "none"),
version = c("Rcpp", "R")
)
fit |
An Ultimate Deconvolution model fit. Typically,
this will be an output of |
version |
When |
update |
The method to use for updating the prior mixture
weights or the residual covariance matrix; see |
control |
A list of parameters controlling the behaviour of
the model fitting and initialization. See |
covupdates |
Functions or character strings naming the functions to be called for updating the prior covariance matrices. |
minval |
Minimum eigenvalue allowed in the prior covariance matrices. Should be a small, positive number. |
compute_posterior_probs
returns the matrix of
posterior mixture assignment probabilities ("responsibilities")
given current estimates of the model parameters. This implements
the E step in the EM algorithm.
update_mixture_weights
performs an M-step update for the
mixture weights in the mixture prior (or no update if update
= "none"
).
update_resid_covariance
performs an M-step update for the
residual covariance matrix, V (or no update if update = "none"
).
assign_prior_covariance_updates
determine the functions for
updating the prior covariance matrices based on the the covariance
matrix types and the control settings. The "covupdates"
return value is a character vector with one entry for each prior
covariance matrix.
update_prior_covariances
performs an M-step update for all
the prior covariance matrices, U.
All functions except assign_prior_covariance_updates
return an Ultimate Deconvolution model fit; see
ud_fit
for details.
ud_init
, ud_fit
# Simulate data from a UD model.
set.seed(1)
n <- 4000
V <- rbind(c(0.8,0.2),
c(0.2,1.5))
U <- list(none = rbind(c(0,0),
c(0,0)),
shared = rbind(c(1.0,0.9),
c(0.9,1.0)),
only1 = rbind(c(1,0),
c(0,0)),
only2 = rbind(c(0,0),
c(0,1)))
w <- c(0.8,0.1,0.075,0.025)
rownames(V) <- c("d1","d2")
colnames(V) <- c("d1","d2")
X <- simulate_ud_data(n,w,U,V)
# Perform 4 EM updates.
fit1 <- ud_init(X)
fit1 <- ud_fit(fit1,control = list(maxiter = 4))
# Update the responsibilities matrix.
fit2 <- compute_posterior_probs(fit1)
# Update the mixture weights.
fit2 <- update_mixture_weights(fit2)
# Update the residual covariance, V.
fit2 <- update_resid_covariance(fit2)
# Update the prior covariance matrices, U, using the defaults.
fit2 <- update_prior_covariances(fit2)
# Update only the unconstrained prior covariance matrices using the
# truncated eigenvalue decomposition ("ted") algorithm.
control <- list(scaled.update = "none",rank1.update = "none",
unconstrained.update = "ted")
updates <- assign_prior_covariance_updates(fit2,control)$covupdates
fit2 <- update_prior_covariances(fit2,updates)
# Compute the new log-likelihood and compare the old one.
print(logLik(fit1),digits = 8)
print(logLik(fit2),digits = 8)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.