sir.estimate
Class SIRestimate.SIRState

java.lang.Object
  |
  +--sir.estimate.SIRestimate.SIRState
All Implemented Interfaces:
org.omegahat.Simulation.MCMC.MCMCState, Uncmin_methods
Enclosing class:
SIRestimate

protected class SIRestimate.SIRState
extends java.lang.Object
implements org.omegahat.Simulation.MCMC.MCMCState, Uncmin_methods

Class corresponds to state of the Markov Chain in the simple SIR example. It consists of beta, gamma, I1, \mathbf{I}. The two latter are stored into the same I array as I[0] and I[1]...I[?], respectively. Added: Implements Uncmin_methods which will contain a wrapper for the optimization class.


Field Summary
 double deviance
          Deviance part
 double loglik
          LogLikelihood
 
Constructor Summary
SIRestimate.SIRState()
          Constructor - necessary to allocate an array for I
 
Method Summary
 void add(SIRestimate.SIRState s, double noOfSamples)
          Add values for posterior mean calculations
 double f_to_minimize(double[] theta)
          In case the object is given to a numerical minimizer, this is the function to minimize.
protected  void genXYZFromLambdaI()
          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.
protected  int ISize(Unit u, int r)
          Deduce number of 'I' events within unit and regime time contributing to the likelihood.
 double logflambdaI()
          Corrected spatial edition, calculating \int_{I_0}^T \sum_{u\in U} \lambda_\all^u(t)
protected  int tauSize(Unit u, int r)
          Deduce number of 'R' events within unit and regime time contributing to the likelihood.
 java.lang.String toString()
          Debug/Information as usual
 void translateTheta2Beta(double[] theta)
          Function to transfer beta vector from one long array to our 3D array This is used in the minimizing stuff.
 void writeRFile()
          To R-compatible file, i.e. write a .txt file containing the following columns t, X_11, Y_11, ..., X_nn, Y_nn, eventype.
protected  double XYintegrate(Unit u, int r)
          Calculate int_{S[i-1]},S[i]} X(t) Y(t) for a regime i.
protected  double Yintegrate(Unit u, int r)
          Calculate int_{S[i-1]},S[i]} 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
 

Field Detail

loglik

public double loglik
LogLikelihood

deviance

public double deviance
Deviance part
Constructor Detail

SIRestimate.SIRState

public SIRestimate.SIRState()
Constructor - necessary to allocate an array for I
Method Detail

translateTheta2Beta

public void translateTheta2Beta(double[] theta)
Function to transfer beta vector from one long array to our 3D array This is used in the minimizing stuff.
Parameters:
double[] - theta The parameter vector, for compatability with Fortran we start at index 1. First spaces are beta, rest is betaN

f_to_minimize

public double f_to_minimize(double[] theta)
In case the object is given to a numerical minimizer, this is the function to minimize. We will only do maximization of the likelihood, i.e. parameters have to be transmoglyffed to account for different indexing of arrays etc. Thus, this will work as a wrapper to logflambdaI.
Specified by:
f_to_minimize in interface Uncmin_methods
Parameters:
x - The parameter (remember Fortran indexing of arrayx (starting at 1))

gradient

public void gradient(double[] x,
                     double[] g)
Gradient function, in case one wants to do numeric optimization of the likelihood. Contains an EMPTY body.
Specified by:
gradient in interface Uncmin_methods
Parameters:
x - The parameter (remember Fortran indexing of arrayx (starting at 1))
g - The computed gradient.

hessian

public void hessian(double[] x,
                    double[][] h)
Hessian function, in case one wants to do numeric optimization of the likelihood. Contains an EMPTY body.
Specified by:
hessian in interface Uncmin_methods
Parameters:
x - The parameter (remember indexing of arrayx (starting at 1))
g - The computed gradient.

writeRFile

public void writeRFile()
To R-compatible file, i.e. write a .txt file containing the following columns t, X_11, Y_11, ..., X_nn, Y_nn, eventype. Output is saved to the file R-epidemic.txt. Note: Regime switches are currently NOT supported in the R-procedure.

toString

public java.lang.String toString()
Debug/Information as usual
Overrides:
toString in class java.lang.Object

add

public void add(SIRestimate.SIRState s,
                double noOfSamples)
Add values for posterior mean calculations

Yintegrate

protected double Yintegrate(Unit u,
                            int r)
Calculate int_{S[i-1]},S[i]} Y_u(t) dt for a unit u and regime r.
Parameters:
u - The unit to get Y(t) from.
r - The regime defining the time limits. I.e. all points with that number.
Returns:
The integral.

XYintegrate

protected double XYintegrate(Unit u,
                             int r)
Calculate int_{S[i-1]},S[i]} X(t) Y(t) for a regime i.
Parameters:
u - Unit to take X,Y values in. This only works as long as there is no interaction.
r - The regime defining the time limits. I.e. all points with that number.

ISize

protected int ISize(Unit u,
                    int r)
Deduce number of 'I' events within unit and regime time contributing to the likelihood. This means that the I event does not count. Same as calculating |I^u_r|
Parameters:
u - The unit
r - The regime
Returns:
|I^u_r|

tauSize

protected int tauSize(Unit u,
                      int r)
Deduce number of 'R' events within unit and regime time contributing to the likelihood. This means that the I event does not count. Same as calculating |tau^u_r|. Instead of going through all events it here suffices to go through the local unit events.
Parameters:
u - The unit
r - The regime
Returns:
|I^u_r|

genXYZFromLambdaI

protected void genXYZFromLambdaI()
Generate X, Y, XY, and time by sorting appropriate events. Note: New Version using Event classes. Before, we sorted by zipping. Now we use general sort on all events. Slower? Probably - use zipper again, which required I to be sorted, but then we have to sort it twice??

logflambdaI

public double logflambdaI()
Corrected spatial edition, calculating \int_{I_0}^T \sum_{u\in U} \lambda_\all^u(t)