Description Usage Arguments Details Value Note Author(s) References See Also Examples
Estimates the parameters of a MRF by successively sampling from a parameter configuration and updating it by comparing the sufficient statistics of the sampled field and the observed field.
This method aims to find the parameter value where the gradient of the likelihood function is equal to zero.
1 2 3 4 5 6 7 8 9 10 11 | fit_sa(
Z,
mrfi,
family = "onepar",
gamma_seq,
init = 0,
cycles = 5,
refresh_each = length(gamma_seq) + 1,
refresh_cycles = 60,
verbose = interactive()
)
|
Z |
A |
mrfi |
A |
family |
The family of parameter restrictions to potentials. Families
are:
|
gamma_seq |
A |
init |
The initial value to be used in the optimization. It can be:
|
cycles |
The number of updates to be done (for each each pixel). |
refresh_each |
An integer with the number of iterations taken before a
complete refresh (restart from a random state). This prevents the sample from
being stuck in a mode for too long. Defaults to |
refresh_cycles |
An integer indicating how many Gibbs Sampler cycles are performed when a refresh happens. Larger is usually better, but slower. |
verbose |
|
The stochastic approximation method consists of, given an observed field Z
,
and a starting parameters configuration θ_0, successively sample
a field Z_t from the current parameter configuration and estimate the
direction of the gradient of the likelihood function by comparing the
sufficient statistics in the current sample and the observed field.
The solution is updated by moving in the estimated direction with a predefined step size γ_t, a new field Z_{t+1} is sampled using the new parameter configuration and Z_t as an initial value, and the process is repeated.
θ_{t+1} = θ_t - γ_t(T(Z_t) - T(Z)),
where T(Z) is the sufficient statistics for the reference field, T(Z_t) is the sufficient statistics for a field sampled from θ_t.
gamma_seq
is normalized internally by diving values by length(Z)
, so the
choice of the sequence is invariant to the lattice dimensions. Typically, a
sequence like seq(from = 1, to = 0, length.out = 1000)
should be used for
defining a sequence with 1000
steps. Some tuning of this sequence is
required.
A mrfout
object with the following elements:
theta
: The estimated array
of potentials.
mrfi
: The interaction structure considered.
family
: The parameter restriction family considered.
method
: The estimation method ("Stochastic Approximation"
).
metrics
: A data.frame
containing the the euclidean distance between
the sufficient statics computed for Z
and the current sample.
Stochastic Approximation is called "Controllable Simulated Annealing" in some references.
Examples where Stochastic Approximation is used with MRFs are \insertCitegimel_samrf2d, \insertCiteCRmrf2d.
Victor Freguglia
wiki_samrf2d
\insertAllCitedA paper with detailed description of the package can be found at doi: 10.18637/jss.v101.i08.
1 2 3 4 5 6 7 8 | set.seed(2)
fit1 <- fit_sa(Z_potts, mrfi(1), family = "oneeach", gamma_seq = seq(1, 0, length.out = 50))
# Estimated parameters
fit1$theta
# A visualization of estimated gradient norm over iterations.
plot(fit1$metrics, type = "l")
fit_sa(Z_potts, mrfi(1), family = "oneeach", gamma_seq = seq(1, 0, length.out = 50))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.