sir.estimate
Class LadyBug

java.lang.Object
  extended byorg.omegahat.Simulation.MCMC.NotifyingMCMCObject
      extended byorg.omegahat.Simulation.MCMC.BaseMarkovChain
          extended bysir.estimate.LadyBug
All Implemented Interfaces:
org.omegahat.Simulation.MCMC.MarkovChain, org.omegahat.Simulation.MCMC.NotifyingObject, java.lang.Runnable

public class LadyBug
extends org.omegahat.Simulation.MCMC.BaseMarkovChain

This class implements estimation of the parameters in a SIR epidemic. Four methods are supported:

  1. MCMC analysis as described in O'Neill & Roberts, JRSSA 162. The results of MCMC using burn-in rate, thinning factor, etc. specified by the code are written to a file log.txt. This can then be used by CODA or BOA for analysis in Splus.
  2. Maximum Likelihood
  3. Maximum Marginalized Likelihood
  4. Simulated ML
The class design unfortunately shows clea signs that this has been an incremental project, i.e. it has grown from nothing to something quite huge, without the structure following the same development. E.g. this means that global variables and switches are used instead of nice design patterns.

Version:
2 April 2002
Author:
Michael Höhle <hoehle@dina.kvl.dk>

Nested Class Summary
 
Nested classes inherited from class org.omegahat.Simulation.MCMC.NotifyingMCMCObject
org.omegahat.Simulation.MCMC.NotifyingMCMCObject.MyHandle
 
Field Summary
protected  Data data
          New version - all data related variables are gathered in a Data object
static boolean DEBUG
          Debugging flag - gives extra printed info
static boolean E0Fixed
          Configuration settings
static java.text.DecimalFormat form
          For formatting of doubles to an output stream.
static boolean gotI
          Do we have acces to I time
protected  boolean metropolisBeta
          Do we want the beta's to be updated using Metropolis sampling.
protected  boolean metropolisGamma
          Do we want the gamma's to be updated using Metropolis, i.e.
static Distributions prob
          The Pseudo random generator for distributions
 
Fields inherited from class org.omegahat.Simulation.MCMC.NotifyingMCMCObject
listeners
 
Constructor Summary
LadyBug(org.omegahat.Simulation.RandomGenerators.PRNG prng, java.lang.String dataFile)
          Constructor which calls all the necessary sub-routines, s.a. reading of data, registering of listeners and iteration of the MC.
 
Method Summary
 org.omegahat.Simulation.MCMC.MCMCState generate(org.omegahat.Simulation.MCMC.MCMCState state)
          Generate the next state of the Markov Chain using Gibbs-within-Metropolis.
static void main(java.lang.String[] argv)
          Main function - start a LadyBug analyserer based on prompt arguments
 void MCMCEst(int noOfSamples, int thinFactor, int noOfBurnin, java.lang.String logFileName)
          MCMC Estimation method - generates noOfSamples*thinFactor + noOfBurnin samples and estimates beta and gamma based on recovery times alone.
 void MLEst()
          Calculate parameters beta and gamma using ML estimation.
protected  void readDataFile(java.lang.String fileName)
          Read information about the epidemic from the denoted files.
 
Methods inherited from class org.omegahat.Simulation.MCMC.BaseMarkovChain
getState, iterate, run, step
 
Methods inherited from class org.omegahat.Simulation.MCMC.NotifyingMCMCObject
notifyAll, registerListener, unregisterListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
Debugging flag - gives extra printed info


gotI

public static boolean gotI
Do we have acces to I time


data

protected Data data
New version - all data related variables are gathered in a Data object


metropolisBeta

protected boolean metropolisBeta
Do we want the beta's to be updated using Metropolis sampling. Usually the answer is no if data.noOfUnits == 1 and yes otherwise. But it is possible to hardcode it.


metropolisGamma

protected boolean metropolisGamma
Do we want the gamma's to be updated using Metropolis, i.e. RandomWalk


form

public static java.text.DecimalFormat form
For formatting of doubles to an output stream.


prob

public static Distributions prob
The Pseudo random generator for distributions


E0Fixed

public static boolean E0Fixed
Configuration settings

Constructor Detail

LadyBug

public LadyBug(org.omegahat.Simulation.RandomGenerators.PRNG prng,
               java.lang.String dataFile)
Constructor which calls all the necessary sub-routines, s.a. reading of data, registering of listeners and iteration of the MC. Output is written into the file log.txt.

Parameters:
prng - The pseudo random number generator
dataFile - Name of the file containing recovery, inf and sero times
Method Detail

generate

public org.omegahat.Simulation.MCMC.MCMCState generate(org.omegahat.Simulation.MCMC.MCMCState state)
Generate the next state of the Markov Chain using Gibbs-within-Metropolis. In this new version all the business is done by the state.

Parameters:
state - Current chain of the MC
Returns:
New state of chain.
See Also:
EpiState

readDataFile

protected void readDataFile(java.lang.String fileName)
Read information about the epidemic from the denoted files. This is a new version, where inf and rec times are in the same file. The JavaCC file DataFileSpec.jj contains the specification.

Parameters:
fileName - The filename of the data file.

MCMCEst

public void MCMCEst(int noOfSamples,
                    int thinFactor,
                    int noOfBurnin,
                    java.lang.String logFileName)
MCMC Estimation method - generates noOfSamples*thinFactor + noOfBurnin samples and estimates beta and gamma based on recovery times alone.

Parameters:
noOfSamples - The size of the sample to generate
noOfBurnin - Number of samples to use as burnin. Note: No thinning applied here
thinFactor - Thinning, e.g. take each 100th sample.
logFileName - Name of the log file to save the output.

MLEst

public void MLEst()
Calculate parameters beta and gamma using ML estimation.

Returns:
SIRState object containing the parameter estimates.

main

public static void main(java.lang.String[] argv)
                 throws java.lang.Throwable
Main function - start a LadyBug analyserer based on prompt arguments

Throws:
java.lang.Throwable
See Also:
readDataFile(java.lang.String)