Description Usage Arguments Details Value Author(s) References See Also Examples
fit_ghm
fits a Gaussian Mixture model with hidden components
driven by a Markov random field with known parameters. The inclusion of a
linear combination of basis functions as a fixed effect is also possible.
The algorithm is a modification of of \insertCitezhang2001segmentationmrf2d, which is described in \insertCitefreguglia2020hiddenmrf2d.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 
Y 
A matrix of observed (continuous) pixel values. 
mrfi 
A 
theta 
A 3dimensional array describing potentials. Slices represent
interacting positions, rows represent pixel values and columns represent
neighbor values. As an example: 
fixed_fn 
A list of functions 
equal_vars 

init_mus 
Optional. A 
init_sigmas 
Otional. A 
maxiter 
The maximum number of iterations allowed. Defaults to 100. 
max_dist 
Defines a stopping condition. The algorithm stops if the
maximum absolute difference between parameters of two consecutive iterations
is less than 
icm_cycles 
Number of steps used in the Iterated Conditional Modes algorithm executed in each interaction. Defaults to 6. 
verbose 

qr 
The QR decomposition of the design matrix. Used internally. 
If either init_mus
or init_sigmas
is NULL
an EM algorithm
considering an independent uniform distriburion for the hidden component is
fitted first and its estimated means and sample deviations are used as
initial values. This is necessary because the algorithm may not converge if
the initial parameter configuration is too far from the maximum likelihood
estimators.
max_dist
defines a stopping condition. The algorithm will stop if the
maximum absolute difference between (μ and σ) parameters
in consecutive iterations is less than max_dist
.
A hmrfout
containing:
par
: A data.frame
with μ and σ estimates for each
component.
fixed
: A matrix
with the estimated fixed effect in each pixel.
Z_pred
: A matrix
with the predicted component (highest probability) in
each pixel.
predicted
: A matrix
with the fixed effect + the μ value for
the predicted component in each pixel.
iterations
: Number of EM iterations done.
Victor Freguglia
A paper with detailed description of the package can be found at https://arxiv.org/abs/2006.00383
1 2 3 4 5 6 7 8 9 10 11 12 13  # Sample a Gaussian mixture with components given by Z_potts
# mean values are 0, 1 and 2 and a linear effect on the xaxis.
set.seed(2)
Y < Z_potts + rnorm(length(Z_potts), sd = 0.4) +
(row(Z_potts)  mean(row(Z_potts)))*0.01
# Check what the data looks like
cplot(Y)
fixed < polynomial_2d(c(1,0), dim(Y))
fit < fit_ghm(Y, mrfi = mrfi(1), theta = theta_potts, fixed_fn = fixed)
fit$par
cplot(fit$fixed)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.