sir.model
Class SEIRwSState

java.lang.Object
  |
  +--sir.model.EpiState
        |
        +--sir.model.SEIRState
              |
              +--sir.model.SEIRwSState
All Implemented Interfaces:
org.omegahat.Simulation.MCMC.MCMCState, Uncmin_methods

public class SEIRwSState
extends SEIRState
implements org.omegahat.Simulation.MCMC.MCMCState, Uncmin_methods

This class is used to represent the state a SEIR model as mentioned in the O'Neill and Becker article. I.e. we have - fixed latency time (c), - beta* X * Y for infection and - gamm, distributed infection time, i.e. f I\sim \Gamma(\gammaI,\deltaI) Note: Nothing about regimes included anymore. Copyright: Copyright (c) 2002

Version:
5 January 2003
Author:
Michael Höhle <hoehle@dina.kvl.dk>

Field Summary
 double deltaD
          Parameters of the gamma distributed seroconversion time
 int deltaD_
          Indices in param array
static double deltaDaccept
          Acceptance rates
 double gammaD
          Parameters of the gamma distributed seroconversion time
 int gammaD_
          Indices in param array
static double gammaDaccept
          Acceptance rates
 Event[] S
          All seroconversion events
 
Fields inherited from class sir.model.SEIRState
deltaE, deltaE_, deltaEaccept, deltaI, deltaI_, deltaIaccept, E, Eaccept, firstEventInUnits, gammaE, gammaE_, gammaEaccept, gammaI, gammaI_, incu, lastEventInUnits, MeanVarianceParameters, sero
 
Fields inherited from class sir.model.EpiState
beta, beta_, betaN, betaN_, betaNaccept, betaaccept, data, eta, gammaIaccept, I, Iaccept, loglik, modelParamNames, nogen, noOfModelParams, prob, R, Raccept, runs
 
Constructor Summary
SEIRwSState()
          Constructor - new necessary structures
 
Method Summary
protected  void addExtraEventsHook(int baseNoOfEvents)
          Hook function to add additional events to the events array.
protected  int extraNoOfEventsHook()
          Hook function returning how many additional events are put into the events array by subclasses etc.
 void f_to_minimizeHook(double[] theta)
          Hook function to move additional parameters in numerical optimizer.
 void gammaDelta2MeanVar()
          The reverse of @see meanVar2GammaDelta, i.e. y=r(x)
 boolean isValidHook()
          Hook function to check for a valid state.
protected  double loglikAddIndividualHook(int i)
          Hook function for adding additional events to the loglikelihood.
 double loglikMoment()
          The likelihood for the transformed case with moment parametrisation
 void meanVar2GammaDelta()
          Transform from mean,variance to gammaX,deltaX for all parameters, where this applies.
 void MLParamsPrintHook(double[] theta)
          Hook function called inside ML once the results are showns.
 void MLParamsSetupHook(double[] theta0, double[] typicalParamSize)
          Hook function to be called when initializing the theta0 and typicalParamSize initialization in the ML method.
 double[] params2Array()
          Helper functions to put all parameters in an array.
protected  void sampleStateEventsHook(int i)
          Use hook function to new individual's diagnostic event in case of censoring.
protected  void sampleStateParamsHook()
          Initializing gammaD and deltaD is done using this hook function.
 java.lang.String showStats(int noOfIterations)
          Show statistics once we are done.
 java.lang.String toStringEvents2()
          This version shows only time of exposure and the length of the infectious time
 void updatedeltaD()
          Gibbs updating of deltaD - we know the full conditional (see paper)
 void updateE()
          Update E using full conditionals.
 void updategammaD()
          Update gammaD using Metropolis Hastings.
 void updateHook()
          Hook method to update additional parameters using MCMC, i.e. deltaD and gammaD
 void updatePrintHook()
          For printing current extra parameters
 void updateS()
          Method to update the S.
 
Methods inherited from class sir.model.SEIRState
absDetJ, array2ParamsExp, betaHaz, betaHazAll, betaSurv, Eloc, Enbr, f_to_minimize, generateNext, genXYFuncs, gradient, hessian, lastEventInit, loglik, loglikGammaDelta, loglikMoment2, ML, periodsEV, sampleOrigins, sampleState, toStringLong, updateBeta, updateBetaN, updateDeltaE, updateDeltaI, updateE2, updateGammaE, updateGammaI, updateI, updateO
 
Methods inherited from class sir.model.EpiState
acceptProposal, analLog, isIValid, setData, setProb, toHeader, toString, toStringEvents, Yintegrate
 
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

gammaD

public double gammaD
Parameters of the gamma distributed seroconversion time


deltaD

public double deltaD
Parameters of the gamma distributed seroconversion time


gammaD_

public int gammaD_
Indices in param array


deltaD_

public int deltaD_
Indices in param array


gammaDaccept

public static double gammaDaccept
Acceptance rates


deltaDaccept

public static double deltaDaccept
Acceptance rates


S

public Event[] S
All seroconversion events

Constructor Detail

SEIRwSState

