[Pomp-commits] r669 - in pkg/pompExamples: inst/doc src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 18 14:27:14 CEST 2012


Author: kingaa
Date: 2012-04-18 14:27:14 +0200 (Wed, 18 Apr 2012)
New Revision: 669

Modified:
   pkg/pompExamples/inst/doc/budmoth-model-slices.rda
   pkg/pompExamples/inst/doc/budmoth-model-true-loglik.rda
   pkg/pompExamples/inst/doc/pertussis-model-true-loglik.rda
   pkg/pompExamples/src/budmoth.c
Log:
- remove finiteness checks from budmoth model


Modified: pkg/pompExamples/inst/doc/budmoth-model-slices.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/inst/doc/budmoth-model-true-loglik.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/inst/doc/pertussis-model-true-loglik.rda
===================================================================
(Binary files differ)

Modified: pkg/pompExamples/src/budmoth.c
===================================================================
--- pkg/pompExamples/src/budmoth.c	2012-04-18 11:50:55 UTC (rev 668)
+++ pkg/pompExamples/src/budmoth.c	2012-04-18 12:27:14 UTC (rev 669)
@@ -48,26 +48,6 @@
   if (dt != 1.0) 
     error("'delta.t'=",dt,"!=1 violates an assumption of this model");
 
-  // untransform and check the parameters
-  if (!(R_FINITE(ALPHA))) return;
-  if (!(R_FINITE(SIGALPHA))) return;
-  if (!(R_FINITE(GAM))) return;
-  if (!(R_FINITE(LAMBDA))) return;
-  if (!(R_FINITE(SIGLAMBDA))) return;
-  if (!(R_FINITE(GEE))) return;
-  if (!(R_FINITE(DELTA))) return;
-  if (!(R_FINITE(AEY))) return;
-  if (!(R_FINITE(SIGAEY))) return;
-  if (!(R_FINITE(DUBYA))) return;
-
-  // untransform and check the state variables
-  if (!(R_FINITE(ALPHASTATE))) return;
-  if (!(R_FINITE(LAMBDASTATE))) return;
-  if (!(R_FINITE(ASTATE))) return;
-  if (!(R_FINITE(QSTATE))) return;
-  if (!(R_FINITE(NSTATE))) return;
-  if (!(R_FINITE(SSTATE))) return;
-
   sig2lambda = SIGLAMBDA*SIGLAMBDA/LAMBDA;
 
   ALPHASTATE = expit(rnorm(logit(ALPHA),SIGALPHA));
@@ -91,23 +71,6 @@
   double Q, N, S;
   double tol = 1e-6;
 
-  // untransform and check the parameters
-  if (!(R_FINITE(ALPHA))) return;
-  if (!(R_FINITE(GAM))) return;
-  if (!(R_FINITE(LAMBDA))) return;
-  if (!(R_FINITE(GEE))) return;
-  if (!(R_FINITE(DELTA))) return;
-  if (!(R_FINITE(AEY))) return;
-  if (!(R_FINITE(DUBYA))) return;
-
-  // untransform and check the state variables
-  if (!(R_FINITE(ALPHASTATE))) return;
-  if (!(R_FINITE(LAMBDASTATE))) return;
-  if (!(R_FINITE(ASTATE))) return;
-  if (!(R_FINITE(QSTATE))) return;
-  if (!(R_FINITE(NSTATE))) return;
-  if (!(R_FINITE(SSTATE))) return;
-
   f[stateindex[0]] = ALPHA;	// ALPHA equation
   f[stateindex[1]] = LAMBDA;	// LAMBDA equation
   f[stateindex[2]] = AEY;	// A equation
