Rép. : MCSim and mixture models
"Frederic BOIS" <[email protected]> Tue, 22 Apr 2014 13:13:46 +0200
| Newsgroups | gmane.comp.gnu.mcsim |
|---|---|
| Message-ID | <[email protected]> |
Hi Bill,
I assume that by mixture you mean "model A" with probability P(A), "model B" with probability P(B) etc., and in an MCMC context.
I have never done that. I would setup an indicator variable, condition the code on its value...
There are two problems: sampling the indicator variable (there is an obscure "PiecewiseVariate"
function that could do that in random.c I think).
The other problem would be sampling the parameters: If the indicator variable is set to B and a parameter to sample is used in model A, then any
new value for that parameter would be accepted because it does enter in the likelihood computed with model B. So in fact, only the parameters
relevant for model B should be sampled as long as the indicator points to B...
There might be a way (not covered by the warranty!):
#===================
# Model file:
States = {Y}
Outputs = {Y_out}
# parameters
Param_a;
Param_b;
model; # zero or 1
Indicator; # zero or 1
very_unlikely_value = 1e-30;
Dynamics {
# model 0 is - a * Y
# model 1 is - a * Y * Y
dt(Y) = (Indicator == model ? (model == 0 ? - Param_a * Y : - Param_b * Y * Y)
: 0); # avoid computing for nothing
}
Outputs {
Y_out = (Indicator == model ? Y : very_unlikely_value) # that way irrelevant samples (for non model parameters) will be rejected
}
#===================
# Input file:
Level {
Distribution (Indicator, ...); # e.g. bernoulli, or PiecewiseVariate if you make it work!
Likelihood (Y_out, ...);
Level { # for model A
Distribution (Param_a, ...);
Level {
Simulation {
model = A;
Y = ...
Print (Y_out, ...);
Data (Y_out, ...);
}
Simulation {
model = A;
Y = ...
Print (Y_out, ...);
Data (Y_out, ...);
}
}
} # end level model A
Level { # for model B, same data
Distribution (Param_b ...)
Level {
Simulation {
model = B
Y = ...
Print (Y_out, ...);
Data (Y_out, ...);
}
Simulation {
model = B
Y = ...
Print (Y_out, ...);
Data (Y_out, ...);
}
}
} # end level model B
}
End.
Frederic
>>> Bill Harris <[email protected]> 18/04/2014 17:21 >>>
Does anyone have an example of the setup of a simple dynamic (ODE) mixture
model in MCSim? Without a predefined unit k-simplex distribution, I'm not
quite sure where to start.
Thanks,
Bill