|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsir.model.EpiState
sir.model.SEIRState
Subclass implementing all functionality for an multivariate SEIR model. This class is used to represent the state as a SEIR model as mentioned in the O'Neill and Becker article "Inference for an epidemic when susceptibility varies", P.D. O'Neill and Niels G. Becker, Biostatistics 2(1), pp.99-108 (2001) and the M. Hoehle, E. Jørgensen, and P.D. O'Neill article "Inference in disease transmission experiments using stochastic epidemic models. I.e. we have
Copyright: GPL
Field Summary | |
double |
deltaE
Parameters of the gamma distributed incbuation time |
int |
deltaE_
Index of inc time parameters in param vector |
double |
deltaI
Parameters of the gamma distributed infectious time |
int |
deltaI_
Index of inc time parameters in param vector |
Event[] |
E
All the exposed states |
static double |
Eaccept
|
boolean |
expTransformParams
Are we operating with log transformed parameters in the loglik function. |
Event[][] |
firstEventInUnits
First event in all units - a data structure updated each timegenXYFuncs is called. |
double |
gammaE
Parameters of the gamma distributed incbuation time |
int |
gammaE_
Index of inc time parameters in param vector |
double |
gammaI
Parameters of the gamma distributed infectious time |
int |
gammaI_
Index of inc time parameters in param vector |
boolean |
justDiagnostic
Just a foobar thing - only use diagnostic times in the likelihood |
Event[][] |
lastEventInUnits
Global variable to speed up the lastEventInit method so we do not need to new each time |
boolean |
MeanVarianceParameters
Re-parameterization using mean and variance |
boolean |
useOrigins
Are we using exposure origins in the loglik calculations. |
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 | |
SEIRState()
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. |
double |
betaHaz(Unit u,
Unit o,
Event[][] le)
Method to compute \lambda_e^j (t-) when the origin of the event is known. |
double |
betaHazAll(Unit u,
Event[][] le)
Method to compute \lambda_{all}^j(t-|...) for a specific individual (located in u_j). |
double |
betaSurvLn(Unit u,
double tstop)
Compute log S_j(t), i.e. the survival of an individual located in unit u up to time t, when overall hazard exerted on the individual is \lambda_j(t). |
java.util.LinkedList |
Eloc()
Count the number of exposures originating from the unit itself. |
java.util.LinkedList |
Enbr()
Count the number of exposures originating from a neighbour. |
protected int |
extraNoOfEventsHook()
Hook function returning how many additional events are put into the events array by subclasses etc. |
double |
f_to_minimize(double[] theta)
In case the object is given to a numerical minimizer, this is the function to minimize. |
void |
f_to_minimizeHook(double[] theta)
Hook function to move additional parameters in numerical optimizer. |
EpiState |
generateNext(boolean justTheta)
Generate method for MCMC chain Modifcation happen on the instance itself to keep things simple. |
void |
genXYFuncs()
Generate X, Y, XY, and time by sorting appropriate events. |
void |
gradient(double[] x,
double[] g)
Gradient function, in case one wants to do numeric optimization of the likelihood. |
void |
hessian(double[] x,
double[][] h)
Hessian function, in case one wants to do numeric optimization of the likelihood. |
boolean |
isValidHook()
Hook function to check for a valid state. |
Event[][] |
lastEventInit(boolean newArray)
Prepare the last event data structure. |
double |
loglik()
Just a dummy director to the currently used loglik function depending on the currently used parametrisation. |
protected double |
loglikAddIndividualHook(int individual)
Hook function for adding additional events to the loglikelihood. |
double |
loglikGammaDelta()
Abstract method to calculate the loglikelihood of the state. |
double[] |
ML(double[][] iHessian)
Perform maximum likelihood estimation by numerically maximizing the likelihood equation. |
void |
MLParamsPrintHook(double[] theta)
Hook function called inside ML once the results are showns |
void |
MLParamsSetup(double[] theta0,
double[] typicalParamSize)
Function to be called when initializing the theta0 and typicalParamSize initialization in the ML method. |
void |
MLProfiles()
Foo function to be specialized in SEIRWState |
double[] |
params2Array()
Helper functions to put all named parameters in an array. |
double[] |
periodsEV()
Small stats function to compute mean and variance for inf or inc periods of current configuraion |
void |
sampleOrigins()
Get origins right once we know E(t), I(t), R(t), i.e can't pick an origin where I(t) = 0. |
EpiState |
sampleState(boolean sampleCensored)
Make a valid instance of the parameters to start the MCMC chain with. |
protected void |
sampleStateEventsHook(int i,
boolean sampleCensored)
Hook function to new any additional events in subclasses. |
protected void |
sampleStateParamsHook()
Hook function to initialize any additional parameters introduced in subclasses. |
java.lang.String |
showStats(int noOfIterations)
|
java.lang.String |
toHeaderHook()
Hook function for header writing |
java.lang.String |
toStringDiagnostic()
Show how state params relate to data |
java.lang.String |
toStringHook()
Hook function for SEIR specific output |
java.lang.String |
toStringLong()
Current State information is shown on screen in long format |
void |
updateBeta()
Gibbs updating of beta - we know the full conditional (see paper) This version handles the multiple unit setup. |
void |
updateBetaN()
Gibbs updating of betaN - we know the full conditional (see paper) This is a new version correcting an mistake of the conditioning on o_j. |
void |
updateDeltaE()
Gibbs updating of deltaI - we know the full conditional (see paper) |
void |
updateDeltaI()
Gibbs updating of deltaI - we know the full conditional (see paper) |
void |
updateE()
Update E using full conditionals. |
void |
updateGammaE()
Update gammaE using Metropolis Hastings. |
void |
updateGammaI()
Update gammaI using Metropolis Hastings. |
void |
updateHook(boolean justTheta)
Hook method to update additional parameters using MCMC. |
void |
updateI()
Update I using Metropolis Hastings. |
void |
updateMetroHastings(double[] theta,
int paramIndex,
double sigma)
Random Walk Metropolis-Hastings updating of a parameter with gamma prior distribution. |
void |
updateO()
Update the o vector using Gibbs Sampling. |
void |
updateR()
Update R using Metropolis Hastings. |
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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public double gammaE
public double deltaE
public double gammaI
public double deltaI
public int gammaE_
public int deltaE_
public int gammaI_
public int deltaI_
public boolean MeanVarianceParameters
public boolean justDiagnostic
public boolean expTransformParams
public Event[] E
public static double Eaccept
public boolean useOrigins
public Event[][] firstEventInUnits
public Event[][] lastEventInUnits
Constructor Detail |
public SEIRState()
Method Detail |
public java.lang.String toStringDiagnostic()
public java.lang.String toStringLong()
toStringLong
in class EpiState
public double betaHaz(Unit u, Unit o, Event[][] le)
u
- Unit, where the individual is located.o
- Unit, where the exposure is originating from (o is equal to u or one of its neighbours)le
- Array with last event occured in each section. I.e. state just before to the event of interest.
public double betaHazAll(Unit u, Event[][] le)
u
- Unit, where the individual is located.le
- Array with last event occured in each section. I.e. state previous to the event of interest.
public Event[][] lastEventInit(boolean newArray)
newArray
- Should we new a new instance. Necessary if we have nested calls to lastEventInit as in loglik
public double betaSurvLn(Unit u, double tstop)
u
- The unit, where the individual is located.
public double loglikGammaDelta()
public double loglik()
loglik
in class EpiState
public void sampleOrigins()
protected void sampleStateParamsHook()
protected void sampleStateEventsHook(int i, boolean sampleCensored)
i
- Number of the individual we are newing events for.public EpiState sampleState(boolean sampleCensored)
sampleState
in class EpiState
public void updateMetroHastings(double[] theta, int paramIndex, double sigma)
theta
- Vector of all parameters.paramIndex
- of the parameter to updatesigma
- How large a standard deviation to use in the proposal distribution
Note: The value is updated automatically by calling the array2Param function
Therefore no value is returnedpublic void updateBeta()
public void updateBetaN()
public void updateDeltaE()
public void updateDeltaI()
public void updateGammaE()
public void updateGammaI()
public void updateO()
public void updateE()
public void updateI()
public void updateR()
public void updateHook(boolean justTheta)
justTheta
- no data just parameters are updated.public EpiState generateNext(boolean justTheta)
generateNext
in class EpiState
justTheta
- Boolean indicating whether to just update the beta,...,gamma_D variables
public void f_to_minimizeHook(double[] theta)
theta
- The theta arraypublic double[] periodsEV()
public double[] params2Array()
params2Array
in class EpiState
public void array2Params(double[] theta, boolean expTransformParams)
theta
- - A vector of length noOfModelParams containing the values to assignexpTransformParams
- - When using the minimizer it is a good idea to operate with
log(param) value instead to avoid negative values.public double f_to_minimize(double[] theta)
f_to_minimize
in interface Uncmin_methods
theta
- The parameter vector(remember Fortran indexing of arrayx (starting at 1))public void gradient(double[] x, double[] g)
gradient
in interface Uncmin_methods
x
- The parameter (remember Fortran indexing of arrayx (starting at 1))g
- The computed gradient.public void hessian(double[] x, double[][] h)
hessian
in interface Uncmin_methods
x
- The parameter (remember indexing of arrayx (starting at 1))protected int extraNoOfEventsHook()
protected void addExtraEventsHook(int baseNoOfEvents)
baseNoOfEvents
- Number of E,I,R events in SEIRState class.
protected double loglikAddIndividualHook(int individual)
individual
- The i'th individual to add events for
public void genXYFuncs()
genXYFuncs
in class EpiState
public void MLParamsSetup(double[] theta0, double[] typicalParamSize)
theta0
- Array of theta0's, i.e. the start valuestypicalParamSize
- Typical sizepublic void MLParamsPrintHook(double[] theta)
theta
- Array with the optimized valued. Index 1-4 are taken care of.public double[] ML(double[][] iHessian)
iHessian
- Inverse of Hessian as array (has to be newed before!)public void MLProfiles()
public java.util.LinkedList Eloc()
public java.util.LinkedList Enbr()
public boolean isValidHook()
isValidHook
in class EpiState
public java.lang.String toHeaderHook()
toHeaderHook
in class EpiState
public java.lang.String toStringHook()
toStringHook
in class EpiState
public java.lang.String showStats(int noOfIterations)
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |