sir.model
Class SEIRwDState

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

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

Subclass implementing all functionality for an multivariate SEIRwD model. Extra functions for handling diagnostic events is added. Most is done using hook functions. However, the ML function is coded pretty much from scratch.

Version:
5 January 2003
Author:
Michael Höhle <hoehle@stat.uni-muenchen.de>

Field Summary
 Event[] D
          All seroconversion events
 double deltaD
          Parameters of the gamma distributed seroconversion time
 int deltaD_
          Indices in param array
 double gammaD
          Parameters of the gamma distributed seroconversion time
 int gammaD_
          Indices in param array
 
Fields inherited from class sir.model.SEIRState
deltaE, deltaE_, deltaI, deltaI_, E, Eaccept, expTransformParams, firstEventInUnits, gammaE, gammaE_, gammaI, gammaI_, justDiagnostic, lastEventInUnits, MeanVarianceParameters, useOrigins
 
Fields inherited from class sir.model.EpiState
accept, beta, beta_, betaN, betaN_, data, eta, I, loglik, modelParamNames, nogen, noOfModelParams, prob, R, runs, theta
 
Constructor Summary
SEIRwDState()
          Constructor - new necessary structures
 
Method Summary
protected  void addExtraEventsHook(int baseNoOfEvents)
          Hook function to add additional events to the events array.
 void array2Params(double[] theta, boolean expTransformParams)
          Helper function, given an array of size noOfModelParams assign the values of this vector to the correct names.
 java.lang.Object clone()
          Clone.
protected  int extraNoOfEventsHook()
          Hook function returning how many additional events are put into the events array by subclasses etc.
 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.
 void meanVar2GammaDelta()
          Transform from mean,variance to gammaX,deltaX for all parameters, where this applies.
 void MLParamsSetup(double[] theta0, double[] typicalParamSize)
          Hook function to be called when initializing the theta0 and typicalParamSize initialization in the ML method.
 void MLProfiles()
          Create Profile Plots of LogLikelihood around the max
 double[] params2Array()
          Helper functions to put all parameters in an array.
protected  void sampleStateEventsHook(int i, boolean sampleCensored)
          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 toHeaderHook()
          Hook function for header writing
 java.lang.String toStringDiagnostic()
          Function to display how parameters relate to data.
 java.lang.String toStringEvents2()
          This version shows only time of exposure and the length of the infectious time
 java.lang.String toStringEvents3()
          Show all stats
 java.lang.String toStringHook()
          Hook function calling the super before adding SEIRwD specifc things
 void updateD()
          Method to update the D.
 void updateDeltaD()
          Gibbs updating of deltaD - we know the full conditional (see paper)
 void updateE()
          Update E using full conditionals.
 void updateEPropagate()
          Update E using full conditionals.
 void updateGammaD()
          Update gammaD using Metropolis Hastings.
 void updateHook(boolean justTheta)
          Hook method to update additional parameters using MCMC, i.e. deltaD and gammaD
 
Methods inherited from class sir.model.SEIRState
betaHaz, betaHazAll, betaSurvLn, Eloc, Enbr, f_to_minimize, f_to_minimizeHook, generateNext, genXYFuncs, gradient, hessian, lastEventInit, loglik, loglikGammaDelta, ML, MLParamsPrintHook, periodsEV, sampleOrigins, sampleState, showStats, toStringLong, updateBeta, updateBetaN, updateDeltaE, updateDeltaI, updateGammaE, updateGammaI, updateI, updateMetroHastings, updateO, updateR
 
Methods inherited from class sir.model.EpiState
acceptProposal, analLog, fromString, generateNext, isIValid, setData, setProb, showStats, toHeader, toString, toStringEvents, Yintegrate
 
Methods inherited from class java.lang.Object
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


D

public Event[] D
All seroconversion events

Constructor Detail

SEIRwDState

public SEIRwDState()
Constructor - new necessary structures

Method Detail

clone

public java.lang.Object clone()
Clone. Not everything is cloned. Just enough to be able to reconstruct likelihood


meanVar2GammaDelta

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

See Also:
gammaDelta2MeanVar

gammaDelta2MeanVar

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


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.

MLParamsSetup

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

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

MLProfiles

public void MLProfiles()
Create Profile Plots of LogLikelihood around the max

Overrides:
MLProfiles in class SEIRState

toStringDiagnostic

public java.lang.String toStringDiagnostic()
Function to display how parameters relate to data.

Overrides:
toStringDiagnostic in class SEIRState

array2Params

public void array2Params(double[] theta,
                         boolean expTransformParams)
Helper function, given an array of size noOfModelParams assign the values of this vector to the correct names. Call supermethod and initializae gammaD,deltaD

Overrides:
array2Params in class SEIRState
Parameters:
theta - - A vector of length noOfModelParams containing the values to assign
expTransformParams - - When using the minimizer it is a good idea to operate with log(param) value instead to avoid negative values.

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

toStringEvents2

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


toStringEvents3

public java.lang.String toStringEvents3()
Show all stats


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.

toHeaderHook

public java.lang.String toHeaderHook()
Hook function for header writing

Overrides:
toHeaderHook in class SEIRState

toStringHook

public java.lang.String toStringHook()
Hook function calling the super before adding SEIRwD specifc things

Overrides:
toStringHook in class SEIRState

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,
                                     boolean sampleCensored)
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)


updateE

public void updateE()
Update E using full conditionals. Currently, Metropolis Hastings is used, but only relevant parts of likelihood are computed. This version includes Diagnostic events.

Overrides:
updateE in class SEIRState

updateEPropagate

public void updateEPropagate()
Update E using full conditionals. Currently, Metropolis Hastings is used, but only relevant parts of likelihood are computed. This version includes Diagnostic events.


updateD

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


updateHook

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

Overrides:
updateHook in class SEIRState
Parameters:
justTheta - Just update theta no missing events.