Learn R Programming

pauwels2014 (version 1.0)

generate_sample: An implementation of the Metropolis Hasting algorithm

Description

This is an implementation of MH algorithm to sample from the posterior distribution. The proposal is a mixture between a gaussian proposal and a single coordinate proposal. The step size is diminished when the rejection rate is too high.

Usage

generate_sample(theta, knobj, N = 500, step = 1, verbose = F)

Arguments

theta
An initialization parameter named numeric vector
knobj
A knowledge list. See knobjs.
N
The total sample size.
step
The proposal distribution expected step length.
verbose
Should the sampling process print information about itself?

Value

A posterior sample matrix, each row representing a parameter named numeric vector.

Details

The posterior is evaluated using eval_log_like_knobj function.

See Also

eval_log_like_knobj, knobjs

Examples

Run this code
data(experiment_list1)
data(observables)

## Generate the knowledge object with correct parameter value
knobj <- generate_our_knowledge(transform_params)

## Initialize with some data
knobj$datas[[1]] <- list(
 manip = experiment_list1$nothing,
 data = add_noise(
  simulate_experiment(knobj$global_parameters$true_params_T, knobj, experiment_list1$nothing)[
   knobj$global_parameters$tspan %in% observables[["mrnaLow"]]$reso, 
   observables[["mrnaLow"]]$obs
  ]
 )
)

generate_sample(knobj$global_parameters$params * 50, knobj, N = 10)

Run the code above in your browser using DataLab