generate_sample: An implementation of the Metropolis Hasting algorithm

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/generate_sample.R

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

1
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?

Details

The posterior is evaluated using eval_log_like_knobj function.

Value

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

Author(s)

Edouard Pauwels

See Also

eval_log_like_knobj, knobjs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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)

pauwels2014 documentation built on May 1, 2019, 6:29 p.m.