sir.model
Class EpiState

java.lang.Object
  extended bysir.model.EpiState
All Implemented Interfaces:
org.omegahat.Simulation.MCMC.MCMCState, Uncmin_methods
Direct Known Subclasses:
SEIRState

public abstract class EpiState
extends java.lang.Object
implements org.omegahat.Simulation.MCMC.MCMCState, Uncmin_methods

The EpiState is an abstract base class implementing common features of the epidemic model. A class hierarchy with SEIRState and SEIRwDState as subclasses. The EpiState is an abstract base class implementing a couple of common features -- most functionality will be made in the subclasses.

Version:
16 October 2002
Author:
Michael Höhle <hoehle@stat.uni-muenchen.de>

Field Summary
 int[] accept
          Acceptance counts for all traditional parameters
 double beta
          Infection pressure aka. transmission parameter
 int beta_
           
 double betaN
          Vaccination effect
 int betaN_
           
protected static Data data
          Static link to the data.
 double eta
          Neighbour effect
 Event[] I
          Array of infection times, I1,...
 double loglik
          LogLikelihood
 java.lang.String[] modelParamNames
          The names of all model parameters to be used when printing them
 boolean nogen
          Boolean telling whether the time wise structure has been created on this object (inits events array)
 int noOfModelParams
          Number of model parameters, i.e. no of unknowns when we have full data
protected static Distributions prob
          Static link to a random number generator
 Event[] R
          Array of recovery times, R1,...
static int runs
          Static stuff to keep track of progress
 double[] theta
          Dual representation of params by array
 
Constructor Summary
EpiState()
          Constructor - initializes structures holding who is parameter and who is fixed among the recovery and infection events.
 
Method Summary
protected  boolean acceptProposal(double logfnew, double logfold)
          Based on acceptance probability we find out whether to accept a sample i.e. we accept it with probability min( f(x'|)pi(x') / f(x|)pi(x), 1)
 java.lang.String analLog(java.lang.String logFileName)
          Method to present mean and variance of posterior for each variable contained in the logfile.
 void fromString(java.lang.String aLine)
          Take a line from a logfile and assign the parameters.
 EpiState generateNext()
           
abstract  EpiState generateNext(boolean justTheta)
          Generate method for MCMC chain
abstract  void genXYFuncs()
          Generate X, Y as functions of time by bookeeping of events
 boolean isIValid()
          Verify whether I is valid wrt. tau, i.e. that the constraints are fulfilled
 boolean isValidHook()
          Hook function to be used by subclasses
abstract  double loglik()
          Abstract method to calculate the loglikelihood of the state
abstract  double[] params2Array()
          Helper functions to put all parameters in an array.
abstract  EpiState sampleState(boolean sampleCensored)
          Make a valid instance of the parameters, e.g. to start the MCMC chain with
static void setData(Data theData)
          Set reference to the data
static void setProb(Distributions theProb)
           
 java.lang.String showStats(java.lang.String logFile)
          Show statistics once we are done.
 java.lang.String toHeader()
          What to write to the header of the log
 java.lang.String toHeaderHook()
           
 java.lang.String toString()
          Debug/Information as usual.
 java.lang.String toStringEvents()
          Show X(t) and Y(t) as functions
 java.lang.String toStringHook()
           
 java.lang.String toStringLong()
          Current State information is shown on screen in long format
protected  double Yintegrate(Unit u, double tstop)
          Calculate int_{i_0}^t Y_u(t) dt for a unit u and regime r.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sir.optim.Uncmin_methods
f_to_minimize, gradient, hessian
 

Field Detail

I

public Event[] I
Array of infection times, I1,...,Im


R

public Event[] R
Array of recovery times, R1,...,Rm


noOfModelParams

public int noOfModelParams
Number of model parameters, i.e. no of unknowns when we have full data


modelParamNames

public java.lang.String[] modelParamNames
The names of all model parameters to be used when printing them


beta

public double beta
Infection pressure aka. transmission parameter


eta

public double eta
Neighbour effect


betaN

public double betaN
Vaccination effect


theta

public double[] theta
Dual representation of params by array


beta_

public int beta_

betaN_

public int betaN_

loglik

public double loglik
LogLikelihood


nogen

public boolean nogen
Boolean telling whether the time wise structure has been created on this object (inits events array)


runs

public static int runs
Static stuff to keep track of progress


accept

public int[] accept
Acceptance counts for all traditional parameters


data

protected static Data data
Static link to the data.


prob

protected static Distributions prob
Static link to a random number generator

Constructor Detail

EpiState

public EpiState()
Constructor - initializes structures holding who is parameter and who is fixed among the recovery and infection events.

Method Detail

fromString

public void fromString(java.lang.String aLine)
Take a line from a logfile and assign the parameters. Caution: We assumed the logfile has correct format compared to the instance of EpiState we are looking at.

Parameters:
aLine - A line from the logfile containing all the parameters

toStringHook

public java.lang.String toStringHook()

toString

public java.lang.String toString()
Debug/Information as usual. This is used in logfiles


toStringLong

public java.lang.String toStringLong()
Current State information is shown on screen in long format


toHeader

public java.lang.String toHeader()
What to write to the header of the log


toHeaderHook

public java.lang.String toHeaderHook()

toStringEvents

public java.lang.String toStringEvents()
Show X(t) and Y(t) as functions


Yintegrate

protected double Yintegrate(Unit u,
                            double tstop)
Calculate int_{i_0}^t Y_u(t) dt for a unit u and regime r.

Parameters:
u - The unit to get Y(t) from.
tstop - Integrate \int_{i_0}^{t} Y(t) dt
Returns:
The integral.

isValidHook

public boolean isValidHook()
Hook function to be used by subclasses


isIValid

public boolean isIValid()
Verify whether I is valid wrt. tau, i.e. that the constraints are fulfilled


genXYFuncs

public abstract void genXYFuncs()
Generate X, Y as functions of time by bookeeping of events


loglik

public abstract double loglik()
Abstract method to calculate the loglikelihood of the state


sampleState

public abstract EpiState sampleState(boolean sampleCensored)
Make a valid instance of the parameters, e.g. to start the MCMC chain with


acceptProposal

protected boolean acceptProposal(double logfnew,
                                 double logfold)
Based on acceptance probability we find out whether to accept a sample i.e. we accept it with probability min( f(x'|)pi(x') / f(x|)pi(x), 1)

Parameters:
logfnew - log( f(x'|...) * pi(x') ), i.e. numerator of acceptance fraction
logfold - log( f(x'|...) * pi(x) ), i.e. denumerator of acceptance fraction
Returns:
Boolean telling whether the proposal is to be accepted.

setData

public static void setData(Data theData)
Set reference to the data


setProb

public static void setProb(Distributions theProb)

generateNext

public abstract EpiState generateNext(boolean justTheta)
Generate method for MCMC chain

Parameters:
justTheta - Boolean indicating whether to just update the beta,...,gamma_D variables

generateNext

public EpiState generateNext()

params2Array

public abstract double[] params2Array()
Helper functions to put all parameters in an array. Remember Fortran indexing Function currently does not work if incu period a constant.

Returns:
An @see noOfModelParams + 1 long array with params

analLog

public java.lang.String analLog(java.lang.String logFileName)
Method to present mean and variance of posterior for each variable contained in the logfile. This is a new generic version handling any amount of parameters

Parameters:
logFileName - The name of the logfile to look in.
Returns:
String with the information to present

showStats

public java.lang.String showStats(java.lang.String logFile)
Show statistics once we are done.

Parameters:
logFile - Name of the logFile to analyze
Returns:
StringBuffer Contains all the stat information