new_sample | R Documentation |
Generate a new sample for a particular subject given their data and the new model parameter estimates. This should not be called directly, rather it is used internally to run_stage.
new_sample(
s,
data,
num_particles,
parameters,
efficient_mu = NULL,
efficient_sig2 = NULL,
mix_proportion = c(0.5, 0.5, 0),
likelihood_func = NULL,
epsilon = 1,
subjects = NULL
)
s |
A number - the index of the subject. For |
data |
A data.frame (or similar object) which contains the data against which the particles are assessed. The only strict requirement is that it contains a subject column named as such to allow for the splitting of the data by unique subject id. The provided log likelihood function is the only other contact with the data. |
num_particles |
The total number of particles to generate using a combination of the three methods. |
parameters |
A list containing:
|
efficient_mu |
The mu value for the efficient proposals |
efficient_sig2 |
The sigma value for the efficient proposals |
mix_proportion |
A vector of floats between 0 and 1 and summing to 1 which give the proportion of particles to generate from the population level parameters, the individual random effects and the conditional parameters respectively |
likelihood_func |
A likelihood function for calculating log likelihood
of samples. Usually provided internally in |
epsilon |
A scaling factor to reduce the variance on the distribution based on subject random effects when generating particles. |
subjects |
A list of unique subject ids in the order they appear in the data.frame |
The function that controls the generation of new samples for the Particle
Metropolis within Gibbs sampler. It generates samples from either the initial
proposal or from the last iteration of the sampler. This function should not
usually need to be called, as the run_stage
function uses this
internally.
The way it selects a new sample is by generating proposal particles from up to three different distributions (according to a mixing proportion).
The first distribution is based on the current model parameter sample values. The second distribution is based on the last random effects for the subject. The third distribution is only used in the final sampling phase and is based on the conditional distribution built from accepted particles in the adapt phase of the sampler.
A single sample from the new proposals
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.