public SEIRwSState()
Constructor - new necessary structures

Method Detail

meanVar2GammaDelta

public void meanVar2GammaDelta()
Transform from mean,variance to gammaX,deltaX for all parameters, where this applies. Reverse it by calling gammaDelta2MeanVar.

Overrides:
meanVar2GammaDelta in class SEIRState
See Also:
gammaDelta2MeanVar

gammaDelta2MeanVar

public void gammaDelta2MeanVar()
The reverse of @see meanVar2GammaDelta, i.e. y=r(x)

Overrides:
gammaDelta2MeanVar in class SEIRState

loglikMoment

public double loglikMoment()
The likelihood for the transformed case with moment parametrisation

Overrides:
loglikMoment in class SEIRState

extraNoOfEventsHook

protected int extraNoOfEventsHook()
Hook function returning how many additional events are put into the events array by subclasses etc. Overwrites similar method in SEIRState.

Overrides:
extraNoOfEventsHook in class SEIRState
Returns:
Number of additional events added.

addExtraEventsHook

protected void addExtraEventsHook(int baseNoOfEvents)
Hook function to add additional events to the events array. Overwrites method in SEIRState class.

Overrides:
addExtraEventsHook in class SEIRState
Parameters:
baseNoOfEvents - Number of E,I,R events in SEIRState class.
Returns:
Number of additional events added.

loglikAddIndividualHook

protected double loglikAddIndividualHook(int i)
Hook function for adding additional events to the loglikelihood. It is called from within loglikGammaDelta. The rec-inf periods are already added. In this case it is the (possibly censored) seroconversion events. Remember that we operate on log scale!!

Overrides:
loglikAddIndividualHook in class SEIRState
Parameters:
i - Number of the individual.
Returns:
Likelihood of the additional events.

MLParamsSetupHook

public void MLParamsSetupHook(double[] theta0,
                              double[] typicalParamSize)
Hook function to be called when initializing the theta0 and typicalParamSize initialization in the ML method. Add seroconversion part.

Overrides:
MLParamsSetupHook in class SEIRState
Parameters:
theta0 - Array of theta0's, i.e. the start values
typicalParamSize - Typical size

params2Array

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

Overrides:
params2Array in class SEIRState
Returns:
An @see noOfModelParams + 1 long array with params

MLParamsPrintHook

public void MLParamsPrintHook(double[] theta)
Hook function called inside ML once the results are showns. Show Seroparams

Overrides:
MLParamsPrintHook in class SEIRState
Parameters:
theta - Array with the optimized valued. Index 1-4 are taken care of.

f_to_minimizeHook

public void f_to_minimizeHook(double[] theta)
Hook function to move additional parameters in numerical optimizer. Move sero stuff

Overrides:
f_to_minimizeHook in class SEIRState
Parameters:
theta - The theta array

toStringEvents2

public java.lang.String toStringEvents2()
This version shows only time of exposure and the length of the infectious time


isValidHook

public boolean isValidHook()
Hook function to check for a valid state. In our case it's a special case if its a disease transmission experiment. Then all event times have to be in >= 0

Overrides:
isValidHook in class SEIRState
Returns:
Boolean indicating whether all event times are >=0.

sampleStateParamsHook

protected void sampleStateParamsHook()
Initializing gammaD and deltaD is done using this hook function.

Overrides:
sampleStateParamsHook in class SEIRState

sampleStateEventsHook

protected void sampleStateEventsHook(int i)
Use hook function to new individual's diagnostic event in case of censoring. We currently only handle censored diagnostic events, not completly missing.

Overrides:
sampleStateEventsHook in class SEIRState
Parameters:
i - Number of the individual we are newing events for.

updategammaD

public void updategammaD()
Update gammaD using Metropolis Hastings. This new version includes only relevant parts of the likelihood when calculating the acceptance prob. Quite a speed gain! Note though mean/var representation does not work now, but it sucks anyway.


updatedeltaD

public void updatedeltaD()
Gibbs updating of deltaD - we know the full conditional (see paper)


updateS

public void updateS()
Method to update the S. As shown in paper these are only the censored events which can be updated using Gibbs sampling from a truncated gamma distribution


updateE

public void updateE()
Update E using full conditionals. Currently, Metropolis Hastings is used, but at this point we would very much prefer to use some adaptive rejection scheme. Still, the formula is quicker to update so we update all at the same time. This version does not work for mean/var parametrization, just the natural.

Overrides:
updateE in class SEIRState

updateHook

public void updateHook()
Hook method to update additional parameters using MCMC, i.e. deltaD and gammaD

Overrides:
updateHook in class SEIRState

updatePrintHook

public void updatePrintHook()
For printing current extra parameters

Overrides:
updatePrintHook in class SEIRState

showStats

public java.lang.String showStats(int noOfIterations)
Description copied from class: EpiState
Show statistics once we are done.

Overrides:
showStats in class SEIRState
Parameters:
noOfIterations - Number of iterations of the MCMC chain
Returns:
StringBuffer Contains all the stat information