@@ -124,32 +87,23 @@
 void budmoth_rmeasure (double *y, double *x, double *p, 
 		       int *obsindex, int *stateindex, int *parindex, int *covindex,
 		       int ncovars, double *covars, double t) {
-  double meanlogQ;
-  double meanlogN;
-  double meanlogitS;
+  double meanlogQ = log(BETA0+BETA1*QSTATE);
+  double meanlogN = log(NSTATE);
+  double meanlogitS = logit(YEW*SSTATE);
 
-  if (
-      !(R_FINITE(meanlogQ = log(BETA0+BETA1*QSTATE))) ||
-      !(R_FINITE(SIGQOBS))
-      ) {
+  if (!(R_FINITE(meanlogQ)) || !(R_FINITE(SIGQOBS))) {
     QOBS = R_NaN;
   } else {
     QOBS = rlnorm(meanlogQ,SIGQOBS);
   }
 
-  if (
-      !(R_FINITE(meanlogN = log(NSTATE))) ||
-      !(R_FINITE(SIGNOBS))
-      ) {
+  if (!(R_FINITE(meanlogN = log(NSTATE))) || !(R_FINITE(SIGNOBS))) {
     NOBS = R_NaN;
   } else {
     NOBS = rlnorm(meanlogN,SIGNOBS);
   }
 
-  if (
-      !(R_FINITE(meanlogitS = logit(YEW*SSTATE))) ||
-      !(R_FINITE(SIGSOBS))
-      ) {
+  if (!(R_FINITE(meanlogitS)) || !(R_FINITE(SIGSOBS))) {
     SOBS = R_NaN;
   } else {
     SOBS = expit(rnorm(meanlogitS,SIGSOBS));
@@ -161,15 +115,11 @@
 		       int *obsindex, int *stateindex, int *parindex, int *covindex,
 		       int ncovars, double *covars, double t) {
   
-  double meanlogQ;
-  double meanlogN;
-  double meanlogitS;
+  double meanlogQ = log(BETA0+BETA1*QSTATE);
+  double meanlogN = log(NSTATE);
+  double meanlogitS = logit(YEW*SSTATE);
   double f1, f2, f3;
 
-  meanlogQ = log(BETA0+BETA1*QSTATE);
-  meanlogN = log(NSTATE);
-  meanlogitS = logit(YEW*SSTATE);
-
   f1 = dlnorm(QOBS,meanlogQ,SIGQOBS,1);
   f2 = dlnorm(NOBS,meanlogN,SIGNOBS,1);
   f3 = dnorm(logit(SOBS),meanlogitS,SIGSOBS,1)-log(SOBS*(1-SOBS));
@@ -209,35 +159,6 @@
   if (t2-t1 != 1.0) 
     error("t2-t1=",t2-t1,"!=1 violates an assumption of this model");
 
-  // untransform and check the parameters and state variables
-  if (
-      !(R_FINITE(ALPHA)) ||
-      !(R_FINITE(SIGALPHA)) ||
-      !(R_FINITE(GAM)) ||
-      !(R_FINITE(LAMBDA)) ||
-      !(R_FINITE(SIGLAMBDA)) ||
-      !(R_FINITE(GEE)) ||
-      !(R_FINITE(DELTA)) ||
-      !(R_FINITE(AEY)) ||
-      !(R_FINITE(SIGAEY)) ||
-      !(R_FINITE(DUBYA)) ||
-      !(R_FINITE(x1[ALPHASTATE])) ||
-      !(R_FINITE(x1[LAMBDASTATE])) ||
-      !(R_FINITE(x1[ASTATE])) ||
-      !(R_FINITE(x1[QSTATE])) ||
-      !(R_FINITE(x1[NSTATE])) ||
-      !(R_FINITE(x1[SSTATE])) ||
-      !(R_FINITE(x2[ALPHASTATE])) ||
-      !(R_FINITE(x2[LAMBDASTATE])) ||
-      !(R_FINITE(x2[ASTATE])) ||
-      !(R_FINITE(x2[QSTATE])) ||
-      !(R_FINITE(x2[NSTATE])) ||
-      !(R_FINITE(x2[SSTATE]))
-      ) {
-    *f = R_NaN;
-    return;
-  }
-
   sig2lambda = SIGLAMBDA*SIGLAMBDA/LAMBDA;
 
   f1 = dnorm(logit(x2[ALPHASTATE]),logit(ALPHA),SIGALPHA/(x2[ALPHASTATE]*(1-x2[ALPHASTATE])),1);
@@ -269,4 +190,3 @@
 #undef SIGQOBS
 #undef SIGNOBS
 #undef SIGSOBS
-



More information about the pomp-commits mailing list