From noreply at r-forge.r-project.org Sun Mar 2 15:10:33 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 2 Mar 2014 15:10:33 +0100 (CET) Subject: [Pomp-commits] r887 - in pkg/pomp: . inst src tests Message-ID: <20140302141033.C4D49184AFD@r-forge.r-project.org> Author: kingaa Date: 2014-03-02 15:10:33 +0100 (Sun, 02 Mar 2014) New Revision: 887 Modified: pkg/pomp/DESCRIPTION pkg/pomp/inst/NEWS pkg/pomp/src/cholmodel.c pkg/pomp/tests/dacca.R pkg/pomp/tests/dacca.Rout.save Log: - fix bug in 'dacca' model to do with very occasional state-variable positivity violations. The model is slightly different now, but likelihoods at MLE appear to be much the same. This makes sense since positivity violations are extremely rare near the MLE. Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-02-27 02:20:24 UTC (rev 886) +++ pkg/pomp/DESCRIPTION 2014-03-02 14:10:33 UTC (rev 887) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.47-2 -Date: 2014-02-26 +Version: 0.47-3 +Date: 2014-03-01 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-02-27 02:20:24 UTC (rev 886) +++ pkg/pomp/inst/NEWS 2014-03-02 14:10:33 UTC (rev 887) @@ -1,4 +1,10 @@ NEWS +0.47-3 + o Fix bug that arises only very occasionally in the 'dacca' cholera example. + + o Modify 'dacca' model so that rare positivity violations are punished in a different way. + This modifies the formal model slightly. + 0.47-2 o By default, 'pompBuilder' now creates all files in the temporary directory. Modified: pkg/pomp/src/cholmodel.c =================================================================== --- pkg/pomp/src/cholmodel.c 2014-02-27 02:20:24 UTC (rev 886) +++ pkg/pomp/src/cholmodel.c 2014-03-02 14:10:33 UTC (rev 887) @@ -92,31 +92,13 @@ const double *pt; int j; - if (!(R_FINITE(SUSCEP))) return; - if (!(R_FINITE(INFECT))) return; - if (!(R_FINITE(RSHORT))) return; - for (pt = &RLONG, j = 0; j < nrstage; j++) { - if (!(R_FINITE(pt[j]))) return; - } + if (COUNT != 0.0) return; eps = EPS*NRSTAGE; - if (!(R_FINITE(GAMMA))) return; - if (!(R_FINITE(eps))) return; - if (!(R_FINITE(RHO))) return; - if (!(R_FINITE(DELTA))) return; - if (!(R_FINITE(DELTA_I))) return; - if (!(R_FINITE(CLIN))) return; - if (!(R_FINITE(SD_BETA))) return; - if (!(R_FINITE(ALPHA))) return; - if (!(R_FINITE(BETATREND))) return; - beta = exp(dot_product(nbasis,&SEASBASIS,&LOGBETA)+BETATREND*TREND); omega = exp(dot_product(nbasis,&SEASBASIS,&LOGOMEGA)); - if (!(R_FINITE(beta))) return; - if (!(R_FINITE(omega))) return; - dw = rnorm(0,sqrt(dt)); // white noise effI = pow(INFECT/POP,ALPHA); @@ -135,21 +117,6 @@ infections = (omega+(beta+SD_BETA*dw/dt)*effI)*SUSCEP; // infection sdeaths = DELTA*SUSCEP; // natural S deaths - if (infections > 0.0) { - if ((infections+sdeaths)*dt > SUSCEP) { // too many leaving S class - COUNT += 1.0e10; - return; - } - } else { - if ((-CLIN*infections+disease+ideaths+passages[0])*dt > INFECT) { // too many leaving I class - COUNT += 1.0e5; - return; - } - if ((-(1-CLIN)*infections+rsdeaths+wanings)*dt > RSHORT) { // too many leaving Rs class - COUNT += 1; - return; - } - } SUSCEP += (births - infections - sdeaths + passages[nrstage] + wanings)*dt; INFECT += (CLIN*infections - disease - ideaths - passages[0])*dt; @@ -159,6 +126,15 @@ DEATHS += disease*dt; // cumulative deaths due to disease NOISE += dw; + // check for violations of positivity constraints + // nonzero COUNT variable signals violation + if (SUSCEP < 0.0) { COUNT += 1; return;} + if (INFECT < 0.0) { COUNT += 1e3; return;} + if (RSHORT < 0.0) { COUNT += 1e6; return;} + if (DEATHS < 0.0) { COUNT += 1e9; return;} + for (j = 0; j < nrstage; j++) + if ((&RLONG)[j] < 0.0) { COUNT += 1e12; return;} + } #undef GAMMA Modified: pkg/pomp/tests/dacca.R =================================================================== --- pkg/pomp/tests/dacca.R 2014-02-27 02:20:24 UTC (rev 886) +++ pkg/pomp/tests/dacca.R 2014-03-02 14:10:33 UTC (rev 887) @@ -14,3 +14,45 @@ pf <- pfilter(dacca,Np=1000,seed=5886855L) print(round(logLik(pf),digits=1)) + +## to investigate the rogue crash: + +dacca.pars <- c("gamma","eps","deltaI","beta.trend", + "log.beta1","log.beta2","log.beta3", + "log.beta4","log.beta5","log.beta6", + "log.omega1","log.omega2","log.omega3", + "log.omega4","log.omega5","log.omega6", + "sd.beta","tau") +dacca.ivps <- c("S.0","I.0","R1.0","R2.0","R3.0") +dacca.rw.sd <- c( + rep(0.1,length(dacca.pars)), + rep(0.2,length(dacca.ivps)) + ) +names(dacca.rw.sd) <- c(dacca.pars,dacca.ivps) + +param.tab <- read.csv2(text=' +"";"gamma";"eps";"rho";"delta";"deltaI";"clin";"alpha";"beta.trend";"log.beta1";"log.beta2";"log.beta3";"log.beta4";"log.beta5";"log.beta6";"log.omega1";"log.omega2";"log.omega3";"log.omega4";"log.omega5";"log.omega6";"sd.beta";"tau";"S.0";"I.0";"Rs.0";"R1.0";"R2.0";"R3.0";"nbasis";"nrstage" +"mle1";20,8;19,1;0;0,02;0,06;1;1;-0,00498;0,747;6,38;-3,44;4,23;3,33;4,55;-1,6928195214;-2,5433835795;-2,8404393891;-4,6918179927;-8,4779724783;-4,3900588064;3,13;0,23;0,621;0,378;0;0,000843;0,000972;1,16e-07;6;3 +"box_min";10;0,2;0;0,02;0,03;1;1;-0,01;-4;0;-4;0;0;0;-10;-10;-10;-10;-10;-10;1;0,1;0;0;0;0;0;0;6;3 +"box_max";40;30;0;0,02;0,6;1;1;0;4;8;4;8;8;8;0;0;0;0;0;0;5;0,5;1;1;0;1;1;1;6;3 +', + row.names=1 + ) + +dacca.hyperparams <- list( + min=unlist(param.tab["box_min",]), + max=unlist(param.tab["box_max",]) + ) +dacca.rprior <- function (hyperparams, ...) { + r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) + names(r) <- names(hyperparams$min) + r +} + +set.seed(7777+7) +params.tricky <- dacca.rprior(dacca.hyperparams) +m7 <- mif(dacca,Nmif=2,start=params.tricky,pars=dacca.pars,ivps=dacca.ivps, + Np=100,ic.lag=600,method="mif2",rw.sd=dacca.rw.sd, + cooling.type="geometric",cooling.fraction=sqrt(0.1),var.factor=2, + transform=TRUE) +m7 <- continue(m7) Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2014-02-27 02:20:24 UTC (rev 886) +++ pkg/pomp/tests/dacca.Rout.save 2014-03-02 14:10:33 UTC (rev 887) @@ -1,6 +1,6 @@ -R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" -Copyright (C) 2013 The R Foundation for Statistical Computing +R Under development (unstable) (2014-02-22 r65060) -- "Unsuffered Consequences" +Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -47,8 +47,52 @@ > > pf <- pfilter(dacca,Np=1000,seed=5886855L) > print(round(logLik(pf),digits=1)) -[1] -3747.5 +[1] -3748.6 > +> ## to investigate the rogue crash: +> +> dacca.pars <- c("gamma","eps","deltaI","beta.trend", ++ "log.beta1","log.beta2","log.beta3", ++ "log.beta4","log.beta5","log.beta6", ++ "log.omega1","log.omega2","log.omega3", ++ "log.omega4","log.omega5","log.omega6", ++ "sd.beta","tau") +> dacca.ivps <- c("S.0","I.0","R1.0","R2.0","R3.0") +> dacca.rw.sd <- c( ++ rep(0.1,length(dacca.pars)), ++ rep(0.2,length(dacca.ivps)) ++ ) +> names(dacca.rw.sd) <- c(dacca.pars,dacca.ivps) +> +> param.tab <- read.csv2(text=' ++ "";"gamma";"eps";"rho";"delta";"deltaI";"clin";"alpha";"beta.trend";"log.beta1";"log.beta2";"log.beta3";"log.beta4";"log.beta5";"log.beta6";"log.omega1";"log.omega2";"log.omega3";"log.omega4";"log.omega5";"log.omega6";"sd.beta";"tau";"S.0";"I.0";"Rs.0";"R1.0";"R2.0";"R3.0";"nbasis";"nrstage" ++ "mle1";20,8;19,1;0;0,02;0,06;1;1;-0,00498;0,747;6,38;-3,44;4,23;3,33;4,55;-1,6928195214;-2,5433835795;-2,8404393891;-4,6918179927;-8,4779724783;-4,3900588064;3,13;0,23;0,621;0,378;0;0,000843;0,000972;1,16e-07;6;3 ++ "box_min";10;0,2;0;0,02;0,03;1;1;-0,01;-4;0;-4;0;0;0;-10;-10;-10;-10;-10;-10;1;0,1;0;0;0;0;0;0;6;3 ++ "box_max";40;30;0;0,02;0,6;1;1;0;4;8;4;8;8;8;0;0;0;0;0;0;5;0,5;1;1;0;1;1;1;6;3 ++ ', ++ row.names=1 ++ ) +> +> dacca.hyperparams <- list( ++ min=unlist(param.tab["box_min",]), ++ max=unlist(param.tab["box_max",]) ++ ) +> dacca.rprior <- function (hyperparams, ...) { ++ r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) ++ names(r) <- names(hyperparams$min) ++ r ++ } +> +> set.seed(7777+7) +> params.tricky <- dacca.rprior(dacca.hyperparams) +> m7 <- mif(dacca,Nmif=2,start=params.tricky,pars=dacca.pars,ivps=dacca.ivps, ++ Np=100,ic.lag=600,method="mif2",rw.sd=dacca.rw.sd, ++ cooling.type="geometric",cooling.fraction=sqrt(0.1),var.factor=2, ++ transform=TRUE) +Warning message: +1 filtering failure occurred in 'pfilter' +> m7 <- continue(m7) +> > proc.time() user system elapsed - 3.492 0.048 3.555 + 8.056 0.044 8.137 From noreply at r-forge.r-project.org Sun Mar 9 17:31:46 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 9 Mar 2014 17:31:46 +0100 (CET) Subject: [Pomp-commits] r888 - in pkg/pomp: . inst src tests Message-ID: <20140309163146.3387D183C61@r-forge.r-project.org> Author: kingaa Date: 2014-03-09 17:31:45 +0100 (Sun, 09 Mar 2014) New Revision: 888 Modified: pkg/pomp/DESCRIPTION pkg/pomp/inst/NEWS pkg/pomp/src/cholmodel.c pkg/pomp/tests/dacca.R pkg/pomp/tests/dacca.Rout.save Log: - in 'dacca' model, positivity violations are now treated a bit differently Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-02 14:10:33 UTC (rev 887) +++ pkg/pomp/DESCRIPTION 2014-03-09 16:31:45 UTC (rev 888) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.47-3 -Date: 2014-03-01 +Version: 0.47-4 +Date: 2014-03-09 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-03-02 14:10:33 UTC (rev 887) +++ pkg/pomp/inst/NEWS 2014-03-09 16:31:45 UTC (rev 888) @@ -1,4 +1,7 @@ NEWS +0.47-4 + o Revisit 'dacca' bug. Set negative compartments to zero along with compartments immediately downstream. + 0.47-3 o Fix bug that arises only very occasionally in the 'dacca' cholera example. Modified: pkg/pomp/src/cholmodel.c =================================================================== --- pkg/pomp/src/cholmodel.c 2014-03-02 14:10:33 UTC (rev 887) +++ pkg/pomp/src/cholmodel.c 2014-03-09 16:31:45 UTC (rev 888) @@ -89,7 +89,7 @@ double beta; double omega; double dw; - const double *pt; + double *pt; int j; if (COUNT != 0.0) return; @@ -110,9 +110,9 @@ rsdeaths = DELTA*RSHORT; // natural Rs deaths wanings = RHO*RSHORT; // loss of immunity - for (pt = &RLONG, j = 0; j < nrstage; j++) { - rldeaths[j] = DELTA*pt[j]; // natural R deaths - passages[j+1] = eps*pt[j]; // passage to the next immunity class + for (pt = &RLONG, j = 0; j < nrstage; j++, pt++) { + rldeaths[j] = *pt*DELTA; // natural R deaths + passages[j+1] = *pt*eps; // passage to the next immunity class } infections = (omega+(beta+SD_BETA*dw/dt)*effI)*SUSCEP; // infection @@ -121,20 +121,39 @@ SUSCEP += (births - infections - sdeaths + passages[nrstage] + wanings)*dt; INFECT += (CLIN*infections - disease - ideaths - passages[0])*dt; RSHORT += ((1-CLIN)*infections - rsdeaths - wanings)*dt; - for (j = 0; j < nrstage; j++) - (&RLONG)[j] += (passages[j] - passages[j+1] - rldeaths[j])*dt; + for (pt = &RLONG, j = 0; j < nrstage; j++, pt++) + *pt += (passages[j] - passages[j+1] - rldeaths[j])*dt; DEATHS += disease*dt; // cumulative deaths due to disease NOISE += dw; // check for violations of positivity constraints // nonzero COUNT variable signals violation - if (SUSCEP < 0.0) { COUNT += 1; return;} - if (INFECT < 0.0) { COUNT += 1e3; return;} - if (RSHORT < 0.0) { COUNT += 1e6; return;} - if (DEATHS < 0.0) { COUNT += 1e9; return;} - for (j = 0; j < nrstage; j++) - if ((&RLONG)[j] < 0.0) { COUNT += 1e12; return;} - + if (SUSCEP < 0.0) { + SUSCEP = 0.0; INFECT = 0.0; RSHORT = 0.0; + COUNT += 1; + } + if (INFECT < 0.0) { + INFECT = 0.0; SUSCEP = 0.0; + COUNT += 1e3; + } + if (RSHORT < 0.0) { + RSHORT = 0.0; SUSCEP = 0.0; + COUNT += 1e6; + } + if (DEATHS < 0.0) { + DEATHS = 0.0; + COUNT += 1e9; + } + for (pt = &RLONG, j = 0; j < nrstage-1; j++, pt++) { + if (*pt < 0.0) { + *pt = 0.0; *(pt+1) = 0.0; + COUNT += 1e12; + } + } + if (*pt < 0.0) { + *pt = 0.0; SUSCEP = 0.0; + COUNT += 1e12; + } } #undef GAMMA Modified: pkg/pomp/tests/dacca.R =================================================================== --- pkg/pomp/tests/dacca.R 2014-03-02 14:10:33 UTC (rev 887) +++ pkg/pomp/tests/dacca.R 2014-03-09 16:31:45 UTC (rev 888) @@ -43,6 +43,7 @@ min=unlist(param.tab["box_min",]), max=unlist(param.tab["box_max",]) ) + dacca.rprior <- function (hyperparams, ...) { r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) names(r) <- names(hyperparams$min) @@ -51,8 +52,35 @@ set.seed(7777+7) params.tricky <- dacca.rprior(dacca.hyperparams) -m7 <- mif(dacca,Nmif=2,start=params.tricky,pars=dacca.pars,ivps=dacca.ivps, - Np=100,ic.lag=600,method="mif2",rw.sd=dacca.rw.sd, - cooling.type="geometric",cooling.fraction=sqrt(0.1),var.factor=2, - transform=TRUE) +m7 <- mif( + dacca, + Nmif=2, + start=params.tricky, + pars=dacca.pars, + ivps=dacca.ivps, + Np=100, + method="mif2", + rw.sd=dacca.rw.sd, + cooling.type="geometric", + cooling.fraction=sqrt(0.1), + var.factor=2, + transform=TRUE + ) m7 <- continue(m7) + +set.seed(12350) +th.draw <- dacca.rprior(dacca.hyperparams) +m1 <- mif( + dacca, + Nmif=10, + Np=100, + start=th.draw, + pars=dacca.pars, + ivps=dacca.ivps, + method="mif2", + rw.sd=dacca.rw.sd, + cooling.type="geometric", + cooling.fraction=sqrt(0.1), + var.factor=2, + transform=TRUE + ) Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2014-03-02 14:10:33 UTC (rev 887) +++ pkg/pomp/tests/dacca.Rout.save 2014-03-09 16:31:45 UTC (rev 888) @@ -1,6 +1,6 @@ -R Under development (unstable) (2014-02-22 r65060) -- "Unsuffered Consequences" -Copyright (C) 2014 The R Foundation for Statistical Computing +R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" +Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. @@ -77,6 +77,7 @@ + min=unlist(param.tab["box_min",]), + max=unlist(param.tab["box_max",]) + ) +> > dacca.rprior <- function (hyperparams, ...) { + r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) + names(r) <- names(hyperparams$min) @@ -85,14 +86,49 @@ > > set.seed(7777+7) > params.tricky <- dacca.rprior(dacca.hyperparams) -> m7 <- mif(dacca,Nmif=2,start=params.tricky,pars=dacca.pars,ivps=dacca.ivps, -+ Np=100,ic.lag=600,method="mif2",rw.sd=dacca.rw.sd, -+ cooling.type="geometric",cooling.fraction=sqrt(0.1),var.factor=2, -+ transform=TRUE) -Warning message: -1 filtering failure occurred in 'pfilter' +> m7 <- mif( ++ dacca, ++ Nmif=2, ++ start=params.tricky, ++ pars=dacca.pars, ++ ivps=dacca.ivps, ++ Np=100, ++ method="mif2", ++ rw.sd=dacca.rw.sd, ++ cooling.type="geometric", ++ cooling.fraction=sqrt(0.1), ++ var.factor=2, ++ transform=TRUE ++ ) +Warning messages: +1: 11 filtering failures occurred in 'pfilter' +2: 4 filtering failures occurred in 'pfilter' > m7 <- continue(m7) > +> set.seed(12350) +> th.draw <- dacca.rprior(dacca.hyperparams) +> m1 <- mif( ++ dacca, ++ Nmif=10, ++ Np=100, ++ start=th.draw, ++ pars=dacca.pars, ++ ivps=dacca.ivps, ++ method="mif2", ++ rw.sd=dacca.rw.sd, ++ cooling.type="geometric", ++ cooling.fraction=sqrt(0.1), ++ var.factor=2, ++ transform=TRUE ++ ) +Warning messages: +1: 1 filtering failure occurred in 'pfilter' +2: 16 filtering failures occurred in 'pfilter' +3: 2 filtering failures occurred in 'pfilter' +4: 2 filtering failures occurred in 'pfilter' +5: 1 filtering failure occurred in 'pfilter' +6: 7 filtering failures occurred in 'pfilter' +> > proc.time() user system elapsed - 8.056 0.044 8.137 + 28.417 0.076 28.599 From noreply at r-forge.r-project.org Mon Mar 10 14:38:56 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 10 Mar 2014 14:38:56 +0100 (CET) Subject: [Pomp-commits] r889 - in pkg/pomp: . inst/examples src tests Message-ID: <20140310133856.B7292187034@r-forge.r-project.org> Author: kingaa Date: 2014-03-10 14:38:56 +0100 (Mon, 10 Mar 2014) New Revision: 889 Modified: pkg/pomp/DESCRIPTION pkg/pomp/inst/examples/dacca.R pkg/pomp/src/cholmodel.c pkg/pomp/tests/dacca.R pkg/pomp/tests/dacca.Rout.save Log: - put parameter transforms into C (3X speedup) Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-09 16:31:45 UTC (rev 888) +++ pkg/pomp/DESCRIPTION 2014-03-10 13:38:56 UTC (rev 889) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.47-4 -Date: 2014-03-09 +Version: 0.47-5 +Date: 2014-03-10 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/inst/examples/dacca.R =================================================================== --- pkg/pomp/inst/examples/dacca.R 2014-03-09 16:31:45 UTC (rev 888) +++ pkg/pomp/inst/examples/dacca.R 2014-03-10 13:38:56 UTC (rev 889) @@ -122,28 +122,14 @@ statenames = c("S","I","Rs","R1","M","W","count"), paramnames = c("tau","gamma","eps","delta","deltaI", "log.omega1","sd.beta","beta.trend","log.beta1", - "alpha","rho","clin","nbasis","nrstage"), + "alpha","rho","clin","nbasis","nrstage", + "S.0","I.0","Rs.0","R1.0"), covarnames = c("pop","dpopdt","seas.1","trend"), all.state.names=c("S","I","Rs",paste("R",1:nrstage,sep=''),"M","W","count"), comp.names=c("S","I","Rs",paste("R",1:nrstage,sep='')), comp.ic.names=c("S.0","I.0","Rs.0",paste("R",1:nrstage,".0",sep='')), - log.trans=c( # parameters to log transform - "gamma","eps","rho","delta","deltaI","alpha", - "tau","sd.beta", - "S.0","I.0","Rs.0",paste("R",1:nrstage,".0",sep='') - ), - logit.trans="clin", # parameters to logit transform - parameter.transform=function (params, log.trans, logit.trans, comp.ic.names, ...) { - params[logit.trans] <- plogis(params[logit.trans]) - params[log.trans] <- exp(params[log.trans]) - params[comp.ic.names] <- params[comp.ic.names]/sum(params[comp.ic.names]) - params - }, - parameter.inv.transform=function (params, log.trans, logit.trans, comp.names, ...) { - params[logit.trans] <- qlogis(params[logit.trans]) - params[log.trans] <- log(params[log.trans]) - params - }, + parameter.transform="_cholmodel_trans", + parameter.inv.transform="_cholmodel_untrans", initializer = function (params, t0, covars, nrstage, comp.ic.names, comp.names, all.state.names, ...) { states <- numeric(length(all.state.names)) names(states) <- all.state.names Modified: pkg/pomp/src/cholmodel.c =================================================================== --- pkg/pomp/src/cholmodel.c 2014-03-09 16:31:45 UTC (rev 888) +++ pkg/pomp/src/cholmodel.c 2014-03-10 13:38:56 UTC (rev 889) @@ -18,6 +18,10 @@ #define CLIN (p[parindex[11]]) #define NBASIS (p[parindex[12]]) #define NRSTAGE (p[parindex[13]]) +#define S0 (p[parindex[14]]) +#define I0 (p[parindex[15]]) +#define RS0 (p[parindex[16]]) +#define RL0 (p[parindex[17]]) #define SUSCEP (x[stateindex[0]]) #define INFECT (x[stateindex[1]]) @@ -34,6 +38,52 @@ #define DATADEATHS (y[obsindex[0]]) +void _cholmodel_untrans (double *pt, double *p, int *parindex) +{ + int k, nrstage = (int) NRSTAGE; + pt[parindex[0]] = log(TAU); + pt[parindex[1]] = log(GAMMA); + pt[parindex[2]] = log(EPS); + pt[parindex[3]] = log(DELTA); + pt[parindex[4]] = log(DELTA_I); + pt[parindex[6]] = log(SD_BETA); + pt[parindex[9]] = log(ALPHA); + pt[parindex[10]] = log(RHO); + pt[parindex[11]] = logit(CLIN); + + pt[parindex[14]] = log(S0); + pt[parindex[15]] = log(I0); + pt[parindex[16]] = log(RS0); + for (k = 0; k < nrstage; k++) + pt[parindex[17]+k] = log((&RL0)[k]); +} + +void _cholmodel_trans (double *pt, double *p, int *parindex) +{ + int k, nrstage = (int) NRSTAGE; + double sum = 0.0; + pt[parindex[0]] = exp(TAU); + pt[parindex[1]] = exp(GAMMA); + pt[parindex[2]] = exp(EPS); + pt[parindex[3]] = exp(DELTA); + pt[parindex[4]] = exp(DELTA_I); + pt[parindex[6]] = exp(SD_BETA); + pt[parindex[9]] = exp(ALPHA); + pt[parindex[10]] = exp(RHO); + pt[parindex[11]] = expit(CLIN); + + sum += (pt[parindex[14]] = exp(S0)); + sum += (pt[parindex[15]] = exp(I0)); + sum += (pt[parindex[16]] = exp(RS0)); + for (k = 0; k < nrstage; k++) + sum += (pt[parindex[17]+k] = exp((&RL0)[k])); + pt[parindex[14]] /= sum; + pt[parindex[15]] /= sum; + pt[parindex[16]] /= sum; + for (k = 0; k < nrstage; k++) + pt[parindex[17]+k] /= sum; +} + void _cholmodel_norm_rmeasure (double *y, double *x, double *p, int *obsindex, int *stateindex, int *parindex, int *covindex, int ncovars, double *covars, double t) Modified: pkg/pomp/tests/dacca.R =================================================================== --- pkg/pomp/tests/dacca.R 2014-03-09 16:31:45 UTC (rev 888) +++ pkg/pomp/tests/dacca.R 2014-03-10 13:38:56 UTC (rev 889) @@ -15,6 +15,9 @@ pf <- pfilter(dacca,Np=1000,seed=5886855L) print(round(logLik(pf),digits=1)) +pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) +print(round(logLik(pf1),digits=1)) + ## to investigate the rogue crash: dacca.pars <- c("gamma","eps","deltaI","beta.trend", Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2014-03-09 16:31:45 UTC (rev 888) +++ pkg/pomp/tests/dacca.Rout.save 2014-03-10 13:38:56 UTC (rev 889) @@ -1,5 +1,5 @@ -R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" +R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -49,6 +49,10 @@ > print(round(logLik(pf),digits=1)) [1] -3748.6 > +> pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) +> print(round(logLik(pf1),digits=1)) +[1] -3701.5 +> > ## to investigate the rogue crash: > > dacca.pars <- c("gamma","eps","deltaI","beta.trend", @@ -131,4 +135,4 @@ > > proc.time() user system elapsed - 28.417 0.076 28.599 + 36.898 0.108 37.070 From noreply at r-forge.r-project.org Tue Mar 11 14:23:39 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 11 Mar 2014 14:23:39 +0100 (CET) Subject: [Pomp-commits] r890 - www/vignettes Message-ID: <20140311132339.A3887186E47@r-forge.r-project.org> Author: kingaa Date: 2014-03-11 14:23:39 +0100 (Tue, 11 Mar 2014) New Revision: 890 Modified: www/vignettes/intro_to_pomp.R www/vignettes/intro_to_pomp.Rnw www/vignettes/intro_to_pomp.pdf Log: - put in note regarding necessity of using compiled codes Modified: www/vignettes/intro_to_pomp.R =================================================================== --- www/vignettes/intro_to_pomp.R 2014-03-10 13:38:56 UTC (rev 889) +++ www/vignettes/intro_to_pomp.R 2014-03-11 13:23:39 UTC (rev 890) @@ -110,7 +110,7 @@ ################################################### -### code chunk number 9: intro_to_pomp.Rnw:326-327 (eval = FALSE) +### code chunk number 9: intro_to_pomp.Rnw:327-328 (eval = FALSE) ################################################### ## plot(gompertz,variables="Y") @@ -239,13 +239,13 @@ ################################################### -### code chunk number 21: intro_to_pomp.Rnw:465-466 (eval = FALSE) +### code chunk number 21: intro_to_pomp.Rnw:466-467 (eval = FALSE) ################################################### ## as(gompertz,"data.frame") ################################################### -### code chunk number 22: intro_to_pomp.Rnw:470-473 (eval = FALSE) +### code chunk number 22: intro_to_pomp.Rnw:471-474 (eval = FALSE) ################################################### ## obs(gompertz) ## obs(gompertz,"Y") @@ -253,40 +253,40 @@ ################################################### -### code chunk number 23: intro_to_pomp.Rnw:476-477 (eval = FALSE) +### code chunk number 23: intro_to_pomp.Rnw:477-478 (eval = FALSE) ################################################### ## time(gompertz) <- 1:10 ################################################### -### code chunk number 24: intro_to_pomp.Rnw:480-482 (eval = FALSE) +### code chunk number 24: intro_to_pomp.Rnw:481-483 (eval = FALSE) ################################################### ## timezero(gompertz) ## timezero(gompertz) <- -10 ################################################### -### code chunk number 25: intro_to_pomp.Rnw:485-487 (eval = FALSE) +### code chunk number 25: intro_to_pomp.Rnw:486-488 (eval = FALSE) ################################################### ## time(gompertz,t0=TRUE) ## time(gompertz,t0=T) <- seq(from=0,to=10,by=1) ################################################### -### code chunk number 26: intro_to_pomp.Rnw:490-491 (eval = FALSE) +### code chunk number 26: intro_to_pomp.Rnw:491-492 (eval = FALSE) ################################################### ## window(gompertz,start=3,end=20) ################################################### -### code chunk number 27: intro_to_pomp.Rnw:495-497 (eval = FALSE) +### code chunk number 27: intro_to_pomp.Rnw:496-498 (eval = FALSE) ################################################### ## coef(gompertz) ## coef(gompertz,c("sigma","tau")) <- c(1,0) ################################################### -### code chunk number 28: intro_to_pomp.Rnw:501-503 (eval = FALSE) +### code chunk number 28: intro_to_pomp.Rnw:502-504 (eval = FALSE) ################################################### ## states(gompertz) ## states(gompertz,"X") @@ -307,32 +307,32 @@ ################################################### -### code chunk number 30: intro_to_pomp.Rnw:542-543 +### code chunk number 30: intro_to_pomp.Rnw:543-544 ################################################### coef(gompertz) <- c(r=0.1,K=1,tau=0.1,sigma=0.1,X.0=1) ################################################### -### code chunk number 31: intro_to_pomp.Rnw:546-547 +### code chunk number 31: intro_to_pomp.Rnw:547-548 ################################################### coef(gompertz) ################################################### -### code chunk number 32: intro_to_pomp.Rnw:550-552 +### code chunk number 32: intro_to_pomp.Rnw:551-553 ################################################### coef(gompertz,transform=TRUE) <- c(r=log(0.1),K=0,tau=log(0.1), sigma=log(0.1),X.0=0) ################################################### -### code chunk number 33: intro_to_pomp.Rnw:555-556 +### code chunk number 33: intro_to_pomp.Rnw:556-557 ################################################### coef(gompertz,transform=TRUE) ################################################### -### code chunk number 34: intro_to_pomp.Rnw:559-560 +### code chunk number 34: intro_to_pomp.Rnw:560-561 ################################################### coef(gompertz) @@ -351,13 +351,13 @@ ################################################### -### code chunk number 36: intro_to_pomp.Rnw:580-581 (eval = FALSE) +### code chunk number 36: intro_to_pomp.Rnw:581-582 (eval = FALSE) ################################################### ## demo(gompertz) ################################################### -### code chunk number 37: intro_to_pomp.Rnw:608-611 +### code chunk number 37: intro_to_pomp.Rnw:609-612 ################################################### pompExample(gompertz) theta <- coef(gompertz) @@ -465,7 +465,7 @@ ################################################### -### code chunk number 41: intro_to_pomp.Rnw:685-686 (eval = FALSE) +### code chunk number 41: intro_to_pomp.Rnw:686-687 (eval = FALSE) ################################################### ## theta.true <- coef(gompertz) ## theta.mif <- apply(sapply(mf,coef),1,mean) @@ -924,7 +924,7 @@ ################################################### -### code chunk number 69: intro_to_pomp.Rnw:1120-1121 +### code chunk number 69: intro_to_pomp.Rnw:1121-1122 ################################################### fits @@ -1109,7 +1109,7 @@ ################################################### -### code chunk number 77: intro_to_pomp.Rnw:1266-1267 +### code chunk number 77: intro_to_pomp.Rnw:1267-1268 ################################################### apply(fvals,2,function(x)sd(x)/mean(x)) @@ -1151,7 +1151,7 @@ ################################################### -### code chunk number 80: intro_to_pomp.Rnw:1305-1306 +### code chunk number 80: intro_to_pomp.Rnw:1306-1307 ################################################### set.seed(32329L) @@ -1221,7 +1221,7 @@ ################################################### -### code chunk number 83: intro_to_pomp.Rnw:1343-1344 +### code chunk number 83: intro_to_pomp.Rnw:1344-1345 ################################################### apply(pars,2,sd) Modified: www/vignettes/intro_to_pomp.Rnw =================================================================== --- www/vignettes/intro_to_pomp.Rnw 2014-03-10 13:38:56 UTC (rev 889) +++ www/vignettes/intro_to_pomp.Rnw 2014-03-11 13:23:39 UTC (rev 890) @@ -190,8 +190,9 @@ The documentation (\code{?pomp}) spells out the usage of the \code{pomp} constructor, including detailed specifications for all its arguments and a worked example. Let's see how to implement the Gompertz model in \pkg{pomp}. -Here, we'll take the shortest path to this goal. +Here, we'll take the shortest path to this goal, defining the necessary functions directly in \pkg{R}. In the ``Advanced topics in \pkg{pomp}'' vignette, we show how one can make the codes much more efficient using compiled native (C or FORTRAN) code. +\textbf{NB: For all but the very simplest models, it is almost always necessary to use compiled native codes to make the computationally intensive algorithms in \pkg{pomp} fast enough to be useful in practice.} First, we write a function that implements the process model simulator. This is a function that will simulate a single step ($t\to{t+{\Delta}t}$) of the unobserved process \eqref{eq:gompertz1}. Modified: www/vignettes/intro_to_pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Sun Mar 16 22:57:33 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 16 Mar 2014 22:57:33 +0100 (CET) Subject: [Pomp-commits] r891 - in pkg/pomp: . R demo inst inst/include man src tests Message-ID: <20140316215734.17791186A5E@r-forge.r-project.org> Author: kingaa Date: 2014-03-16 22:57:33 +0100 (Sun, 16 Mar 2014) New Revision: 891 Added: pkg/pomp/R/dprior-pomp.R pkg/pomp/R/rprior-pomp.R pkg/pomp/man/prior-pomp.Rd pkg/pomp/src/dprior.c pkg/pomp/src/rprior.c pkg/pomp/tests/prior.R pkg/pomp/tests/prior.Rout.save Modified: pkg/pomp/DESCRIPTION pkg/pomp/NAMESPACE pkg/pomp/R/aaa.R pkg/pomp/R/abc-methods.R pkg/pomp/R/abc.R pkg/pomp/R/bsmc.R pkg/pomp/R/mif-methods.R pkg/pomp/R/mif.R pkg/pomp/R/pmcmc.R pkg/pomp/R/pomp-class.R pkg/pomp/R/pomp-methods.R pkg/pomp/R/pomp.R pkg/pomp/R/rmeasure-pomp.R pkg/pomp/demo/sir.R pkg/pomp/inst/NEWS pkg/pomp/inst/include/pomp.h pkg/pomp/man/abc.Rd pkg/pomp/man/bsmc.Rd pkg/pomp/man/pmcmc-methods.Rd pkg/pomp/man/pmcmc.Rd pkg/pomp/man/pomp-class.Rd pkg/pomp/man/pomp.Rd pkg/pomp/src/pomp.h pkg/pomp/tests/abc.R pkg/pomp/tests/abc.Rout.save pkg/pomp/tests/bbs-trajmatch.Rout.save pkg/pomp/tests/bbs.R pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/blowflies.Rout.save pkg/pomp/tests/dacca.R pkg/pomp/tests/dacca.Rout.save pkg/pomp/tests/dimchecks.Rout.save pkg/pomp/tests/fhn.Rout.save pkg/pomp/tests/filtfail.Rout.save pkg/pomp/tests/gillespie.Rout.save pkg/pomp/tests/gompertz.Rout.save pkg/pomp/tests/logistic.Rout.save pkg/pomp/tests/ou2-bsmc.R pkg/pomp/tests/ou2-bsmc.Rout.save pkg/pomp/tests/ou2-forecast.Rout.save pkg/pomp/tests/ou2-icfit.R pkg/pomp/tests/ou2-icfit.Rout.save pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/ou2-mif-fp.R pkg/pomp/tests/ou2-mif-fp.Rout.save pkg/pomp/tests/ou2-mif.R pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/ou2-mif2.R pkg/pomp/tests/ou2-mif2.Rout.save pkg/pomp/tests/ou2-nlf.Rout.save pkg/pomp/tests/ou2-pmcmc.R pkg/pomp/tests/ou2-pmcmc.Rout.save pkg/pomp/tests/ou2-probe.Rout.save pkg/pomp/tests/ou2-procmeas.Rout.save pkg/pomp/tests/ou2-simulate.Rout.save pkg/pomp/tests/ou2-trajmatch.Rout.save pkg/pomp/tests/partrans.Rout.save pkg/pomp/tests/pfilter.Rout.save pkg/pomp/tests/pomppomp.Rout.save pkg/pomp/tests/ricker-bsmc.R pkg/pomp/tests/ricker-bsmc.Rout.save pkg/pomp/tests/ricker-probe.R pkg/pomp/tests/ricker-probe.Rout.save pkg/pomp/tests/ricker-spect.Rout.save pkg/pomp/tests/ricker.Rout.save pkg/pomp/tests/rw2.Rout.save pkg/pomp/tests/sir.Rout.save pkg/pomp/tests/skeleton.Rout.save pkg/pomp/tests/steps.Rout.save pkg/pomp/tests/synlik.Rout.save pkg/pomp/tests/verhulst.Rout.save Log: - new 'rprior' and 'dprior' slots in 'pomp' objects - use environment variable POMP_FULL_TESTS to suppress some test-script execution - change in 'bsmc' interface: now 'rprior' is used Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/DESCRIPTION 2014-03-16 21:57:33 UTC (rev 891) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.47-5 -Date: 2014-03-10 +Version: 0.48-1 +Date: 2014-03-16 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), @@ -29,6 +29,7 @@ pomp-fun.R pomp-class.R pomp.R pomp-methods.R rmeasure-pomp.R rprocess-pomp.R init-state-pomp.R dmeasure-pomp.R dprocess-pomp.R skeleton-pomp.R + dprior-pomp.R rprior-pomp.R simulate-pomp.R trajectory-pomp.R plot-pomp.R pfilter.R pfilter-methods.R traj-match.R bsmc.R mif-class.R particles-mif.R mif.R mif-methods.R compare-mif.R Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/NAMESPACE 2014-03-16 21:57:33 UTC (rev 891) @@ -25,6 +25,8 @@ do_dprocess, do_rmeasure, do_dmeasure, + do_rprior, + do_dprior, do_skeleton, do_init_state ) @@ -51,15 +53,15 @@ pomp, plot,show,print,coerce,summary,logLik,window,"$", dprocess,rprocess,rmeasure,dmeasure,init.state,skeleton, - data.array,obs,partrans,coef,"coef<-",time,"time<-",timezero,"timezero<-", + dprior,rprior, + data.array,obs,partrans,coef,"coef<-", + time,"time<-",timezero,"timezero<-", simulate,pfilter, eff.sample.size,cond.logLik, particles,mif,continue,states,trajectory, pred.mean,pred.var,filter.mean,conv.rec, - bsmc, - pmcmc,dprior, - spect,probe, - probe.match,abc, + bsmc,pmcmc,abc, + spect,probe,probe.match, traj.match ) Modified: pkg/pomp/R/aaa.R =================================================================== --- pkg/pomp/R/aaa.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/aaa.R 2014-03-16 21:57:33 UTC (rev 891) @@ -19,6 +19,7 @@ setGeneric("filter.mean",function(object,...)standardGeneric("filter.mean")) setGeneric("cond.logLik",function(object,...)standardGeneric("cond.logLik")) setGeneric("eff.sample.size",function(object,...)standardGeneric("eff.sample.size")) +setGeneric("conv.rec",function(object,...)standardGeneric("conv.rec")) if (!exists("paste0",where="package:base")) { paste0 <- function(...) paste(...,sep="") Modified: pkg/pomp/R/abc-methods.R =================================================================== --- pkg/pomp/R/abc-methods.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/abc-methods.R 2014-03-16 21:57:33 UTC (rev 891) @@ -23,18 +23,3 @@ } } ) - -setMethod( - "dprior", - signature=signature(object="abc"), - function (object, params, log = FALSE, ...) { - do.call( - object at dprior, - list( - params=params, - hyperparams=object at hyperparams, - log=log - ) - ) - } - ) Modified: pkg/pomp/R/abc.R =================================================================== --- pkg/pomp/R/abc.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/abc.R 2014-03-16 21:57:33 UTC (rev 891) @@ -6,11 +6,9 @@ pars = 'character', transform = 'logical', Nabc = 'integer', - dprior = 'function', probes='list', scale = 'numeric', epsilon = 'numeric', - hyperparams = 'list', random.walk.sd = 'numeric', conv.rec = 'matrix' ) @@ -20,19 +18,20 @@ setGeneric('abc',function(object,...)standardGeneric("abc")) abc.internal <- function (object, Nabc, - start, pars, dprior.fun, + start, pars, rw.sd, probes, - hyperparams, epsilon, scale, verbose, transform, - .ndone, .getnativesymbolinfo = TRUE, + .ndone = 0L, + .getnativesymbolinfo = TRUE, ...) { + object <- as(object,'pomp') gnsi <- as.logical(.getnativesymbolinfo) - transform <- as.logical(transform) - Nabc <- as.integer(Nabc) + epsilon <- as.numeric(epsilon) + epssq <- epsilon*epsilon if (length(start)==0) stop( @@ -64,7 +63,7 @@ stop( "abc error: ", sQuote("pars"), - " must be a mutually disjoint subset of ", + " must be a subset of ", sQuote("names(start)"), " and must correspond to positive random-walk SDs specified in ", sQuote("rw.sd"), @@ -101,7 +100,7 @@ } theta <- start - log.prior <- dprior.fun(params=theta,hyperparams=hyperparams,log=TRUE) + log.prior <- dprior(object,params=theta,log=TRUE) ## we suppose that theta is a "match", which does the right thing for continue() and ## should have negligible effect unless doing many short calls to continue() @@ -161,8 +160,8 @@ ## ABC update rule distance <- sum(((datval-simval)/scale)^2) - if( (is.finite(distance)) && (distance0] - } if (missing(probes)) stop("abc error: ",sQuote("probes")," must be specified",call.=FALSE) @@ -222,41 +217,19 @@ stop("abc error: ",sQuote("scale")," must be specified",call.=FALSE) if (missing(epsilon)) - stop("abc error: ",sQuote("abc match criterion, epsilon,")," must be specified",call.=FALSE) + stop("abc error: abc match criterion, ",sQuote("epsilon"),", must be specified",call.=FALSE) - if (missing(hyperparams)) - stop("abc error: ",sQuote("hyperparams")," must be specified",call.=FALSE) - - if (missing(dprior)) { # use default flat improper prior - dprior <- function (params, hyperparams, log) { - if (log) 0 else 1 - } - } else { - dprior <- match.fun(dprior) - if (!all(c('params','hyperparams','log')%in%names(formals(dprior)))) - stop( - "abc error: ", - sQuote("dprior"), - " must be a function of prototype ", - sQuote("dprior(params,hyperparams,log)"), - call.=FALSE - ) - } - abc.internal( object=object, Nabc=Nabc, start=start, pars=pars, - dprior.fun=dprior, probes=probes, scale=scale, epsilon=epsilon, rw.sd=rw.sd, - hyperparams=hyperparams, verbose=verbose, - transform=transform, - .ndone=0 + transform=transform ) } ) @@ -264,62 +237,19 @@ setMethod( "abc", signature=signature(object="probed.pomp"), - function (object, Nabc = 1, - start, pars, rw.sd, - dprior, probes, scale, epsilon, hyperparams, + function (object, probes, verbose = getOption("verbose"), transform = FALSE, ...) { - transform <- as.logical(transform) - - if (missing(start)) start <- coef(object,transform=transform) - - if (missing(rw.sd)) - stop("abc error: ",sQuote("rw.sd")," must be specified",call.=FALSE) - - if (missing(pars)) { - pars <- names(rw.sd)[rw.sd>0] - } - if (missing(probes)) probes <- object at probes - if (missing(scale)) probes <- object at scale - if (missing(epsilon)) probes <- object at epsilon - if (missing(hyperparams)) - stop("abc error: ",sQuote("hyperparams")," must be specified",call.=FALSE) - - if (missing(dprior)) { # use default flat improper prior - dprior <- function (params, hyperparams, log) { - if (log) 0 else 1 - } - } else { - dprior <- match.fun(dprior) - if (!all(c('params','hyperparams','log')%in%names(formals(dprior)))) - stop( - "abc error: ", - sQuote("dprior"), - " must be a function of prototype ", - sQuote("dprior(params,hyperparams,log)"), - call.=FALSE - ) - } - - abc.internal( - object=as(object,"pomp"), - Nabc=Nabc, - start=start, - pars=pars, - dprior.fun=dprior, - probes=probes, - scale=scale, - epsilon=epsilon, - rw.sd=rw.sd, - hyperparams=hyperparams, - verbose=verbose, - transform=transform, - .ndone=0 - ) + abc( + object=as(object,"pomp"), + probes=probes, + transform=transform, + ... + ) } ) @@ -328,7 +258,7 @@ signature=signature(object="abc"), function (object, Nabc, start, pars, rw.sd, - dprior, probes, scale, epsilon, hyperparams, + probes, scale, epsilon, verbose = getOption("verbose"), transform, ...) { @@ -336,30 +266,25 @@ if (missing(Nabc)) Nabc <- object at Nabc if (missing(start)) start <- coef(object) if (missing(pars)) pars <- object at pars - if (missing(rw.sd)) pars <- object at random.walk.sd - if (missing(dprior)) dprior <- object at dprior + if (missing(rw.sd)) rw.sd <- object at random.walk.sd if (missing(probes)) probes <- object at probes - if (missing(scale)) probes <- object at scale - if (missing(epsilon)) probes <- object at epsilon - if (missing(hyperparams)) hyperparams <- object at hyperparams + if (missing(scale)) scale <- object at scale + if (missing(epsilon)) epsilon <- object at epsilon if (missing(transform)) transform <- object at transform - transform <- as.logical(transform) - abc.internal( - object=as(object,"pomp"), - Nabc=Nabc, - start=start, - pars=pars, - dprior.fun=dprior, - rw.sd=rw.sd, - probes=probes, - scale=scale, - epsilon=epsilon, - hyperparams=hyperparams, - verbose=verbose, - transform=transform, - .ndone=0 - ) + abc( + object=as(object,"pomp"), + Nabc=Nabc, + start=start, + pars=pars, + rw.sd=rw.sd, + probes=probes, + scale=scale, + epsilon=epsilon, + verbose=verbose, + transform=transform, + ... + ) } ) @@ -382,6 +307,7 @@ obj at conv.rec[-1,] ) obj at Nabc <- as.integer(ndone+Nabc) + obj } ) Modified: pkg/pomp/R/bsmc.R =================================================================== --- pkg/pomp/R/bsmc.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/bsmc.R 2014-03-16 21:57:33 UTC (rev 891) @@ -68,6 +68,9 @@ if (missing(Np)) Np <- NCOL(params) else if (is.matrix(params)&&(Np!=ncol(params))) warning(sQuote("Np")," is ignored when ",sQuote("params")," is a matrix") + + if ((!is.matrix(params)) && (Np > 1)) + params <- rprior(object,params=parmat(params,Np)) if (transform) params <- partrans(object,params,dir="inverse", Added: pkg/pomp/R/dprior-pomp.R =================================================================== --- pkg/pomp/R/dprior-pomp.R (rev 0) +++ pkg/pomp/R/dprior-pomp.R 2014-03-16 21:57:33 UTC (rev 891) @@ -0,0 +1,12 @@ +## evaluate the prior probability density +setGeneric("dprior",function(object,...)standardGeneric("dprior")) + +dprior.internal <- function (object, params, log = FALSE, + .getnativesymbolinfo = TRUE, ...) { + .Call(do_dprior,object,params,log,.getnativesymbolinfo) +} + +setMethod("dprior","pomp", + function (object, params, log = FALSE, ...) + dprior.internal(object=object,params=params,log=log,...) + ) Modified: pkg/pomp/R/mif-methods.R =================================================================== --- pkg/pomp/R/mif-methods.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/mif-methods.R 2014-03-16 21:57:33 UTC (rev 891) @@ -38,8 +38,6 @@ } } -setGeneric("conv.rec",function(object,...)standardGeneric("conv.rec")) - setMethod('conv.rec','mif', function (object, pars, transform = FALSE, ...) { conv.rec.internal(object=object,pars=pars,transform=transform,...) Modified: pkg/pomp/R/mif.R =================================================================== --- pkg/pomp/R/mif.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/mif.R 2014-03-16 21:57:33 UTC (rev 891) @@ -404,7 +404,6 @@ transform = FALSE, ...) { - transform <- as.logical(transform) method <- match.arg(method) if (missing(start)) start <- coef(object) @@ -515,7 +514,6 @@ if (missing(cooling.fraction)) cooling.fraction <- object at cooling.fraction if (missing(method)) method <- object at method if (missing(transform)) transform <- object at transform - transform <- as.logical(transform) if (missing(Np)) Np <- object at Np if (missing(tol)) tol <- object at tol Modified: pkg/pomp/R/pmcmc.R =================================================================== --- pkg/pomp/R/pmcmc.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/pmcmc.R 2014-03-16 21:57:33 UTC (rev 891) @@ -6,8 +6,6 @@ pars = 'character', transform = 'logical', Nmcmc = 'integer', - dprior = 'function', - hyperparams = 'list', random.walk.sd = 'numeric', conv.rec = 'matrix', log.prior = 'numeric' @@ -17,28 +15,19 @@ ## PMCMC algorithm functions setGeneric('pmcmc',function(object,...)standardGeneric("pmcmc")) -setGeneric('dprior', function(object,...)standardGeneric("dprior")) - -setMethod( - "dprior", - signature=signature(object="pmcmc"), - function (object, params, log = FALSE, ...) { - do.call(object at dprior,list(params=params,hyperparams=object at hyperparams,log=log)) - } - ) - pmcmc.internal <- function (object, Nmcmc, - start, pars, dprior.fun, + start, pars, rw.sd, Np, - hyperparams, tol, max.fail, verbose, transform, .ndone = 0L, .prev.pfp = NULL, .prev.log.prior = NULL, .getnativesymbolinfo = TRUE) { + object <- as(object,"pomp") gnsi <- as.logical(.getnativesymbolinfo) transform <- as.logical(transform) + .ndone <- as.integer(.ndone) if (missing(start)) stop(sQuote("start")," must be specified",call.=FALSE) @@ -96,9 +85,6 @@ rw.sd <- rw.sd[pars] rw.names <- names(rw.sd) - if (missing(dprior.fun)) - stop("pmcmc error: ",sQuote("dprior")," must be specified",call.=FALSE) - ntimes <- length(time(object)) if (missing(Np)) stop("pmcmc error: ",sQuote("Np")," must be specified",call.=FALSE) @@ -120,9 +106,6 @@ stop(sQuote("Np")," must be a number, a vector of numbers, or a function") Np <- as.integer(Np) - if (missing(hyperparams)) - stop("pmcmc error: ",sQuote("hyperparams")," must be specified",call.=FALSE) - if (missing(Nmcmc)) stop("pmcmc error: ",sQuote("Nmcmc")," must be specified",call.=FALSE) Nmcmc <- as.integer(Nmcmc) @@ -161,23 +144,11 @@ ) } - obj <- as(object,"pomp") - - if (Nmcmc>0) - tmp.pmcmc <- new("pmcmc",obj,dprior=dprior.fun,hyperparams=hyperparams) - else - pfp <- obj - - if (.ndone==0) { ## compute prior and likelihood on initial parameter vector + if (.ndone==0L) { ## compute prior and likelihood on initial parameter vector pfp <- try( pfilter.internal( - object=obj, - params=if (transform) { - partrans(obj,theta,dir="forward", - .getnativesymbolinfo=gnsi) - } else { - theta - }, + object=object, + params=theta, Np=Np, tol=tol, max.fail=max.fail, @@ -194,7 +165,8 @@ ) if (inherits(pfp,'try-error')) stop("pmcmc error: error in ",sQuote("pfilter"),call.=FALSE) - log.prior <- dprior(object=tmp.pmcmc,params=theta,log=TRUE) + log.prior <- dprior(object,params=theta,log=TRUE,.getnativesymbolinfo=gnsi) + gnsi <- FALSE } else { ## has been computed previously pfp <- .prev.pfp log.prior <- .prev.log.prior @@ -205,18 +177,17 @@ for (n in seq_len(Nmcmc)) { # main loop theta.prop <- theta + if (transform) + theta <- partrans(object,theta.prop,dir='inverse',.getnativesymbolinfo=gnsi) theta.prop[pars] <- rnorm(n=length(pars),mean=theta.prop[pars],sd=rw.sd) + if (transform) + theta <- partrans(object,theta.prop,dir='forward',.getnativesymbolinfo=gnsi) ## run the particle filter on the proposed new parameter values pfp.prop <- try( pfilter.internal( object=pfp, - params=if (transform) { - partrans(obj,theta.prop,dir="forward", - .getnativesymbolinfo=gnsi) - } else { - theta.prop - }, + params=theta.prop, Np=Np, tol=tol, max.fail=max.fail, @@ -233,7 +204,7 @@ ) if (inherits(pfp.prop,'try-error')) stop("pmcmc error: error in ",sQuote("pfilter"),call.=FALSE) - log.prior.prop <- dprior(object=tmp.pmcmc,params=theta.prop,log=TRUE) + log.prior.prop <- dprior(object,params=theta.prop,log=TRUE,.getnativesymbolinfo=gnsi) gnsi <- FALSE ## PMCMC update rule (OK because proposal is symmetric) @@ -258,10 +229,8 @@ transform=transform, Nmcmc=Nmcmc, pars=pars, - dprior=dprior.fun, random.walk.sd=rw.sd, Np=Np, - hyperparams=hyperparams, tol=tol, conv.rec=conv.rec, log.prior=log.prior @@ -272,47 +241,26 @@ "pmcmc", signature=signature(object="pomp"), function (object, Nmcmc = 1, - start, pars, rw.sd, - dprior, Np, hyperparams, + start, pars, rw.sd, Np, tol = 1e-17, max.fail = 0, verbose = getOption("verbose"), transform = FALSE, ...) { - transform <- as.logical(transform) if (missing(start)) start <- coef(object,transform=transform) if (missing(rw.sd)) stop("pmcmc error: ",sQuote("rw.sd")," must be specified",call.=FALSE) if (missing(pars)) pars <- names(rw.sd)[rw.sd>0] if (missing(Np)) stop("pmcmc error: ",sQuote("Np")," must be specified",call.=FALSE) - if (missing(hyperparams)) - stop("pmcmc error: ",sQuote("hyperparams")," must be specified",call.=FALSE) - if (missing(dprior)) { # use default flat improper prior - dprior <- function (params, hyperparams, log) { - if (log) 0 else 1 - } - } else { - dprior <- match.fun(dprior) - if (!all(c('params','hyperparams','log')%in%names(formals(dprior)))) - stop( - "pmcmc error: ", - sQuote("dprior"), - " must be a function of prototype ", - sQuote("dprior(params,hyperparams,log)"), - call.=FALSE - ) - } pmcmc.internal( object=object, Nmcmc=Nmcmc, start=start, pars=pars, - dprior.fun=dprior, rw.sd=rw.sd, Np=Np, - hyperparams=hyperparams, tol=tol, max.fail=max.fail, verbose=verbose, @@ -325,8 +273,7 @@ setMethod( "pmcmc", signature=signature(object="pfilterd.pomp"), - function (object, Nmcmc = 1, - Np, tol, ...) { + function (object, Nmcmc = 1, Np, tol, ...) { if (missing(Np)) Np <- object at Np if (missing(tol)) tol <- object at tol @@ -346,8 +293,7 @@ signature=signature(object="pmcmc"), function (object, Nmcmc, start, pars, rw.sd, - dprior, Np, hyperparams, - tol, max.fail = 0, + Np, tol, max.fail = 0, verbose = getOption("verbose"), transform, ...) { @@ -356,22 +302,17 @@ if (missing(start)) start <- coef(object) if (missing(pars)) pars <- object at pars if (missing(rw.sd)) rw.sd <- object at random.walk.sd - if (missing(dprior)) dprior <- object at dprior if (missing(Np)) Np <- object at Np - if (missing(hyperparams)) hyperparams <- object at hyperparams if (missing(tol)) tol <- object at tol if (missing(transform)) transform <- object at transform - transform <- as.logical(transform) pmcmc( object=as(object,"pomp"), Nmcmc=Nmcmc, start=start, pars=pars, - dprior=dprior, rw.sd=rw.sd, Np=Np, - hyperparams=hyperparams, tol=tol, max.fail=max.fail, verbose=verbose, @@ -384,8 +325,7 @@ setMethod( 'continue', signature=signature(object='pmcmc'), - function (object, Nmcmc = 1, - ...) { + function (object, Nmcmc = 1, ...) { ndone <- object at Nmcmc Modified: pkg/pomp/R/pomp-class.R =================================================================== --- pkg/pomp/R/pomp-class.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/pomp-class.R 2014-03-16 21:57:33 UTC (rev 891) @@ -25,6 +25,8 @@ dprocess = 'function', dmeasure = 'pomp.fun', rmeasure = 'pomp.fun', + dprior = 'pomp.fun', + rprior = 'pomp.fun', skeleton.type = 'character', skeleton = 'pomp.fun', skelmap.delta.t = 'numeric', @@ -52,6 +54,8 @@ dprocess=function(x,times,params,log=FALSE,...)stop(sQuote("dprocess")," not specified"), dmeasure=pomp.fun(), rmeasure=pomp.fun(), + dprior=pomp.fun(), + rprior=pomp.fun(), skeleton.type="map", skeleton=pomp.fun(), skelmap.delta.t=as.numeric(NA), Modified: pkg/pomp/R/pomp-methods.R =================================================================== --- pkg/pomp/R/pomp-methods.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/pomp-methods.R 2014-03-16 21:57:33 UTC (rev 891) @@ -47,33 +47,19 @@ partrans.internal(object=object,params=params,dir=dir,...) ) -## a simple method to extract the data array -setMethod( - "data.array", - "pomp", - function (object, vars, ...) { - varnames <- rownames(object at data) - if (missing(vars)) - vars <- varnames - else if (!all(vars%in%varnames)) - stop("some elements of ",sQuote("vars")," correspond to no observed variable") - object at data[vars,,drop=FALSE] - } - ) +obs.internal <- function (object, vars, ...) { + varnames <- rownames(object at data) + if (missing(vars)) + vars <- varnames + else if (!all(vars%in%varnames)) + stop("some elements of ",sQuote("vars")," correspond to no observed variable") + object at data[vars,,drop=FALSE] +} + ## a simple method to extract the data array -setMethod( - "obs", - "pomp", - function (object, vars, ...) { - varnames <- rownames(object at data) - if (missing(vars)) - vars <- varnames - else if (!all(vars%in%varnames)) - stop("some elements of ",sQuote("vars")," correspond to no observed variable") - object at data[vars,,drop=FALSE] - } - ) +setMethod("obs","pomp",obs.internal) +setMethod("data.array","pomp",obs.internal) ## a simple method to extract the array of states setMethod( @@ -293,6 +279,10 @@ show(object at rmeasure) cat("measurement model density, dmeasure = \n") show(object at dmeasure) + cat("prior simulator, rprior = \n") + show(object at rprior) + cat("prior density, dprior = \n") + show(object at dprior) if (!is.na(object at skeleton.type)) { cat("skeleton (",object at skeleton.type,") = \n") show(object at skeleton) Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2014-03-11 13:23:39 UTC (rev 890) +++ pkg/pomp/R/pomp.R 2014-03-16 21:57:33 UTC (rev 891) @@ -1,9 +1,12 @@ ## basic constructor of the pomp class pomp.constructor <- function (data, times, t0, ..., rprocess, dprocess, rmeasure, dmeasure, measurement.model, - skeleton = NULL, skeleton.type = c("map","vectorfield"), + skeleton = NULL, + skeleton.type = c("map","vectorfield"), skelmap.delta.t = 1, - initializer, params, covar, tcovar, + initializer, + rprior, dprior, + params, covar, tcovar, obsnames, statenames, paramnames, covarnames, zeronames, PACKAGE, parameter.transform, parameter.inv.transform) { @@ -36,14 +39,16 @@ if (!is.numeric(times) || !all(diff(times)>0)) stop("pomp error: ",sQuote("times")," must be an increasing numeric vector",call.=TRUE) if (length(times)!=ncol(data)) - stop("pomp error: the length of ",sQuote("times")," does not equal the number of columns in ",sQuote("data"),call.=TRUE) + stop("pomp error: the length of ",sQuote("times")," does not equal the number of columns in ", + sQuote("data"),call.=TRUE) storage.mode(times) <- 'double' ## check t0 if (!is.numeric(t0) || length(t0) > 1) stop("pomp error: the zero-time ",sQuote("t0")," must be a single number",call.=TRUE) if (t0 > times[1L]) - stop("pomp error: the zero-time ",sQuote("t0")," must occur no later than the first observation",call.=TRUE) + stop("pomp error: the zero-time ",sQuote("t0")," must occur no later than the first observation", + call.=TRUE) storage.mode(t0) <- 'double' if (missing(PACKAGE)) PACKAGE <- "" @@ -57,7 +62,8 @@ if (!(missing(dmeasure)&&missing(rmeasure))) { warning( "specifying ",sQuote("measurement.model"), - " overrides specification of ",sQuote("rmeasure")," and ",sQuote("dmeasure") + " overrides specification of ", + sQuote("rmeasure")," and ",sQuote("dmeasure") ) } mm <- measform2pomp(measurement.model) @@ -71,9 +77,10 @@ stop(sQuote("skelmap.delta.t")," must be positive") if (is.null(skeleton)) { - skeleton <- pomp.fun(f=function(x,t,params,covars,...)stop(sQuote("skeleton")," not specified")) + skeleton <- pomp.fun() } else { - skeleton <- pomp.fun(f=skeleton,PACKAGE=PACKAGE,proto=quote(skeleton(x,t,params,...))) + skeleton <- pomp.fun(f=skeleton,PACKAGE=PACKAGE, + proto=quote(skeleton(x,t,params,...))) } if (missing(initializer)) { @@ -94,13 +101,29 @@ if (missing(rmeasure)) rmeasure <- pomp.fun() else - rmeasure <- pomp.fun(f=rmeasure,PACKAGE=PACKAGE,proto=quote(rmeasure(x,t,params,...))) + rmeasure <- pomp.fun(f=rmeasure,PACKAGE=PACKAGE, + proto=quote(rmeasure(x,t,params,...))) if (missing(dmeasure)) dmeasure <- pomp.fun() else - dmeasure <- pomp.fun(f=dmeasure,PACKAGE=PACKAGE,proto=quote(dmeasure(y,x,t,params,log,...))) + dmeasure <- pomp.fun(f=dmeasure,PACKAGE=PACKAGE, + proto=quote(dmeasure(y,x,t,params,log,...))) + if (missing(rprior)) { ## no default rprior + rprior <- pomp.fun() + } else { + rprior <- pomp.fun(f=rprior,PACKAGE=PACKAGE, + proto=quote(rprior(params,...))) + } + + if (missing(dprior)) { ## by default, use flat improper prior + dprior <- pomp.fun(f="_pomp_default_dprior") + } else { + dprior <- pomp.fun(f=dprior,PACKAGE=PACKAGE, + proto=quote(dprior(params,log,...))) + } + [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 891 From noreply at r-forge.r-project.org Sun Mar 16 23:13:38 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 16 Mar 2014 23:13:38 +0100 (CET) Subject: [Pomp-commits] r892 - pkg/pomp/tests Message-ID: <20140316221338.4E3DD186A65@r-forge.r-project.org> Author: kingaa Date: 2014-03-16 23:13:37 +0100 (Sun, 16 Mar 2014) New Revision: 892 Modified: pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/ou2-bsmc.Rout.save pkg/pomp/tests/ricker-bsmc.Rout.save Log: - update 3 tests Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2014-03-16 21:57:33 UTC (rev 891) +++ pkg/pomp/tests/bbs.Rout.save 2014-03-16 22:13:37 UTC (rev 892) @@ -37,16 +37,21 @@ rho sigma S.0 I.0 R.0 2.1972246 1.2809338 -0.0010005 -6.9077553 -Inf > -> prior <- parmat(coef(bbs),nrep=1000) -> prior["beta",] <- exp(runif(n=1000,min=1,max=2)) -> prior["sigma",] <- runif(n=1000,min=2,max=4) -> fit1 <- bsmc(bbs,params=prior,transform=TRUE,est=c("beta","sigma"),smooth=0.2) +> bbs <- pomp(bbs, ++ rprior=function(params,...){ ++ params["beta"] <- exp(runif(n=1,min=1,max=2)) ++ params["sigma"] <- runif(n=1,min=2,max=4) ++ params ++ } ++ ) +> +> fit1 <- bsmc(bbs,params=coef(bbs),Np=1000,transform=TRUE,est=c("beta","sigma"),smooth=0.2) Warning message: In sample.int(n = Np, size = Np, replace = TRUE, prob = g) : Walker's alias method used: results are different from R < 2.2.0 > signif(coef(fit1),3) gamma mu iota beta beta.sd pop rho sigma - 0.333 0.000 0.000 3.220 0.000 1400.000 0.900 2.240 + 0.333 0.000 0.000 3.630 0.000 1400.000 0.900 2.220 S.0 I.0 R.0 0.999 0.001 0.000 > @@ -59,4 +64,4 @@ > > proc.time() user system elapsed - 2.824 0.036 2.881 + 2.784 0.068 2.880 Modified: pkg/pomp/tests/ou2-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc.Rout.save 2014-03-16 21:57:33 UTC (rev 891) +++ pkg/pomp/tests/ou2-bsmc.Rout.save 2014-03-16 22:13:37 UTC (rev 892) @@ -63,7 +63,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 2.936097 secs +Time difference of 2.921494 secs > > print( + cbind( @@ -90,6 +90,12 @@ > print(smc$log.evidence) [1] 45.47584 > +> ou2 <- pomp(ou2, ++ rprior=function(params,...){ ++ params ++ } ++ ) +> > smc <- bsmc(ou2,ntries=5,Np=5000,smooth=0.1,est=estnames,seed=648651945L) > print(smc$eff.sample.size) [1] 186.40437 36.29100 57.56951 29.30424 180.23722 34.63366 156.94264 @@ -99,4 +105,4 @@ > > proc.time() user system elapsed - 4.808 0.060 4.897 + 4.788 0.072 4.889 Modified: pkg/pomp/tests/ricker-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ricker-bsmc.Rout.save 2014-03-16 21:57:33 UTC (rev 891) +++ pkg/pomp/tests/ricker-bsmc.Rout.save 2014-03-16 22:13:37 UTC (rev 892) @@ -25,14 +25,18 @@ + + set.seed(6457673L) + -+ po <- ricker ++ po <- pomp( ++ ricker, ++ rprior=function (params, ...) { ++ params["r"] <- exp(runif(n=1,min=2,max=5)) ++ params["sigma"] <- runif(n=1,min=0.1,max=1) ++ params ++ } ++ ) + + Np <- 10000 -+ params <- parmat(coef(ricker),nrep=Np) -+ params["r",] <- exp(runif(n=Np,min=2,max=5)) -+ params["sigma",] <- runif(n=Np,min=0.1,max=1) + -+ fit <- bsmc(ricker,params=params,est=c("r","sigma"),transform=TRUE,smooth=0.2) ++ fit <- bsmc(po,Np=1000,est=c("r","sigma"),transform=TRUE,smooth=0.2) + + invisible(apply(fit$prior[c("r","sigma"),],1,mean)) + @@ -58,4 +62,4 @@ > > proc.time() user system elapsed - 22.097 0.064 22.399 + 3.000 0.060 3.231 From noreply at r-forge.r-project.org Mon Mar 17 17:10:44 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 17 Mar 2014 17:10:44 +0100 (CET) Subject: [Pomp-commits] r893 - in pkg/pomp: . R Message-ID: <20140317161044.A28F8180AC2@r-forge.r-project.org> Author: kingaa Date: 2014-03-17 17:10:44 +0100 (Mon, 17 Mar 2014) New Revision: 893 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/plot-pomp.R Log: - minor tweak to the plot.pomp method Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-16 22:13:37 UTC (rev 892) +++ pkg/pomp/DESCRIPTION 2014-03-17 16:10:44 UTC (rev 893) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.48-1 -Date: 2014-03-16 +Version: 0.48-2 +Date: 2014-03-17 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/R/plot-pomp.R =================================================================== --- pkg/pomp/R/plot-pomp.R 2014-03-16 22:13:37 UTC (rev 892) +++ pkg/pomp/R/plot-pomp.R 2014-03-17 16:10:44 UTC (rev 893) @@ -6,6 +6,7 @@ mar = c(0, 5.1, 0, if (yax.flip) 5.1 else 2.1), oma = c(6, 0, 5, 0), axes = TRUE, + xlabel, ...) { X <- as(x,"data.frame") vars <- names(X) @@ -25,6 +26,7 @@ vars <- variables ylabels <- names(variables) } + plotpomp <- function (x, time, xy.labels, xy.lines, panel = lines, nc, xlabel, type = "l", xlim = NULL, ylim = NULL, xlab = "time", @@ -97,7 +99,7 @@ time=X[[tpos]], ylab=ylabels, xy.labels=FALSE, - xlabel=deparse(substitute(x,env=parent.frame(1))), + xlabel=xlabel, panel=panel, nc=nc, axes=axes, @@ -118,8 +120,10 @@ oma = c(6, 0, 5, 0), axes = TRUE, ...) { + xlabel <- deparse(substitute(x,env=parent.frame())) plotpomp.internal(x=x,y=y,variables=variables, panel=panel,nc=nc,yax.flip=yax.flip, - mar=mar,oma=oma,axes=axes,...) + mar=mar,oma=oma,axes=axes, + xlabel=xlabel,...) } ) From noreply at r-forge.r-project.org Mon Mar 17 23:02:29 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 17 Mar 2014 23:02:29 +0100 (CET) Subject: [Pomp-commits] r894 - in pkg/pomp: . R inst tests Message-ID: <20140317220230.0B67B18687D@r-forge.r-project.org> Author: kingaa Date: 2014-03-17 23:02:29 +0100 (Mon, 17 Mar 2014) New Revision: 894 Added: pkg/pomp/R/generics.R pkg/pomp/tests/demos.R Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/aaa.R pkg/pomp/R/abc-methods.R pkg/pomp/R/abc.R pkg/pomp/R/bsmc.R pkg/pomp/R/compare-pmcmc.R pkg/pomp/R/dmeasure-pomp.R pkg/pomp/R/dprior-pomp.R pkg/pomp/R/dprocess-pomp.R pkg/pomp/R/init-state-pomp.R pkg/pomp/R/mif.R pkg/pomp/R/particles-mif.R pkg/pomp/R/pfilter.R pkg/pomp/R/pmcmc.R pkg/pomp/R/pomp-class.R pkg/pomp/R/pomp-methods.R pkg/pomp/R/probe-match.R pkg/pomp/R/probe.R pkg/pomp/R/rmeasure-pomp.R pkg/pomp/R/rprior-pomp.R pkg/pomp/R/rprocess-pomp.R pkg/pomp/R/skeleton-pomp.R pkg/pomp/R/spect.R pkg/pomp/R/traj-match.R pkg/pomp/R/trajectory-pomp.R pkg/pomp/inst/NEWS Log: - fix bug in 'abc' to do with parameter transformation - move all generic declarations to 'generics.R' - add new test of demos Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/DESCRIPTION 2014-03-17 22:02:29 UTC (rev 894) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.48-2 +Version: 0.48-3 Date: 2014-03-17 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), @@ -23,8 +23,8 @@ LazyData: true BuildVignettes: true MailingList: Subscribe to pomp-announce at r-forge.r-project.org for announcements by going to http://lists.r-forge.r-project.org/mailman/listinfo/pomp-announce. -Collate: aaa.R authors.R version.R eulermultinom.R plugins.R - parmat.R logmeanexp.R slice-design.R +Collate: aaa.R authors.R generics.R version.R eulermultinom.R + plugins.R parmat.R logmeanexp.R slice-design.R profile-design.R sobol.R bsplines.R sannbox.R pomp-fun.R pomp-class.R pomp.R pomp-methods.R rmeasure-pomp.R rprocess-pomp.R init-state-pomp.R Modified: pkg/pomp/R/aaa.R =================================================================== --- pkg/pomp/R/aaa.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/aaa.R 2014-03-17 22:02:29 UTC (rev 894) @@ -5,22 +5,6 @@ ## packageStartupMessage("This is pomp version ",version,"\n") ## } -setGeneric("print",function(x,...)standardGeneric("print")) -setGeneric("plot",function(x,y,...)standardGeneric("plot")) -setGeneric("summary",function(object,...)standardGeneric("summary")) -setGeneric("simulate",function(object,nsim=1,seed=NULL,...)standardGeneric("simulate")) -setGeneric("time",function(x,...)standardGeneric("time")) -setGeneric("coef",function(object,...)standardGeneric("coef")) -setGeneric("logLik",function(object,...)standardGeneric("logLik")) -setGeneric("window",function(x,...)standardGeneric("window")) -setGeneric("continue",function(object,...)standardGeneric("continue")) -setGeneric("pred.mean",function(object,...)standardGeneric("pred.mean")) -setGeneric("pred.var",function(object,...)standardGeneric("pred.var")) -setGeneric("filter.mean",function(object,...)standardGeneric("filter.mean")) -setGeneric("cond.logLik",function(object,...)standardGeneric("cond.logLik")) -setGeneric("eff.sample.size",function(object,...)standardGeneric("eff.sample.size")) -setGeneric("conv.rec",function(object,...)standardGeneric("conv.rec")) - if (!exists("paste0",where="package:base")) { paste0 <- function(...) paste(...,sep="") } Modified: pkg/pomp/R/abc-methods.R =================================================================== --- pkg/pomp/R/abc-methods.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/abc-methods.R 2014-03-17 22:02:29 UTC (rev 894) @@ -19,7 +19,7 @@ if (scatter) { pairs(conv.rec(x, pars)) } else { - plot.ts(conv.rec(x,pars),main="Convergence record") + plot.ts(conv.rec(x,pars),...) } } ) Modified: pkg/pomp/R/abc.R =================================================================== --- pkg/pomp/R/abc.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/abc.R 2014-03-17 22:02:29 UTC (rev 894) @@ -14,9 +14,6 @@ ) ) -## ABC algorithm functions -setGeneric('abc',function(object,...)standardGeneric("abc")) - abc.internal <- function (object, Nabc, start, pars, rw.sd, probes, @@ -100,7 +97,8 @@ } theta <- start - log.prior <- dprior(object,params=theta,log=TRUE) + log.prior <- dprior(object,params=theta,log=TRUE, + .getnativesymbolinfo=gnsi) ## we suppose that theta is a "match", which does the right thing for continue() and ## should have negligible effect unless doing many short calls to continue() @@ -126,10 +124,8 @@ ) } - po <- as(object,"pomp") - ## apply probes to data - datval <- try(.Call(apply_probe_data,po,probes),silent=FALSE) + datval <- try(.Call(apply_probe_data,object,probes),silent=FALSE) if (inherits(datval,'try-error')) stop("abc error: error in ",sQuote("apply_probe_data"),call.=FALSE) @@ -138,14 +134,25 @@ for (n in seq_len(Nabc)) { # main loop theta.prop <- theta + + if (transform) + theta.prop <- partrans(object,params=theta.prop,dir='inverse', + .getnativesymbolinfo=gnsi) + theta.prop[pars] <- rnorm(n=length(pars),mean=theta.prop[pars],sd=rw.sd) + if (transform) + theta.prop <- partrans(object,params=theta.prop,dir='forward', + .getnativesymbolinfo=gnsi) + + gnsi <- FALSE + ## compute the probes for the proposed new parameter values simval <- try( .Call( apply_probe_sim, - object=po, + object=object, nsim=1, params=theta.prop, seed=NULL, @@ -177,7 +184,7 @@ new( 'abc', - po, + object, params=theta, pars=pars, transform=transform, @@ -205,19 +212,23 @@ start <- coef(object) if (missing(rw.sd)) - stop("abc error: ",sQuote("rw.sd")," must be specified",call.=FALSE) + stop("abc error: ",sQuote("rw.sd")," must be specified", + call.=FALSE) if (missing(pars)) pars <- names(rw.sd)[rw.sd>0] if (missing(probes)) - stop("abc error: ",sQuote("probes")," must be specified",call.=FALSE) + stop("abc error: ",sQuote("probes")," must be specified", + call.=FALSE) if (missing(scale)) - stop("abc error: ",sQuote("scale")," must be specified",call.=FALSE) + stop("abc error: ",sQuote("scale")," must be specified", + call.=FALSE) if (missing(epsilon)) - stop("abc error: abc match criterion, ",sQuote("epsilon"),", must be specified",call.=FALSE) + stop("abc error: abc match criterion, ",sQuote("epsilon"), + ", must be specified",call.=FALSE) abc.internal( object=object, @@ -243,13 +254,13 @@ ...) { if (missing(probes)) probes <- object at probes - - abc( - object=as(object,"pomp"), - probes=probes, - transform=transform, - ... - ) + f <- selectMethod("abc","pomp") + f( + object=object, + probes=probes, + transform=transform, + ... + ) } ) @@ -272,19 +283,21 @@ if (missing(epsilon)) epsilon <- object at epsilon if (missing(transform)) transform <- object at transform - abc( - object=as(object,"pomp"), - Nabc=Nabc, - start=start, - pars=pars, - rw.sd=rw.sd, - probes=probes, - scale=scale, - epsilon=epsilon, - verbose=verbose, - transform=transform, - ... - ) + f <- selectMethod("abc","pomp") + + f( + object=object, + Nabc=Nabc, + start=start, + pars=pars, + rw.sd=rw.sd, + probes=probes, + scale=scale, + epsilon=epsilon, + verbose=verbose, + transform=transform, + ... + ) } ) @@ -294,13 +307,14 @@ function (object, Nabc = 1, ...) { ndone <- object at Nabc + f <- selectMethod("abc","abc") - obj <- abc( - object=object, - Nabc=Nabc, - .ndone=ndone, - ... - ) + obj <- f( + object=object, + Nabc=Nabc, + .ndone=ndone, + ... + ) obj at conv.rec <- rbind( object at conv.rec[,colnames(obj at conv.rec)], Modified: pkg/pomp/R/bsmc.R =================================================================== --- pkg/pomp/R/bsmc.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/bsmc.R 2014-03-17 22:02:29 UTC (rev 894) @@ -29,8 +29,6 @@ ) ) -setGeneric("bsmc",function(object,...)standardGeneric("bsmc")) - bsmc.internal <- function (object, params, Np, est, smooth = 0.1, ntries = 1, Modified: pkg/pomp/R/compare-pmcmc.R =================================================================== --- pkg/pomp/R/compare-pmcmc.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/compare-pmcmc.R 2014-03-17 22:02:29 UTC (rev 894) @@ -99,5 +99,3 @@ } invisible(NULL) } - - Modified: pkg/pomp/R/dmeasure-pomp.R =================================================================== --- pkg/pomp/R/dmeasure-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/dmeasure-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,5 +1,4 @@ ## evaluate the measurement model density function -setGeneric("dmeasure",function(object,...)standardGeneric("dmeasure")) dmeasure.internal <- function (object, y, x, times, params, log = FALSE, .getnativesymbolinfo = TRUE, ...) { .Call(do_dmeasure,object,y,x,times,params,log,.getnativesymbolinfo) Modified: pkg/pomp/R/dprior-pomp.R =================================================================== --- pkg/pomp/R/dprior-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/dprior-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,5 +1,4 @@ ## evaluate the prior probability density -setGeneric("dprior",function(object,...)standardGeneric("dprior")) dprior.internal <- function (object, params, log = FALSE, .getnativesymbolinfo = TRUE, ...) { Modified: pkg/pomp/R/dprocess-pomp.R =================================================================== --- pkg/pomp/R/dprocess-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/dprocess-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,5 +1,4 @@ ## evaluate the process model density function -setGeneric("dprocess",function(object,...)standardGeneric("dprocess")) dprocess.internal <- function (object, x, times, params, log = FALSE, .getnativesymbolinfo = TRUE, ...) .Call(do_dprocess,object,x,times,params,log,.getnativesymbolinfo) Added: pkg/pomp/R/generics.R =================================================================== --- pkg/pomp/R/generics.R (rev 0) +++ pkg/pomp/R/generics.R 2014-03-17 22:02:29 UTC (rev 894) @@ -0,0 +1,79 @@ +## basic constructor +setGeneric("pomp",function(data,...)standardGeneric("pomp")) + +setGeneric("print",function(x,...)standardGeneric("print")) +setGeneric("plot",function(x,y,...)standardGeneric("plot")) +setGeneric("summary",function(object,...)standardGeneric("summary")) +setGeneric("window",function(x,...)standardGeneric("window")) + +## constituent components of a 'pomp' object +setGeneric("dmeasure",function(object,...)standardGeneric("dmeasure")) +setGeneric("rmeasure",function(object,...)standardGeneric("rmeasure")) +setGeneric("dprocess",function(object,...)standardGeneric("dprocess")) +setGeneric("rprocess",function(object,...)standardGeneric("rprocess")) +setGeneric("dprior",function(object,...)standardGeneric("dprior")) +setGeneric("rprior",function(object,...)standardGeneric("rprior")) +setGeneric("init.state",function(object,...)standardGeneric("init.state")) +setGeneric("skeleton",function(object,...)standardGeneric("skeleton")) + +## functions to extract or call the components of a "pomp" object +setGeneric("obs",function(object,...)standardGeneric("obs")) +setGeneric("data.array",function(object,...)standardGeneric("data.array")) +setGeneric("time",function(x,...)standardGeneric("time")) +setGeneric("time<-",function(object,...,value)standardGeneric("time<-")) +setGeneric("coef",function(object,...)standardGeneric("coef")) +setGeneric("coef<-",function(object,...,value)standardGeneric("coef<-")) +setGeneric("states",function(object,...)standardGeneric("states")) +setGeneric("timezero",function(object,...)standardGeneric("timezero")) +setGeneric("timezero<-",function(object,...,value)standardGeneric("timezero<-")) +setGeneric("partrans",function(object,params,dir=c("forward","inverse"),...)standardGeneric("partrans")) +setGeneric("logLik",function(object,...)standardGeneric("logLik")) + +## prediction mean +setGeneric("pred.mean",function(object,...)standardGeneric("pred.mean")) +## prediction variance +setGeneric("pred.var",function(object,...)standardGeneric("pred.var")) +## filter mean +setGeneric("filter.mean",function(object,...)standardGeneric("filter.mean")) +## conditional log likelihood +setGeneric("cond.logLik",function(object,...)standardGeneric("cond.logLik")) +## effective sample size +setGeneric("eff.sample.size",function(object,...)standardGeneric("eff.sample.size")) +## convergence record +setGeneric("conv.rec",function(object,...)standardGeneric("conv.rec")) + +## stochastic simulation +setGeneric("simulate",function(object,nsim=1,seed=NULL,...)standardGeneric("simulate")) + +## deterministic trajectory computation +setGeneric("trajectory",function(object,...)standardGeneric("trajectory")) +## trajectory matching +setGeneric("traj.match",function(object,...)standardGeneric("traj.match")) + +## ABC algorithm functions +setGeneric('abc',function(object,...)standardGeneric("abc")) + +## Bayesian SMC (Liu & West) +setGeneric("bsmc",function(object,...)standardGeneric("bsmc")) + +## basic SMC (particle filter) +setGeneric("pfilter",function(object,...)standardGeneric("pfilter")) + +## particle Markov chain Monte Carlo (PMCMC) +setGeneric('pmcmc',function(object,...)standardGeneric("pmcmc")) + +## iterated filtering +setGeneric('mif',function(object,...)standardGeneric("mif")) +## generate new particles +setGeneric('particles',function(object,...)standardGeneric("particles")) + +## synthetic likelihood +setGeneric("probe",function(object,probes,...)standardGeneric("probe")) +## probe matching +setGeneric("probe.match",function(object,...)standardGeneric("probe.match")) + +## power spectrum +setGeneric("spect",function(object,...)standardGeneric("spect")) + +## continue an iteration +setGeneric("continue",function(object,...)standardGeneric("continue")) Modified: pkg/pomp/R/init-state-pomp.R =================================================================== --- pkg/pomp/R/init-state-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/init-state-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,12 +1,11 @@ ## initialize the state variables of the process model + init.state.internal <- function (object, params, t0, ...) { if (missing(t0)) t0 <- object at t0 if (missing(params)) params <- coef(object) .Call(do_init_state,object,params,t0) } -setGeneric("init.state",function(object,...)standardGeneric("init.state")) - setMethod( 'init.state', 'pomp', Modified: pkg/pomp/R/mif.R =================================================================== --- pkg/pomp/R/mif.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/mif.R 2014-03-17 22:02:29 UTC (rev 894) @@ -386,8 +386,6 @@ ) } -setGeneric('mif',function(object,...)standardGeneric("mif")) - setMethod( "mif", signature=signature(object="pomp"), Modified: pkg/pomp/R/particles-mif.R =================================================================== --- pkg/pomp/R/particles-mif.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/particles-mif.R 2014-03-17 22:02:29 UTC (rev 894) @@ -30,8 +30,6 @@ x } -setGeneric('particles',function(object,...)standardGeneric("particles")) - setMethod("particles",signature=signature(object="mif"), function (object, Np = 1, center = coef(object), sd = 0, ...) { particles.internal(object=object,Np=Np,center=center,sd=sd,...) Modified: pkg/pomp/R/pfilter.R =================================================================== --- pkg/pomp/R/pfilter.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/pfilter.R 2014-03-17 22:02:29 UTC (rev 894) @@ -341,9 +341,6 @@ ) } -## generic particle filter -setGeneric("pfilter",function(object,...)standardGeneric("pfilter")) - setMethod( "pfilter", signature=signature(object="pomp"), Modified: pkg/pomp/R/pmcmc.R =================================================================== --- pkg/pomp/R/pmcmc.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/pmcmc.R 2014-03-17 22:02:29 UTC (rev 894) @@ -12,9 +12,6 @@ ) ) -## PMCMC algorithm functions -setGeneric('pmcmc',function(object,...)standardGeneric("pmcmc")) - pmcmc.internal <- function (object, Nmcmc, start, pars, rw.sd, Np, Modified: pkg/pomp/R/pomp-class.R =================================================================== --- pkg/pomp/R/pomp-class.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/pomp-class.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,6 +1,3 @@ -## as of version 0.37-1 'pomp' is a generic function -setGeneric("pomp",function(data,...)standardGeneric("pomp")) - ## this is the initial-condition setting function that is used by default ## it simply finds all parameters in the vector 'params' that have a name ending in '.0' ## and returns a vector with their values with names stripped of '.0' Modified: pkg/pomp/R/pomp-methods.R =================================================================== --- pkg/pomp/R/pomp-methods.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/pomp-methods.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,15 +1,5 @@ ## this file contains some basic methods definitions -## functions to extract or call the components of a "pomp" object -setGeneric("data.array",function(object,...)standardGeneric("data.array")) -setGeneric("obs",function(object,...)standardGeneric("obs")) -setGeneric("time<-",function(object,...,value)standardGeneric("time<-")) -setGeneric("coef<-",function(object,...,value)standardGeneric("coef<-")) -setGeneric("states",function(object,...)standardGeneric("states")) -setGeneric("timezero",function(object,...)standardGeneric("timezero")) -setGeneric("timezero<-",function(object,...,value)standardGeneric("timezero<-")) -setGeneric("partrans",function(object,params,dir=c("forward","inverse"),...)standardGeneric("partrans")) - ## 'coerce' method: allows for coercion of a "pomp" object to a data-frame setAs( from="pomp", Modified: pkg/pomp/R/probe-match.R =================================================================== --- pkg/pomp/R/probe-match.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/probe-match.R 2014-03-17 22:02:29 UTC (rev 894) @@ -169,8 +169,6 @@ ) } -setGeneric("probe.match",function(object,...)standardGeneric("probe.match")) - setMethod( "probe.match", signature=signature(object="pomp"), Modified: pkg/pomp/R/probe.R =================================================================== --- pkg/pomp/R/probe.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/probe.R 2014-03-17 22:02:29 UTC (rev 894) @@ -63,8 +63,6 @@ ) } -setGeneric("probe",function(object,probes,...)standardGeneric("probe")) - setMethod("probe",signature(object="pomp"), function (object, probes, params, nsim = 1, seed = NULL, ...) { probe.internal(object=object,probes=probes,params=params, Modified: pkg/pomp/R/rmeasure-pomp.R =================================================================== --- pkg/pomp/R/rmeasure-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/rmeasure-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,7 +1,5 @@ ## simulate the measurement model -setGeneric("rmeasure",function(object,...)standardGeneric("rmeasure")) - rmeasure.internal <- function (object, x, times, params, .getnativesymbolinfo = TRUE, ...) { .Call(do_rmeasure,object,x,times,params,.getnativesymbolinfo) Modified: pkg/pomp/R/rprior-pomp.R =================================================================== --- pkg/pomp/R/rprior-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/rprior-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,7 +1,5 @@ ## simulate from the prior -setGeneric("rprior",function(object,...)standardGeneric("rprior")) - rprior.internal <- function (object, params, .getnativesymbolinfo = TRUE, ...) { .Call(do_rprior,object,params,.getnativesymbolinfo) } Modified: pkg/pomp/R/rprocess-pomp.R =================================================================== --- pkg/pomp/R/rprocess-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/rprocess-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,7 +1,5 @@ ## simulate the process model -setGeneric("rprocess",function(object,...)standardGeneric("rprocess")) - rprocess.internal <- function (object, xstart, times, params, offset = 0, .getnativesymbolinfo = TRUE, ...) .Call(do_rprocess,object,xstart,times,params,offset,.getnativesymbolinfo) Modified: pkg/pomp/R/skeleton-pomp.R =================================================================== --- pkg/pomp/R/skeleton-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/skeleton-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,5 +1,4 @@ ## evaluate the deterministic skeleton -setGeneric("skeleton",function(object,...)standardGeneric("skeleton")) skeleton.internal <- function (object, x, t, params, .getnativesymbolinfo = TRUE, ...) { .Call(do_skeleton,object,x,t,params,.getnativesymbolinfo) Modified: pkg/pomp/R/spect.R =================================================================== --- pkg/pomp/R/spect.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/spect.R 2014-03-17 22:02:29 UTC (rev 894) @@ -136,8 +136,6 @@ simspec } -setGeneric("spect",function(object,...)standardGeneric("spect")) - setMethod( "spect", signature(object="pomp"), Modified: pkg/pomp/R/traj-match.R =================================================================== --- pkg/pomp/R/traj-match.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/traj-match.R 2014-03-17 22:02:29 UTC (rev 894) @@ -151,8 +151,6 @@ traj.match <- function (object, ...) stop("function ",sQuote("traj.match")," is undefined for objects of class ",sQuote(class(object))) -setGeneric("traj.match") - setMethod( "traj.match", signature=signature(object="pomp"), Modified: pkg/pomp/R/trajectory-pomp.R =================================================================== --- pkg/pomp/R/trajectory-pomp.R 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/R/trajectory-pomp.R 2014-03-17 22:02:29 UTC (rev 894) @@ -1,5 +1,3 @@ -setGeneric("trajectory",function(object,...)standardGeneric("trajectory")) - trajectory.internal <- function (object, params, times, t0, as.data.frame = FALSE, .getnativesymbolinfo = TRUE, ...) { if (missing(times)) Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-03-17 16:10:44 UTC (rev 893) +++ pkg/pomp/inst/NEWS 2014-03-17 22:02:29 UTC (rev 894) @@ -1,4 +1,7 @@ NEWS +0.48-3 + o Correct a bug in 'abc' to do with parameter transformation. + 0.48-1 o Create new 'dprior' and 'rprior' slots for 'pomp' objects. These will be used by the Bayesian methods (currently 'abc', 'bsmc', and 'pmcmc'). Added: pkg/pomp/tests/demos.R =================================================================== --- pkg/pomp/tests/demos.R (rev 0) +++ pkg/pomp/tests/demos.R 2014-03-17 22:02:29 UTC (rev 894) @@ -0,0 +1,18 @@ +if (Sys.getenv("POMP_FULL_TESTS")=="yes") { + + library(pomp) + + pdf.options(useDingbats=FALSE) + pdf(file="demos.pdf") + + set.seed(47575684) + + demos <- list.files(path=system.file("demo",package="pomp"),pattern=".\\.R$",full.names=TRUE) + + for (d in demos) { + source(d,local=TRUE,echo=TRUE) + } + + dev.off() + +} From noreply at r-forge.r-project.org Thu Mar 20 16:07:36 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 20 Mar 2014 16:07:36 +0100 (CET) Subject: [Pomp-commits] r895 - in pkg/pomp: . R inst man src tests Message-ID: <20140320150736.83273186C6C@r-forge.r-project.org> Author: kingaa Date: 2014-03-20 16:07:33 +0100 (Thu, 20 Mar 2014) New Revision: 895 Added: pkg/pomp/R/minim.R Removed: pkg/pomp/tests/ou2-icfit.R pkg/pomp/tests/ou2-icfit.Rout.save Modified: pkg/pomp/DESCRIPTION pkg/pomp/NAMESPACE pkg/pomp/R/generics.R pkg/pomp/R/pomp.R pkg/pomp/R/probe-match.R pkg/pomp/R/probe.R pkg/pomp/R/simulate-pomp.R pkg/pomp/R/traj-match.R pkg/pomp/inst/NEWS pkg/pomp/man/probe.Rd pkg/pomp/man/probed-pomp-methods.Rd pkg/pomp/man/spect.Rd pkg/pomp/man/traj-match.Rd pkg/pomp/src/sir.c pkg/pomp/tests/abc.R pkg/pomp/tests/abc.Rout.save pkg/pomp/tests/bbs-trajmatch.R pkg/pomp/tests/bbs-trajmatch.Rout.save pkg/pomp/tests/ou2-probe.R pkg/pomp/tests/ou2-probe.Rout.save pkg/pomp/tests/ou2-trajmatch.R pkg/pomp/tests/ou2-trajmatch.Rout.save pkg/pomp/tests/ricker-probe.R pkg/pomp/tests/ricker-probe.Rout.save pkg/pomp/tests/rw2.Rout.save pkg/pomp/tests/sir.Rout.save Log: - barycentric transformation added for initial conditions in SIR example - probe matching and trajectory matching are now done using a unified optimizer (in 'minim.R') - the 'gr' and 'eval.only' arguments have been removed from 'probe.match' and 'traj.match' - 'probe.match.objfun' and 'traj.match.objfun' are now exported S4 methods - some changes to the underlying structure of 'probe.matched.pomp' and 'traj.matched.pomp' objects - access to slots in 'probed.pomp' is now available via the '$' operator - RNG seed is now stored in 'probed.pomp' objects if set - in 'pomp', when dprior is unspecified, the default (flat, improper) prior is sought in the 'pomp' package Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/DESCRIPTION 2014-03-20 15:07:33 UTC (rev 895) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.48-3 -Date: 2014-03-17 +Version: 0.49-1 +Date: 2014-03-20 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), @@ -18,7 +18,7 @@ ) URL: http://pomp.r-forge.r-project.org Description: Inference methods for partially-observed Markov processes -Depends: R(>= 2.14.1), stats, graphics, methods, mvtnorm, subplex, deSolve +Depends: R(>= 2.14.1), stats, graphics, methods, mvtnorm, subplex, nloptr, deSolve License: GPL(>= 2) LazyData: true BuildVignettes: true @@ -31,7 +31,7 @@ dmeasure-pomp.R dprocess-pomp.R skeleton-pomp.R dprior-pomp.R rprior-pomp.R simulate-pomp.R trajectory-pomp.R plot-pomp.R - pfilter.R pfilter-methods.R traj-match.R bsmc.R + pfilter.R pfilter-methods.R minim.R traj-match.R bsmc.R mif-class.R particles-mif.R mif.R mif-methods.R compare-mif.R pmcmc.R pmcmc-methods.R compare-pmcmc.R nlf-funcs.R nlf-guts.R nlf-objfun.R nlf.R Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/NAMESPACE 2014-03-20 15:07:33 UTC (rev 895) @@ -37,6 +37,7 @@ importFrom(mvtnorm,dmvnorm,rmvnorm) importFrom(subplex,subplex) importFrom(deSolve,ode) +importFrom(nloptr,nloptr) exportClasses( pomp, @@ -61,6 +62,8 @@ particles,mif,continue,states,trajectory, pred.mean,pred.var,filter.mean,conv.rec, bsmc,pmcmc,abc, + traj.match.objfun, + probe.match.objfun, spect,probe,probe.match, traj.match ) @@ -98,7 +101,6 @@ probe.marginal, sannbox, spect.match, - traj.match.objfun, pompBuilder, pompExample ) Modified: pkg/pomp/R/generics.R =================================================================== --- pkg/pomp/R/generics.R 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/R/generics.R 2014-03-20 15:07:33 UTC (rev 895) @@ -48,6 +48,7 @@ ## deterministic trajectory computation setGeneric("trajectory",function(object,...)standardGeneric("trajectory")) ## trajectory matching +setGeneric("traj.match.objfun",function(object,...)standardGeneric("traj.match.objfun")) setGeneric("traj.match",function(object,...)standardGeneric("traj.match")) ## ABC algorithm functions @@ -70,6 +71,7 @@ ## synthetic likelihood setGeneric("probe",function(object,probes,...)standardGeneric("probe")) ## probe matching +setGeneric("probe.match.objfun",function(object,...)standardGeneric("probe.match.objfun")) setGeneric("probe.match",function(object,...)standardGeneric("probe.match")) ## power spectrum Added: pkg/pomp/R/minim.R =================================================================== --- pkg/pomp/R/minim.R (rev 0) +++ pkg/pomp/R/minim.R 2014-03-20 15:07:33 UTC (rev 895) @@ -0,0 +1,75 @@ +minim.internal <- function(objfun, start, est, object, method, transform, verbose, ...) +{ + + transform <- as.logical(transform) + est <- as.character(est) + + if (length(start)<1) + stop(sQuote("start")," must be supplied") + + if (transform) { + start <- partrans(object,start,dir="inverse") + if (is.null(names(start))||(!all(est%in%names(start)))) + stop(sQuote("est")," must refer to parameters named in ", + sQuote("partrans(object,start,dir=\"inverse\")")) + guess <- start[est] + } else { + if (is.null(names(start))||(!all(est%in%names(start)))) + stop(sQuote("est")," must refer to parameters named in ", + sQuote("start")) + guess <- start[est] + } + + if (length(est)==0) { + + params <- c(A=3) + val <- objfun(guess) + conv <- NA + evals <- as.integer(c(1,0)) + msg <- "no optimization performed" + + } else { + + opts <- list(...) + + if (method == 'subplex') { + opt <- subplex::subplex(par=guess,fn=objfun,control=opts) + } else if (method=="sannbox") { + opt <- sannbox(par=guess,fn=objfun,control=opts) + } else if (method=="nloptr") { + opt <- nloptr(x0=guess,eval_f=objfun,opts=opts) + } else { + opt <- optim(par=guess,fn=objfun,method=method,control=opts) + } + + msg <- as.character(opt$message) + val <- opt$value + + if (method == "nloptr") { + + start[est] <- unname(opt$solution) + conv <- opt$status + evals <- opt$iterations + + } else { + + start[est] <- unname(opt$par) + conv <- opt$convergence + evals <- opt$counts + + } + } + + if (transform) + start <- partrans(object,start,dir='forward') + + list( + params=start, + est=est, + transform=transform, + value=val, + convergence=as.integer(conv), + evals=as.integer(evals), + msg=msg + ) +} Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/R/pomp.R 2014-03-20 15:07:33 UTC (rev 895) @@ -118,7 +118,7 @@ } if (missing(dprior)) { ## by default, use flat improper prior - dprior <- pomp.fun(f="_pomp_default_dprior") + dprior <- pomp.fun(f="_pomp_default_dprior",PACKAGE="pomp") } else { dprior <- pomp.fun(f=dprior,PACKAGE=PACKAGE, proto=quote(dprior(params,log,...))) Modified: pkg/pomp/R/probe-match.R =================================================================== --- pkg/pomp/R/probe-match.R 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/R/probe-match.R 2014-03-20 15:07:33 UTC (rev 895) @@ -2,10 +2,8 @@ "probe.matched.pomp", contains="probed.pomp", representation=representation( - start="numeric", transform="logical", est="character", - weights="numeric", fail.value="numeric", value="numeric", evals="integer", @@ -14,6 +12,8 @@ ) ) +setMethod("$",signature=signature(x="probe.matched.pomp"),function(x, name)slot(x,name)) + setMethod( "summary", "probe.matched.pomp", @@ -31,13 +31,18 @@ } ) -probe.match.objfun <- function (object, params, est, probes, - nsim = 1, seed = NULL, fail.value = NA, - transform = FALSE, ...) { - +pmof.internal <- function (object, params, est, probes, + nsim, seed = NULL, fail.value = NA, + transform = FALSE, ...) +{ + object <- as(object,"pomp") transform <- as.logical(transform) + fail.value <- as.numeric(fail.value) if (missing(est)) est <- character(0) - if (!is.character(est)) stop(sQuote("est")," must be a vector of parameter names") + est <- as.character(est) + if (missing(nsim)) stop(sQuote("nsim")," must be specified") + nsim <- as.integer(nsim) + if (missing(params)) params <- coef(object) if ((!is.numeric(params))||(is.null(names(params)))) stop(sQuote("params")," must be a named numeric vector") @@ -58,8 +63,8 @@ if (nprobes > nsim) stop(sQuote("nsim"),"(=",nsim,") should be (much) larger than the number of probes (=",nprobes,")") - obj.fun <- function (par) { - + function (par) { + params[par.est.idx] <- par if (transform) @@ -79,273 +84,158 @@ ll <- .Call(synth_loglik,simval,datval) if (is.finite(ll)||is.na(fail.value)) -ll else fail.value } - - obj.fun } -probe.match.internal <- function(object, start, est, - probes, weights, - nsim, seed, - method, verbose, - eval.only, fail.value, transform, ...) { +setMethod( + "probe.match.objfun", + signature=signature(object="pomp"), + function (object, params, est, probes, + nsim, seed = NULL, fail.value = NA, + transform = FALSE, ...) + pmof.internal( + object=object, + params=params, + est=est, + probes=probes, + nsim=nsim, + seed=seed, + fail.value=fail.value, + transform=transform, + ... + ) + ) + +setMethod( + "probe.match.objfun", + signature=signature(object="probed.pomp"), + function (object, probes, nsim, seed, ...) { - transform <- as.logical(transform) - - if (eval.only) { - est <- character(0) - guess <- numeric(0) - transform <- FALSE - } else { - if (!is.character(est)) stop(sQuote("est")," must be a vector of parameter names") - if (length(start)<1) - stop(sQuote("start")," must be supplied if ",sQuote("object")," contains no parameters") - if (transform) { - tstart <- partrans(object,start,dir="inverse") - if (is.null(names(tstart))||(!all(est%in%names(tstart)))) - stop(sQuote("est")," must refer to parameters named in ",sQuote("partrans(object,start,dir=\"inverse\")")) - guess <- tstart[est] - } else { - if (is.null(names(start))||(!all(est%in%names(start)))) - stop(sQuote("est")," must refer to parameters named in ",sQuote("start")) - guess <- start[est] - } - } - - obj <- as(object,"pomp") - coef(obj) <- start - - obj.fn <- probe.match.objfun( - obj, - est=est, + if (missing(probes)) probes <- object at probes + if (missing(nsim)) nsim <- nrow(object at simvals) + if (missing(seed)) seed <- object at seed + + probe.match.objfun( + object=as(object,"pomp"), probes=probes, nsim=nsim, seed=seed, - fail.value=fail.value, - transform=transform + ... ) - - - if (eval.only) { - - val <- obj.fn(guess) - conv <- NA - evals <- as.integer(c(1,0)) - msg <- "no optimization performed" - - } else { - - if (method == 'subplex') { - opt <- subplex::subplex(par=guess,fn=obj.fn,control=list(...)) - } else if (method=="sannbox") { - opt <- sannbox(par=guess,fn=obj.fn,control=list(...)) - } else { - opt <- optim(par=guess,fn=obj.fn,method=method,control=list(...)) - } - - if (!is.null(names(opt$par)) && !all(est==names(opt$par))) - stop("mismatch between parameter names returned by optimizer and ",sQuote("est")) - coef(obj,est,transform=transform) <- unname(opt$par) - msg <- if (is.null(opt$message)) character(0) else opt$message - conv <- opt$convergence - val <- opt$value - evals <- opt$counts - } - - new( - "probe.matched.pomp", - probe( - obj, - probes=probes, - nsim=nsim, - seed=seed - ), - start=start, - transform=transform, - est=as.character(est), - value=val, - convergence=as.integer(conv), - evals=as.integer(evals), - msg=as.character(msg) - ) -} - + } + ) + setMethod( "probe.match", signature=signature(object="pomp"), function(object, start, est = character(0), - probes, weights, - nsim, seed = NULL, - method = c("subplex","Nelder-Mead","SANN","BFGS","sannbox"), + probes, nsim, seed = NULL, + method = c("subplex","Nelder-Mead","SANN","BFGS", + "sannbox","nloptr"), verbose = getOption("verbose"), - eval.only = FALSE, fail.value = NA, transform = FALSE, + fail.value = NA, + transform = FALSE, ...) { - - transform <- as.logical(transform) + if (missing(start)) start <- coef(object) if (missing(probes)) stop(sQuote("probes")," must be supplied") if (missing(nsim)) stop(sQuote("nsim")," must be supplied") - if (missing(weights)) weights <- 1 method <- match.arg(method) + est <- as.character(est) + transform <- as.logical(transform) + fail.value <- as.numeric(fail.value) - probe.match.internal( - object=object, - start=start, - est=est, - probes=probes, - weights=weights, - nsim=nsim, - seed=seed, - method=method, - verbose=verbose, - eval.only=eval.only, - fail.value=fail.value, - transform=transform, - ... - ) + m <- minim.internal( + objfun=probe.match.objfun( + object=object, + params=start, + est=est, + probes=probes, + nsim=nsim, + seed=seed, + fail.value=fail.value, + transform=transform + ), + start=start, + est=est, + object=object, + method=method, + transform=transform, + verbose=verbose, + ... + ) + + coef(object) <- m$params + + new( + "probe.matched.pomp", + probe( + object, + probes=probes, + nsim=nsim, + seed=seed + ), + transform=transform, + est=est, + fail.value=fail.value, + value=m$value, + evals=m$evals, + convergence=m$convergence, + msg=m$msg + ) } ) setMethod( "probe.match", signature=signature(object="probed.pomp"), - function(object, start, est = character(0), - probes, weights, - nsim, seed = NULL, - method = c("subplex","Nelder-Mead","SANN","BFGS","sannbox"), - verbose = getOption("verbose"), - eval.only = FALSE, fail.value = NA, transform = FALSE, ...) { - - transform <- as.logical(transform) + function(object, probes, nsim, seed, ..., + verbose = getOption("verbose")) + { - if (missing(start)) start <- coef(object) if (missing(probes)) probes <- object at probes if (missing(nsim)) nsim <- nrow(object at simvals) - if (missing(weights)) weights <- 1 - - method <- match.arg(method) + if (missing(seed)) seed <- object at seed - probe.match.internal( - object=object, - start=start, - est=est, - probes=probes, - weights=weights, - nsim=nsim, - seed=seed, - method=method, - verbose=verbose, - eval.only=eval.only, - fail.value=fail.value, - transform=transform, - ... - ) + f <- selectMethod("probe.match","pomp") + + f( + object=object, + probes=probes, + nsim=nsim, + seed=seed, + verbose=verbose, + ... + ) } ) setMethod( "probe.match", signature=signature(object="probe.matched.pomp"), - function(object, start, est, - probes, weights, - nsim, seed = NULL, - method = c("subplex","Nelder-Mead","SANN","BFGS","sannbox"), - verbose = getOption("verbose"), - eval.only = FALSE, fail.value, transform, ...) { - - if (missing(start)) start <- coef(object) + function(object, est, probes, nsim, seed, transform, + fail.value, ..., verbose = getOption("verbose")) + { + if (missing(est)) est <- object at est + if (missing(probes)) probes <- object at probes + if (missing(nsim)) nsim <- nrow(object at simvals) + if (missing(seed)) seed <- object at seed if (missing(transform)) transform <- object at transform - - if (missing(probes)) - probes <- object at probes - - if (missing(nsim)) - nsim <- nrow(object at simvals) - - if (missing(weights)) weights <- 1 - if (missing(fail.value)) fail.value <- object at fail.value - - method <- match.arg(method) - probe.match.internal( - object=object, - start=start, - est=est, - probes=probes, - weights=weights, - nsim=nsim, - seed=seed, - method=method, - verbose=verbose, - eval.only=eval.only, - fail.value=fail.value, - transform=transform, - ... - ) + f <- selectMethod("probe.match","pomp") + + f( + object=object, + est=est, + probes=probes, + nsim=nsim, + seed=seed, + transform=transform, + fail.value=fail.value, + verbose=verbose, + ... + ) } ) - -probe.mismatch <- function (par, est, object, probes, params, - nsim = 1, seed = NULL, - weights, datval, - fail.value = NA) { - if (missing(par)) par <- numeric(0) - if (missing(est)) est <- integer(0) - if (missing(params)) params <- coef(object) - - params[est] <- par - - ## apply probes to model simulations - simval <- .Call( - apply_probe_sim, - object=object, - nsim=nsim, - params=params, - seed=seed, - probes=probes, - datval=datval - ) - - ## compute a measure of the discrepancies between simulations and data - sim.means <- colMeans(simval) - simval <- sweep(simval,2,sim.means) - discrep <- ((datval-sim.means)^2)/colMeans(simval^2) - if ((length(weights)>1) && (length(weights)!=length(discrep))) - stop(length(discrep)," probes have been computed, but ",length(weights)," have been supplied") - if (!all(is.finite(discrep))) { - mismatch <- fail.value - } else if (length(weights)>1) { - mismatch <- sum(discrep*weights)/sum(weights) - } else { - mismatch <- sum(discrep) - } - - mismatch -} - -neg.synth.loglik <- function (par, est, object, probes, params, - nsim = 1, seed = NULL, - weights, datval, - fail.value = NA) { - if (missing(par)) par <- numeric(0) - if (missing(est)) est <- integer(0) - if (missing(params)) params <- coef(object) - - params[est] <- par - - ## apply probes to model simulations - simval <- .Call( - apply_probe_sim, - object=object, - nsim=nsim, - params=params, - seed=seed, - probes=probes, - datval=datval - ) - - ll <- .Call(synth_loglik,simval,datval) - if (is.finite(ll)||is.na(fail.value)) -ll else fail.value -} Modified: pkg/pomp/R/probe.R =================================================================== --- pkg/pomp/R/probe.R 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/R/probe.R 2014-03-20 15:07:33 UTC (rev 895) @@ -7,16 +7,20 @@ simvals="array", quantiles="numeric", pvals="numeric", - synth.loglik="numeric" + synth.loglik="numeric", + seed="integer" ) ) probe.internal <- function (object, probes, params, nsim = 1, seed = NULL, ...) { + if (!is.list(probes)) probes <- list(probes) if (!all(sapply(probes,is.function))) stop(sQuote("probes")," must be a function or a list of functions") if (!all(sapply(probes,function(f)length(formals(f))==1))) stop("each probe must be a function of a single argument") + + seed <- as.integer(seed) if (missing(params)) params <- coef(object) @@ -25,6 +29,7 @@ nprobes <- length(datval) if (nprobes > nsim) stop(sQuote("nsim"),"(=",nsim,") should be (much) larger than the number of probes (=",nprobes,")") + ## apply probes to model simulations simval <- .Call( apply_probe_sim, @@ -59,29 +64,41 @@ simvals=simval, quantiles=quants, pvals=pvals, - synth.loglik=ll + synth.loglik=ll, + seed=seed ) } -setMethod("probe",signature(object="pomp"), - function (object, probes, params, nsim = 1, seed = NULL, ...) { - probe.internal(object=object,probes=probes,params=params, - nsim=nsim,seed=seed,...) +setMethod( + "probe", + signature=signature(object="pomp"), + function (object, probes, params, nsim = 1, seed = NULL, ...) + { + probe.internal( + object=object, + probes=probes, + params=params, + nsim=nsim, + seed=seed, + ... + ) } ) setMethod( "probe", - signature(object="probed.pomp"), - function (object, probes, params, nsim, ...) { + signature=signature(object="probed.pomp"), + function (object, probes, params, nsim, seed, ...) { if (missing(probes)) probes <- object at probes if (missing(nsim)) nsim <- nrow(object at simvals) + if (missing(seed)) seed <- object at seed probe( - as(object,"pomp"), + object=as(object,"pomp"), probes=probes, nsim=nsim, + seed=seed, ... ) } @@ -187,3 +204,4 @@ ) setMethod("logLik",signature(object="probed.pomp"),function(object,...)object at synth.loglik) +setMethod("$",signature=signature(x="probed.pomp"),function(x, name)slot(x,name)) Modified: pkg/pomp/R/simulate-pomp.R =================================================================== --- pkg/pomp/R/simulate-pomp.R 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/R/simulate-pomp.R 2014-03-20 15:07:33 UTC (rev 895) @@ -27,7 +27,8 @@ params <- as.matrix(params) - if (!is.null(seed)) { # set the random seed (be very careful about this) + ## set the random seed (be very careful about this) + if (!is.null(seed) && length(seed)>0) { if (!exists('.Random.seed',envir=.GlobalEnv)) runif(1) save.seed <- get('.Random.seed',envir=.GlobalEnv) set.seed(seed) @@ -55,7 +56,8 @@ if (inherits(retval,'try-error')) stop(sQuote("simulate")," error",call.=FALSE) - if (!is.null(seed)) { # restore the RNG state + ## restore the RNG state + if (!is.null(seed) && length(seed)>0) { assign('.Random.seed',save.seed,envir=.GlobalEnv) } @@ -113,11 +115,22 @@ retval } -setMethod("simulate",signature=signature(object="pomp"), +setMethod( + "simulate", + signature=signature(object="pomp"), definition=function (object, nsim = 1, seed = NULL, params, states = FALSE, obs = FALSE, times, t0, as.data.frame = FALSE, ...) - simulate.internal(object=object,nsim=nsim,seed=seed,params=params, - states=states,obs=obs,times=times,t0=t0, - as.data.frame=as.data.frame,...) + simulate.internal( + object=object, + nsim=nsim, + seed=seed, + params=params, + states=states, + obs=obs, + times=times, + t0=t0, + as.data.frame=as.data.frame, + ... + ) ) Modified: pkg/pomp/R/traj-match.R =================================================================== --- pkg/pomp/R/traj-match.R 2014-03-17 22:02:29 UTC (rev 894) +++ pkg/pomp/R/traj-match.R 2014-03-20 15:07:33 UTC (rev 895) @@ -2,7 +2,6 @@ "traj.matched.pomp", contains="pomp", representation=representation( - start="numeric", transform="logical", est="character", evals="integer", @@ -32,11 +31,13 @@ } ) -traj.match.objfun <- function (object, params, est, transform = FALSE, ...) { +tmof.internal <- function (object, params, est, transform, ...) { - transform <- as.logical(transform) + object <- as(object,"pomp") if (missing(est)) est <- character(0) - if (!is.character(est)) stop(sQuote("est")," must be a vector of parameter names") + est <- as.character(est) + transform <- as.logical(transform) + if (missing(params)) params <- coef(object) if ((!is.numeric(params))||(is.null(names(params)))) stop(sQuote("params")," must be a named numeric vector") @@ -46,156 +47,105 @@ if (any(is.na(par.est.idx))) stop("parameter(s): ",sQuote(est[is.na(par.est.idx)])," not found in ",sQuote("params")) - obj.fn <- function (par) { + function (par) { params[par.est.idx] <- par - if (transform) { + if (transform) tparams <- partrans(object,params,dir="forward") - d <- dmeasure( + d <- dmeasure( + object, + y=object at data, + x=trajectory( object, - y=object at data, - x=trajectory(object,params=tparams,...), - times=time(object), - params=tparams, - log=TRUE - ) - } else { - d <- dmeasure( - object, - y=object at data, - x=trajectory(object,params=params,...), - times=time(object), - params=params, - log=TRUE - ) - } + params=if (transform) tparams else params, + ... + ), + times=time(object), + params=if (transform) tparams else params, + log=TRUE + ) -sum(d) } - - obj.fn } -traj.match.internal <- function (object, start, est, method, gr, eval.only, transform, ...) { - - transform <- as.logical(transform) +setMethod( + "traj.match.objfun", + signature=signature(object="pomp"), + function (object, params, est, transform = FALSE, ...) + tmof.internal( + object=object, + params=params, + est=est, + transform=transform, + ... + ) + ) - if (eval.only) { - est <- character(0) - guess <- numeric(0) - transform <- FALSE - } else { - if (!is.character(est)) stop(sQuote("est")," must be a vector of parameter names") - if (length(start)<1) - stop(sQuote("start")," must be supplied if ",sQuote("object")," contains no parameters") - if (transform) { - tstart <- partrans(object,start,dir="inverse") - if (is.null(names(tstart))||(!all(est%in%names(tstart)))) - stop(sQuote("est")," must refer to parameters named in ",sQuote("partrans(object,start,dir=\"inverse\")")) - guess <- tstart[est] - } else { - if (is.null(names(start))||(!all(est%in%names(start)))) - stop(sQuote("est")," must refer to parameters named in ",sQuote("start")) - guess <- start[est] - } - } - - obj <- as(object,"pomp") - coef(obj) <- start - - obj.fn <- traj.match.objfun(obj,est=est,transform=transform) - - if (eval.only) { - - val <- obj.fn(guess) - conv <- NA - evals <- c(1,0) - msg <- "no optimization performed" - - } else { - - if (method=="subplex") { - opt <- subplex::subplex(par=guess,fn=obj.fn,control=list(...)) - } else if (method=="sannbox") { - opt <- sannbox(par=guess,fn=obj.fn,control=list(...)) - } else { - opt <- optim(par=guess,fn=obj.fn,gr=gr,method=method,control=list(...)) - } - - if (!is.null(names(opt$par)) && !all(est==names(opt$par))) - stop("mismatch between parameter names returned by optimizer and ",sQuote("est")) - coef(obj,est,transform=transform) <- unname(opt$par) - msg <- if (is.null(opt$message)) character(0) else opt$message - conv <- opt$convergence - evals <- opt$counts - val <- opt$value - - } - - ## fill 'states' slot of returned object with the trajectory - x <- trajectory(obj) - obj at states <- array(data=x,dim=dim(x)[c(1L,3L)]) - rownames(obj at states) <- rownames(x) - - new( - "traj.matched.pomp", - obj, - start=start, - transform=transform, - est=as.character(est), - evals=as.integer(evals), - convergence=as.integer(conv), - msg=msg, - value=as.numeric(-val) - ) -} - -traj.match <- function (object, ...) - stop("function ",sQuote("traj.match")," is undefined for objects of class ",sQuote(class(object))) - setMethod( "traj.match", signature=signature(object="pomp"), - function (object, start, est, - method = c("Nelder-Mead","subplex","SANN","BFGS","sannbox"), - gr = NULL, eval.only = FALSE, transform = FALSE, ...) { - transform <- as.logical(transform) + function (object, start, est = character(0), + method = c("Nelder-Mead","subplex","SANN","BFGS", + "sannbox","nloptr"), + transform = FALSE, ...) + { + if (missing(start)) start <- coef(object) - if (!eval.only && missing(est)) - stop(sQuote("est")," must be supplied if optimization is to be done") - if (eval.only) est <- character(0) + method <- match.arg(method) - traj.match.internal( - object=object, + est <- as.character(est) + transform <- as.logical(transform) + + m <- minim.internal( + objfun=traj.match.objfun( + object=object, + params=start, + est=est, + transform=transform + ), start=start, est=est, + object=object, method=method, - gr=gr, - eval.only=eval.only, transform=transform, ... ) + + ## fill params slot appropriately [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 895 From noreply at r-forge.r-project.org Thu Mar 20 18:57:02 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 20 Mar 2014 18:57:02 +0100 (CET) Subject: [Pomp-commits] r896 - www/vignettes Message-ID: <20140320175702.21358186707@r-forge.r-project.org> Author: kingaa Date: 2014-03-20 18:57:01 +0100 (Thu, 20 Mar 2014) New Revision: 896 Modified: www/vignettes/advanced_topics_in_pomp.R www/vignettes/advanced_topics_in_pomp.Rnw www/vignettes/advanced_topics_in_pomp.pdf www/vignettes/bsmc-ricker-flat-prior.rda www/vignettes/bsmc-ricker-normal-prior.rda www/vignettes/complex-sir-def.rda www/vignettes/gompertz-multi-mif.rda www/vignettes/gompertz-pfilter-guess.rda www/vignettes/gompertz-trajmatch.rda www/vignettes/intro_to_pomp.R www/vignettes/intro_to_pomp.Rnw www/vignettes/intro_to_pomp.pdf www/vignettes/nlf-block-boot.rda www/vignettes/nlf-boot.rda www/vignettes/nlf-fit-from-truth.rda www/vignettes/nlf-fits.rda www/vignettes/nlf-lag-tests.rda www/vignettes/nlf-multi-short.rda www/vignettes/plugin-C-code.rda www/vignettes/plugin-R-code.rda www/vignettes/ricker-comparison.rda www/vignettes/ricker-first-probe.rda www/vignettes/ricker-mif.rda www/vignettes/ricker-probe-match.rda www/vignettes/ricker-probe.rda www/vignettes/sim-sim.rda www/vignettes/sir-pomp-def.rda www/vignettes/vectorized-C-code.rda www/vignettes/vectorized-R-code.rda Log: - update vignettes Modified: www/vignettes/advanced_topics_in_pomp.R =================================================================== --- www/vignettes/advanced_topics_in_pomp.R 2014-03-20 15:07:33 UTC (rev 895) +++ www/vignettes/advanced_topics_in_pomp.R 2014-03-20 17:57:01 UTC (rev 896) @@ -707,7 +707,6 @@ ) -> sir simulate(sir) -> x pfilter(sir,Np=500) -> pf - dyn.unload("SIR.so") print(logLik(pf)) } Modified: www/vignettes/advanced_topics_in_pomp.Rnw =================================================================== --- www/vignettes/advanced_topics_in_pomp.Rnw 2014-03-20 15:07:33 UTC (rev 895) +++ www/vignettes/advanced_topics_in_pomp.Rnw 2014-03-20 17:57:01 UTC (rev 896) @@ -675,7 +675,6 @@ <> simulate(sir) -> x pfilter(sir,Np=500) -> pf - dyn.unload("SIR.so") print(logLik(pf)) } @ Modified: www/vignettes/advanced_topics_in_pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/bsmc-ricker-flat-prior.rda =================================================================== (Binary files differ) Modified: www/vignettes/bsmc-ricker-normal-prior.rda =================================================================== (Binary files differ) Modified: www/vignettes/complex-sir-def.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-multi-mif.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-pfilter-guess.rda =================================================================== (Binary files differ) Modified: www/vignettes/gompertz-trajmatch.rda =================================================================== (Binary files differ) Modified: www/vignettes/intro_to_pomp.R =================================================================== --- www/vignettes/intro_to_pomp.R 2014-03-20 15:07:33 UTC (rev 895) +++ www/vignettes/intro_to_pomp.R 2014-03-20 17:57:01 UTC (rev 896) @@ -576,29 +576,35 @@ ################################################### ### code chunk number 49: trajmatch-plot ################################################### + op <- par(mfrow=c(1,1),mar=c(3,3,0,0),mgp=c(2,1,0),bty='l') plot(time(tm),obs(tm,"Y"),xlab="time",ylab=expression(X,Y),type='o') lines(time(tm),states(tm,"X"),lwd=2) par(op) + ################################################### ### code chunk number 50: ricker-map-defn ################################################### + ricker.sim <- function (x, t, params, delta.t, ...) { e <- rnorm(n=1,mean=0,sd=params["sigma"]) - xnew <- c( - params["r"]*x["N"]*exp(-x["N"]+e), - e - ) - names(xnew) <- c("N","e") - xnew + setNames( + c( + params["r"]*x["N"]*exp(-x["N"]+e), + e + ), + c("N","e") + ) } + ################################################### ### code chunk number 51: ricker-pomp ################################################### + ricker <- pomp( data=data.frame(time=seq(0,50,by=1),y=NA), times="time", @@ -618,6 +624,7 @@ ricker <- simulate(ricker,seed=73691676L) + ################################################### ### code chunk number 52: get-ricker ################################################### @@ -780,16 +787,10 @@ ## res <- rbind( ## cbind(guess=guess,truth=coef(ricker),MLE=coef(mf),PM=coef(pm)), ## loglik=c( -## pf.guess$loglik, -## pf.truth$loglik, -## pf.mf$loglik, -## pf.pm$loglik +## logLik(pf.guess),logLik(pf.truth),logLik(pf.mf),logLik(pf.pm) ## ), ## synth.loglik=c( -## summary(pb.guess)$synth.loglik, -## summary(pb.truth)$synth.loglik, -## summary(pb.mf)$synth.loglik, -## summary(pm)$synth.loglik +## logLik(pb.guess),logLik(pb.truth),logLik(pb.mf),logLik(pm) ## ) ## ) @@ -809,16 +810,10 @@ res <- rbind( cbind(guess=guess,truth=coef(ricker),MLE=coef(mf),PM=coef(pm)), loglik=c( - pf.guess$loglik, - pf.truth$loglik, - pf.mf$loglik, - pf.pm$loglik + logLik(pf.guess),logLik(pf.truth),logLik(pf.mf),logLik(pf.pm) ), synth.loglik=c( - summary(pb.guess)$synth.loglik, - summary(pb.truth)$synth.loglik, - summary(pb.mf)$synth.loglik, - summary(pm)$synth.loglik + logLik(pb.guess),logLik(pb.truth),logLik(pb.mf),logLik(pm) ) ) save(res,file=binary.file,compress='xz') @@ -924,7 +919,7 @@ ################################################### -### code chunk number 69: intro_to_pomp.Rnw:1121-1122 +### code chunk number 69: intro_to_pomp.Rnw:1122-1123 ################################################### fits @@ -1109,7 +1104,7 @@ ################################################### -### code chunk number 77: intro_to_pomp.Rnw:1267-1268 +### code chunk number 77: intro_to_pomp.Rnw:1268-1269 ################################################### apply(fvals,2,function(x)sd(x)/mean(x)) @@ -1151,7 +1146,7 @@ ################################################### -### code chunk number 80: intro_to_pomp.Rnw:1306-1307 +### code chunk number 80: intro_to_pomp.Rnw:1307-1308 ################################################### set.seed(32329L) @@ -1221,7 +1216,7 @@ ################################################### -### code chunk number 83: intro_to_pomp.Rnw:1344-1345 +### code chunk number 83: intro_to_pomp.Rnw:1345-1346 ################################################### apply(pars,2,sd) @@ -1306,101 +1301,126 @@ ################################################### ### code chunk number 87: bsmc-example-flat-prior-1 ################################################### -require(pomp) + pompExample(ricker) +ricker <- pomp( + ricker, + rprior=function (params, ...) { + params["r"] <- exp(runif(n=1,min=2,max=5)) + params["sigma"] <- runif(n=1,min=0.1,max=1) + params + } + ) + -################################################### -### code chunk number 88: bsmc-example-flat-prior-2 (eval = FALSE) -################################################### -## set.seed(136872209L) -## Np <- 10000 -## prior1 <- parmat(coef(ricker),nrep=Np) -## prior1["r",] <- exp(runif(n=Np,min=2,max=5)) -## prior1["sigma",] <- runif(n=Np,min=0.1,max=1) - ################################################### -### code chunk number 89: bsmc-example-flat-prior-3 (eval = FALSE) +### code chunk number 88: bsmc-example-flat-prior-3 (eval = FALSE) ################################################### -## fit1 <- bsmc(ricker,params=prior1,transform=TRUE, -## est=c("r","sigma"),smooth=0.2) +## +## fit1 <- bsmc(ricker,Np=10000,transform=TRUE, +## est=c("r","sigma"),smooth=0.2, +## seed=1050180387L) +## ################################################### -### code chunk number 90: bsmc-example-flat-prior-eval +### code chunk number 89: bsmc-example-flat-prior-eval ################################################### binary.file <- "bsmc-ricker-flat-prior.rda" if (file.exists(binary.file)) { load(binary.file) } else { -require(pomp) + pompExample(ricker) -set.seed(136872209L) -Np <- 10000 -prior1 <- parmat(coef(ricker),nrep=Np) -prior1["r",] <- exp(runif(n=Np,min=2,max=5)) -prior1["sigma",] <- runif(n=Np,min=0.1,max=1) - fit1 <- bsmc(ricker,params=prior1,transform=TRUE, - est=c("r","sigma"),smooth=0.2) + +ricker <- pomp( + ricker, + rprior=function (params, ...) { + params["r"] <- exp(runif(n=1,min=2,max=5)) + params["sigma"] <- runif(n=1,min=0.1,max=1) + params + } + ) + + + fit1 <- bsmc(ricker,Np=10000,transform=TRUE, + est=c("r","sigma"),smooth=0.2, + seed=1050180387L) + save(fit1,file=binary.file,compress="xz") } ################################################### -### code chunk number 91: bsmc-example-flat-prior-coef +### code chunk number 90: bsmc-example-flat-prior-coef ################################################### + signif(coef(fit1),digits=2) + ################################################### -### code chunk number 92: bsmc-example-flat-prior-plot +### code chunk number 91: bsmc-example-flat-prior-plot ################################################### - plot(fit1,pars=c("r","sigma"),thin=5000) +plot(fit1,pars=c("r","sigma"),thin=5000) + + ################################################### -### code chunk number 93: bsmc-example-normal-prior (eval = FALSE) +### code chunk number 92: bsmc-example-normal-prior (eval = FALSE) ################################################### -## set.seed(90348704L) -## Np <- 10000 -## prior2 <- parmat(coef(ricker),nrep=Np) -## ## log-normal prior on r -## prior2["r",] <- rlnorm(n=Np,meanlog=4,sdlog=3) -## ## log-normal prior on sigma -## prior2["sigma",] <- rlnorm(n=Np,meanlog=log(0.5),sdlog=5) -## fit2 <- bsmc(ricker,params=prior2,transform=TRUE, -## est=c("r","sigma"),smooth=0.2) +## +## ricker <- pomp(ricker, +## rprior=function (params, ...) { +## x <- rlnorm(n=2,meanlog=c(4,log(0.5)),sdlog=c(3,5)) +## params[c("r","sigma")] <- x +## params +## } +## ) +## +## fit2 <- bsmc(ricker,transform=TRUE,Np=10000, +## est=c("r","sigma"),smooth=0.2, +## seed=90348704L) +## ################################################### -### code chunk number 94: bsmc-example-normal-prior-eval +### code chunk number 93: bsmc-example-normal-prior-eval ################################################### binary.file <- "bsmc-ricker-normal-prior.rda" if (file.exists(binary.file)) { load(binary.file) } else { -set.seed(90348704L) -Np <- 10000 -prior2 <- parmat(coef(ricker),nrep=Np) -## log-normal prior on r -prior2["r",] <- rlnorm(n=Np,meanlog=4,sdlog=3) -## log-normal prior on sigma -prior2["sigma",] <- rlnorm(n=Np,meanlog=log(0.5),sdlog=5) -fit2 <- bsmc(ricker,params=prior2,transform=TRUE, - est=c("r","sigma"),smooth=0.2) + +ricker <- pomp(ricker, + rprior=function (params, ...) { + x <- rlnorm(n=2,meanlog=c(4,log(0.5)),sdlog=c(3,5)) + params[c("r","sigma")] <- x + params + } + ) + +fit2 <- bsmc(ricker,transform=TRUE,Np=10000, + est=c("r","sigma"),smooth=0.2, + seed=90348704L) + save(fit2,file=binary.file,compress="xz") } ################################################### -### code chunk number 95: bsmc-example-normal-prior-show +### code chunk number 94: bsmc-example-normal-prior-show ################################################### + signif(coef(fit2),digits=2) + ################################################### -### code chunk number 96: sir-proc-sim-def +### code chunk number 95: sir-proc-sim-def ################################################### sir.proc.sim <- function (x, t, params, delta.t, ...) { ## unpack the parameters @@ -1426,7 +1446,7 @@ ################################################### -### code chunk number 97: sir-pomp-def (eval = FALSE) +### code chunk number 96: sir-pomp-def (eval = FALSE) ################################################### ## simulate( ## pomp( @@ -1463,7 +1483,7 @@ ################################################### -### code chunk number 98: sir-pomp-def-eval +### code chunk number 97: sir-pomp-def-eval ################################################### binary.file <- "sir-pomp-def.rda" if (file.exists(binary.file)) { @@ -1506,7 +1526,7 @@ ################################################### -### code chunk number 99: sir-pomp-def-with-skel (eval = FALSE) +### code chunk number 98: sir-pomp-def-with-skel (eval = FALSE) ################################################### ## sir <- pomp( ## sir, @@ -1535,20 +1555,20 @@ ################################################### -### code chunk number 100: sir-plot +### code chunk number 99: sir-plot ################################################### plot(sir) ################################################### -### code chunk number 101: seas-basis +### code chunk number 100: seas-basis ################################################### tbasis <- seq(0,20,by=1/52) basis <- periodic.bspline.basis(tbasis,nbasis=3,degree=2,period=1,names="seas%d") ################################################### -### code chunk number 102: complex-sir-def (eval = FALSE) +### code chunk number 101: complex-sir-def (eval = FALSE) ################################################### ## complex.sir.proc.sim <- function (x, t, params, delta.t, covars, ...) { ## ## unpack the parameters @@ -1608,7 +1628,7 @@ ################################################### -### code chunk number 103: complex-sir-def-eval +### code chunk number 102: complex-sir-def-eval ################################################### binary.file <- "complex-sir-def.rda" if (file.exists(binary.file)) { @@ -1674,7 +1694,7 @@ ################################################### -### code chunk number 104: seas-basis-plot +### code chunk number 103: seas-basis-plot ################################################### op <- par(mar=c(5,5,1,5)) matplot(tbasis,basis,xlim=c(0,2),type='l',lwd=2,bty='u', @@ -1697,13 +1717,13 @@ ################################################### -### code chunk number 105: complex-sir-plot +### code chunk number 104: complex-sir-plot ################################################### plot(complex.sir) ################################################### -### code chunk number 106: restore-opts +### code chunk number 105: restore-opts ################################################### options(glop) Modified: www/vignettes/intro_to_pomp.Rnw =================================================================== --- www/vignettes/intro_to_pomp.Rnw 2014-03-20 15:07:33 UTC (rev 895) +++ www/vignettes/intro_to_pomp.Rnw 2014-03-20 17:57:01 UTC (rev 896) @@ -795,10 +795,12 @@ \begin{figure} <>= + op <- par(mfrow=c(1,1),mar=c(3,3,0,0),mgp=c(2,1,0),bty='l') plot(time(tm),obs(tm,"Y"),xlab="time",ylab=expression(X,Y),type='o') lines(time(tm),states(tm,"X"),lwd=2) par(op) + @ \caption{ Illustration of trajectory matching. @@ -831,21 +833,25 @@ It will be convenient to work with log-transformed parameters $\log r$, $\log\sigma$, $\log\phi$. Thus <>= + ricker.sim <- function (x, t, params, delta.t, ...) { e <- rnorm(n=1,mean=0,sd=params["sigma"]) - xnew <- c( - params["r"]*x["N"]*exp(-x["N"]+e), - e - ) - names(xnew) <- c("N","e") - xnew + setNames( + c( + params["r"]*x["N"]*exp(-x["N"]+e), + e + ), + c("N","e") + ) } + @ Note that, in this implementation, $e$ is taken to be a state variable. This is not strictly necessary, but it might prove useful, for example, in \emph{a posteriori} diagnostic checking of model residuals. Now we can construct a \code{pomp} object; in this case, we use the \code{discrete.time.sim} plug-in. Note how we specify the measurement model. <>= + ricker <- pomp( data=data.frame(time=seq(0,50,by=1),y=NA), times="time", @@ -863,12 +869,13 @@ e.0=0 ) ricker <- simulate(ricker,seed=73691676L) + @ A pre-built \code{pomp} object implementing this model is included with the package. Its \code{rprocess}, \code{rmeasure}, and \code{dmeasure} components are written in C and are thus a bit faster than the \R\ implementation above. Do -<>= +<>= pompExample(ricker) @ to load this \code{pomp} object. @@ -1021,16 +1028,10 @@ res <- rbind( cbind(guess=guess,truth=coef(ricker),MLE=coef(mf),PM=coef(pm)), loglik=c( - pf.guess$loglik, - pf.truth$loglik, - pf.mf$loglik, - pf.pm$loglik + logLik(pf.guess),logLik(pf.truth),logLik(pf.mf),logLik(pf.pm) ), synth.loglik=c( - summary(pb.guess)$synth.loglik, - summary(pb.truth)$synth.loglik, - summary(pb.mf)$synth.loglik, - summary(pm)$synth.loglik + logLik(pb.guess),logLik(pb.truth),logLik(pb.mf),logLik(pm) ) ) <>= @@ -1404,26 +1405,33 @@ The approximate Bayesian sequential Monte Carlo method of \citet{Liu2001b} is implemented in \pkg{pomp}. The following demonstrates its use on the Ricker model. -First, we draw a sample from our prior distribution. -Here, we'll use uniform priors on two model parameters ($\log{r}$ and $\sigma$), leaving the others fixed at their true values. -<>= -require(pomp) +First, we'll specify a prior distribution. +Bayesian sequential Monte Carlo requires only that we be able to simulate from the prior, so we'll need to write a function that draws samples. +We then give this function to the \code{rprior} argument of \code{pomp}. +Let's use uniform priors on $\log{r}$ and $\sigma$, leaving the others fixed at their true values. +<>= + pompExample(ricker) + +ricker <- pomp( + ricker, + rprior=function (params, ...) { + params["r"] <- exp(runif(n=1,min=2,max=5)) + params["sigma"] <- runif(n=1,min=0.1,max=1) + params + } + ) + @ We'll use 10,000 particles, so we'll need that many samples from the prior distribution. -<>= -set.seed(136872209L) -Np <- 10000 -prior1 <- parmat(coef(ricker),nrep=Np) -prior1["r",] <- exp(runif(n=Np,min=2,max=5)) -prior1["sigma",] <- runif(n=Np,min=0.1,max=1) -@ -Now \code{params} holds these 10,000 samples. -The following runs the sequential Monte Carlo algorithm. +The following runs the Bayesian sequential Monte Carlo algorithm with 10,000 particles. Note that, by specifying \code{transform=TRUE}, we cause the estimation to proceed on the transformed scale. <>= - fit1 <- bsmc(ricker,params=prior1,transform=TRUE, - est=c("r","sigma"),smooth=0.2) + + fit1 <- bsmc(ricker,Np=10000,transform=TRUE, + est=c("r","sigma"),smooth=0.2, + seed=1050180387L) + @ <>= binary.file <- "bsmc-ricker-flat-prior.rda" @@ -1431,7 +1439,6 @@ load(binary.file) } else { <> -<> <> save(fit1,file=binary.file,compress="xz") } @@ -1439,13 +1446,17 @@ Fig.~\ref{fig:bsmc-example-flat-prior} shows the results of this computation. Obtain the posterior medians of the parameters by doing <>= + signif(coef(fit1),digits=2) + @ Note that these are reported on the natural (i.e., untransformed) scale. \begin{figure} <>= - plot(fit1,pars=c("r","sigma"),thin=5000) + +plot(fit1,pars=c("r","sigma"),thin=5000) + @ \caption{ Results of \code{bsmc} on the Ricker model. @@ -1459,15 +1470,19 @@ To repeat the procedure with log-normal priors on $r$ and $\sigma$, one might do the following. <>= -set.seed(90348704L) -Np <- 10000 -prior2 <- parmat(coef(ricker),nrep=Np) -## log-normal prior on r -prior2["r",] <- rlnorm(n=Np,meanlog=4,sdlog=3) -## log-normal prior on sigma -prior2["sigma",] <- rlnorm(n=Np,meanlog=log(0.5),sdlog=5) -fit2 <- bsmc(ricker,params=prior2,transform=TRUE, - est=c("r","sigma"),smooth=0.2) + +ricker <- pomp(ricker, + rprior=function (params, ...) { + x <- rlnorm(n=2,meanlog=c(4,log(0.5)),sdlog=c(3,5)) + params[c("r","sigma")] <- x + params + } + ) + +fit2 <- bsmc(ricker,transform=TRUE,Np=10000, + est=c("r","sigma"),smooth=0.2, + seed=90348704L) + <>= binary.file <- "bsmc-ricker-normal-prior.rda" if (file.exists(binary.file)) { @@ -1477,7 +1492,9 @@ save(fit2,file=binary.file,compress="xz") } <>= + signif(coef(fit2),digits=2) + @ \clearpage Modified: www/vignettes/intro_to_pomp.pdf =================================================================== (Binary files differ) Modified: www/vignettes/nlf-block-boot.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-boot.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-fit-from-truth.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-fits.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-lag-tests.rda =================================================================== (Binary files differ) Modified: www/vignettes/nlf-multi-short.rda =================================================================== (Binary files differ) Modified: www/vignettes/plugin-C-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/plugin-R-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-comparison.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-first-probe.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-mif.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-probe-match.rda =================================================================== (Binary files differ) Modified: www/vignettes/ricker-probe.rda =================================================================== (Binary files differ) Modified: www/vignettes/sim-sim.rda =================================================================== (Binary files differ) Modified: www/vignettes/sir-pomp-def.rda =================================================================== (Binary files differ) Modified: www/vignettes/vectorized-C-code.rda =================================================================== (Binary files differ) Modified: www/vignettes/vectorized-R-code.rda =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Thu Mar 20 19:31:26 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 20 Mar 2014 19:31:26 +0100 (CET) Subject: [Pomp-commits] r897 - in pkg/pomp: R inst inst/examples src tests Message-ID: <20140320183126.9A72C186DCD@r-forge.r-project.org> Author: kingaa Date: 2014-03-20 19:31:26 +0100 (Thu, 20 Mar 2014) New Revision: 897 Modified: pkg/pomp/R/minim.R pkg/pomp/inst/NEWS pkg/pomp/inst/examples/bbs.R pkg/pomp/src/cholmodel.c pkg/pomp/src/pomp.h pkg/pomp/src/sir.c pkg/pomp/tests/dacca.R pkg/pomp/tests/dacca.Rout.save pkg/pomp/tests/ou2-trajmatch.Rout.save Log: - simplify dacca test - updates tests - add barycentric transformation functions to pomp.h - rewrite sir.c and cholmodel.c to use the barycentric transformations - use negative binomial reporting model in bbs Modified: pkg/pomp/R/minim.R =================================================================== --- pkg/pomp/R/minim.R 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/R/minim.R 2014-03-20 18:31:26 UTC (rev 897) @@ -22,7 +22,6 @@ if (length(est)==0) { - params <- c(A=3) val <- objfun(guess) conv <- NA evals <- as.integer(c(1,0)) Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/inst/NEWS 2014-03-20 18:31:26 UTC (rev 897) @@ -5,6 +5,9 @@ o 'pomp' now depends on 'nloptr', which provides a suite of optimization algorithms. This package can now be used in various methods for optimization of an objective function. + o New inline C functions 'to_log_barycentric' and 'from_log_barycentric' are provided in 'pomp.h' to facilitate log-barycentric transformations. + These have proven very useful in dealing with parameters constrained to sum to one (e.g., initial conditions of compartmental models). + 0.48-3 o Correct a bug in 'abc' to do with parameter transformation. Modified: pkg/pomp/inst/examples/bbs.R =================================================================== --- pkg/pomp/inst/examples/bbs.R 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/inst/examples/bbs.R 2014-03-20 18:31:26 UTC (rev 897) @@ -37,7 +37,7 @@ ), skeleton.type="vectorfield", skeleton="_sir_ODE", - measurement.model=reports~norm(mean=rho*cases,sd=1+sigma*cases), + measurement.model=reports~nbinom(mu=rho*cases,size=1/sigma), PACKAGE="pomp", obsnames = c("reports"), statenames=c("S","I","R","cases","W"), Modified: pkg/pomp/src/cholmodel.c =================================================================== --- pkg/pomp/src/cholmodel.c 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/src/cholmodel.c 2014-03-20 18:31:26 UTC (rev 897) @@ -51,17 +51,12 @@ pt[parindex[10]] = log(RHO); pt[parindex[11]] = logit(CLIN); - pt[parindex[14]] = log(S0); - pt[parindex[15]] = log(I0); - pt[parindex[16]] = log(RS0); - for (k = 0; k < nrstage; k++) - pt[parindex[17]+k] = log((&RL0)[k]); + to_log_barycentric(&pt[parindex[14]],&S0,3+nrstage); } void _cholmodel_trans (double *pt, double *p, int *parindex) { int k, nrstage = (int) NRSTAGE; - double sum = 0.0; pt[parindex[0]] = exp(TAU); pt[parindex[1]] = exp(GAMMA); pt[parindex[2]] = exp(EPS); @@ -72,20 +67,12 @@ pt[parindex[10]] = exp(RHO); pt[parindex[11]] = expit(CLIN); - sum += (pt[parindex[14]] = exp(S0)); - sum += (pt[parindex[15]] = exp(I0)); - sum += (pt[parindex[16]] = exp(RS0)); - for (k = 0; k < nrstage; k++) - sum += (pt[parindex[17]+k] = exp((&RL0)[k])); - pt[parindex[14]] /= sum; - pt[parindex[15]] /= sum; - pt[parindex[16]] /= sum; - for (k = 0; k < nrstage; k++) - pt[parindex[17]+k] /= sum; + from_log_barycentric(&pt[parindex[14]],&S0,3+nrstage); } void _cholmodel_norm_rmeasure (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, + int *obsindex, int *stateindex, + int *parindex, int *covindex, int ncovars, double *covars, double t) { double v, tol = 1.0e-18; @@ -97,8 +84,10 @@ } } -void _cholmodel_norm_dmeasure (double *lik, double *y, double *x, double *p, int give_log, - int *obsindex, int *stateindex, int *parindex, int *covindex, +void _cholmodel_norm_dmeasure (double *lik, double *y, double *x, + double *p, int give_log, + int *obsindex, int *stateindex, + int *parindex, int *covindex, int ncovars, double *covars, double t) { double v, tol = 1.0e-18; @@ -119,7 +108,8 @@ // truncation is not used // instead, particles with negative states are killed void _cholmodel_one (double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, + const int *stateindex, const int *parindex, + const int *covindex, int covdim, const double *covar, double t, double dt) { // implementation of the SIRS cholera model Modified: pkg/pomp/src/pomp.h =================================================================== --- pkg/pomp/src/pomp.h 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/src/pomp.h 2014-03-20 18:31:26 UTC (rev 897) @@ -227,6 +227,8 @@ return(trans); } + +// LOGIT AND INVERSE LOGIT TRANSFORMATIONS static R_INLINE double logit (double p) { return log(p/(1.0-p)); } @@ -242,7 +244,8 @@ // this must be done by the calling program // But note that when reulermultinom is called inside a pomp 'rprocess', there is no need to call // {Get,Put}RNGState() as this is handled by pomp -static void reulermultinom (int m, double size, double *rate, double dt, double *trans) { +static void reulermultinom (int m, double size, double *rate, + double dt, double *trans) { double p = 0.0; int j, k; if ((size < 0.0) || (dt < 0.0) || (floor(size+0.5) != size)) { @@ -276,7 +279,8 @@ } // COMPUTE PROBABILITIES OF EULER-MULTINOMIAL TRANSITIONS -static double deulermultinom (int m, double size, double *rate, double dt, double *trans, int give_log) { +static double deulermultinom (int m, double size, double *rate, double dt, + double *trans, int give_log) { double p = 0.0; double n = 0.0; double ff = 0.0; @@ -318,11 +322,42 @@ return ff; } +// C-LEVEL DEFINITIONS OF LOG-BARYCENTRIC TRANSFORMATION. +// USEFUL FOR WORKING WITH PARAMETERS CONSTRAINED TO SUM TO 1 + +// TRANSFORMS TO LOG BARYCENTRIC COORDINATES +// on input: +// x = pointer to vector of parameters to be tranformed to +// log barycentric coordinates, +// n = length of vector. +// on output: +// xt = pointer to vector of log barycentric coordinates +static R_INLINE void to_log_barycentric (double *xt, const double *x, int n) { + double sum; + int i; + for (i = 0, sum = 0.0; i < n; i++) sum += x[i]; + for (i = 0; i < n; i++) xt[i] = log(x[i]/sum); +} + +// TRANSFORMS FROM LOG BARYCENTRIC COORDINATES +// on input: +// x = pointer to vector of parameters in log barycentric coordinates, +// n = length of vector. +// on output: +// xt = pointer to vector of coordinates on unit simplex +static R_INLINE void from_log_barycentric (double *xt, const double *x, int n) { + double sum; + int i; + for (i = 0, sum = 0.0; i < n; i++) sum += (xt[i] = exp(x[i])); + for (i = 0; i < n; i++) xt[i] /= sum; +} + static R_INLINE double rbetabinom (double size, double prob, double theta) { return rbinom(size,rbeta(prob*theta,(1.0-prob)*theta)); } -static R_INLINE double dbetabinom (double x, double size, double prob, double theta, int give_log) { +static R_INLINE double dbetabinom (double x, double size, double prob, +double theta, int give_log) { double a = theta*prob; double b = theta*(1.0-prob); double f = lchoose(size,x)-lbeta(a,b)+lbeta(a+x,b+size-x); @@ -334,7 +369,8 @@ return rnbinom(size,rbeta(prob*theta,(1.0-prob)*theta)); } -static R_INLINE double dbetanbinom (double x, double mu, double size, double theta, int give_log) { +static R_INLINE double dbetanbinom (double x, double mu, double size, +double theta, int give_log) { double prob = size/(size+mu); double a = theta*prob; double b = theta*(1.0-prob); Modified: pkg/pomp/src/sir.c =================================================================== --- pkg/pomp/src/sir.c 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/src/sir.c 2014-03-20 18:31:26 UTC (rev 897) @@ -52,15 +52,13 @@ pt[parindex[3]+k] = log(BETA[k]); pt[parindex[4]] = log(BETA_SD); pt[parindex[6]] = logit(RHO); - pt[parindex[7]] = log(S0); - pt[parindex[8]] = log(I0); - pt[parindex[9]] = log(R0); + to_log_barycentric(pt+parindex[7],&S0,3); + } void _sir_par_trans (double *pt, double *p, int *parindex) { int nbasis = *(get_pomp_userdata_int("nbasis")); - double sum = 0.0; int k; pt[parindex[0]] = exp(GAMMA); pt[parindex[1]] = exp(MU); @@ -69,12 +67,7 @@ pt[parindex[3]+k] = exp(BETA[k]); pt[parindex[4]] = exp(BETA_SD); pt[parindex[6]] = expit(RHO); - sum += (pt[parindex[7]] = exp(S0)); - sum += (pt[parindex[8]] = exp(I0)); - sum += (pt[parindex[9]] = exp(R0)); - pt[parindex[7]] /= sum; - pt[parindex[8]] /= sum; - pt[parindex[9]] /= sum; + from_log_barycentric(pt+parindex[7],&S0,3); } void _sir_binom_dmeasure (double *lik, double *y, double *x, double *p, int give_log, Modified: pkg/pomp/tests/dacca.R =================================================================== --- pkg/pomp/tests/dacca.R 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/tests/dacca.R 2014-03-20 18:31:26 UTC (rev 897) @@ -7,18 +7,10 @@ pompExample(dacca) x <- as.data.frame(dacca) - print(names(x)) - print(dim(x)) - x <- simulate(dacca,nsim=3,as.data.frame=TRUE) - print(names(x)) - print(dim(x)) pf <- pfilter(dacca,Np=1000,seed=5886855L) - print(round(logLik(pf),digits=1)) - pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) - print(round(logLik(pf1),digits=1)) ## to investigate the rogue crash: @@ -55,6 +47,8 @@ r } + op <- options(warn=-1) + set.seed(7777+7) params.tricky <- dacca.rprior(dacca.hyperparams) m7 <- mif( @@ -90,4 +84,6 @@ transform=TRUE ) + options(op) + } Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/tests/dacca.Rout.save 2014-03-20 18:31:26 UTC (rev 897) @@ -24,18 +24,10 @@ + pompExample(dacca) + + x <- as.data.frame(dacca) -+ print(names(x)) -+ print(dim(x)) -+ + x <- simulate(dacca,nsim=3,as.data.frame=TRUE) -+ print(names(x)) -+ print(dim(x)) + + pf <- pfilter(dacca,Np=1000,seed=5886855L) -+ print(round(logLik(pf),digits=1)) -+ + pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) -+ print(round(logLik(pf1),digits=1)) + + ## to investigate the rogue crash: + @@ -110,22 +102,10 @@ + } Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve newly created pomp object(s): dacca - [1] "time" "cholera.deaths" "seas.1" "seas.2" - [5] "seas.3" "seas.4" "seas.5" "seas.6" - [9] "pop" "dpopdt" "trend" -[1] 600 11 - [1] "time" "cholera.deaths" "S" "I" - [5] "Rs" "R1" "R2" "R3" - [9] "M" "W" "count" "seas.1" -[13] "seas.2" "seas.3" "seas.4" "seas.5" -[17] "seas.6" "pop" "dpopdt" "trend" -[21] "sim" -[1] 1800 21 -[1] -3748.6 -[1] -3701.5 Warning messages: 1: 11 filtering failures occurred in 'pfilter' 2: 4 filtering failures occurred in 'pfilter' @@ -138,4 +118,4 @@ > > proc.time() user system elapsed - 11.056 0.060 11.164 + 11.092 0.056 11.206 Modified: pkg/pomp/tests/ou2-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/ou2-trajmatch.Rout.save 2014-03-20 17:57:01 UTC (rev 896) +++ pkg/pomp/tests/ou2-trajmatch.Rout.save 2014-03-20 18:31:26 UTC (rev 897) @@ -133,7 +133,7 @@ Error in tmof.internal(object = object, params = params, est = est, transform = transform, : parameter(s): 'bob''harry' not found in 'params' > try(traj.match(ou2,est=c('x1.0','x2.0','bob','alpha.4','tau'))) -Error in maxim.internal(objfun = traj.match.objfun(object = object, params = start, : +Error in minim.internal(objfun = traj.match.objfun(object = object, params = start, : 'est' must refer to parameters named in 'start' > > fit <- optim(par=c(0,0,1,0.5,0.5),fn=ofun,method="Nelder-Mead",control=list(maxit=400)) @@ -177,4 +177,4 @@ > > proc.time() user system elapsed - 1.588 0.084 1.700 + 1.672 0.028 1.723 From noreply at r-forge.r-project.org Thu Mar 20 19:52:08 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 20 Mar 2014 19:52:08 +0100 (CET) Subject: [Pomp-commits] r898 - pkg/pomp/inst/include Message-ID: <20140320185208.773DF18625D@r-forge.r-project.org> Author: kingaa Date: 2014-03-20 19:52:08 +0100 (Thu, 20 Mar 2014) New Revision: 898 Modified: pkg/pomp/inst/include/pomp.h Log: - forgot to update this Modified: pkg/pomp/inst/include/pomp.h =================================================================== --- pkg/pomp/inst/include/pomp.h 2014-03-20 18:31:26 UTC (rev 897) +++ pkg/pomp/inst/include/pomp.h 2014-03-20 18:52:08 UTC (rev 898) @@ -227,6 +227,8 @@ return(trans); } + +// LOGIT AND INVERSE LOGIT TRANSFORMATIONS static R_INLINE double logit (double p) { return log(p/(1.0-p)); } @@ -242,7 +244,8 @@ // this must be done by the calling program // But note that when reulermultinom is called inside a pomp 'rprocess', there is no need to call // {Get,Put}RNGState() as this is handled by pomp -static void reulermultinom (int m, double size, double *rate, double dt, double *trans) { +static void reulermultinom (int m, double size, double *rate, + double dt, double *trans) { double p = 0.0; int j, k; if ((size < 0.0) || (dt < 0.0) || (floor(size+0.5) != size)) { @@ -276,7 +279,8 @@ } // COMPUTE PROBABILITIES OF EULER-MULTINOMIAL TRANSITIONS -static double deulermultinom (int m, double size, double *rate, double dt, double *trans, int give_log) { +static double deulermultinom (int m, double size, double *rate, double dt, + double *trans, int give_log) { double p = 0.0; double n = 0.0; double ff = 0.0; @@ -318,11 +322,42 @@ return ff; } +// C-LEVEL DEFINITIONS OF LOG-BARYCENTRIC TRANSFORMATION. +// USEFUL FOR WORKING WITH PARAMETERS CONSTRAINED TO SUM TO 1 + +// TRANSFORMS TO LOG BARYCENTRIC COORDINATES +// on input: +// x = pointer to vector of parameters to be tranformed to +// log barycentric coordinates, +// n = length of vector. +// on output: +// xt = pointer to vector of log barycentric coordinates +static R_INLINE void to_log_barycentric (double *xt, const double *x, int n) { + double sum; + int i; + for (i = 0, sum = 0.0; i < n; i++) sum += x[i]; + for (i = 0; i < n; i++) xt[i] = log(x[i]/sum); +} + +// TRANSFORMS FROM LOG BARYCENTRIC COORDINATES +// on input: +// x = pointer to vector of parameters in log barycentric coordinates, +// n = length of vector. +// on output: +// xt = pointer to vector of coordinates on unit simplex +static R_INLINE void from_log_barycentric (double *xt, const double *x, int n) { + double sum; + int i; + for (i = 0, sum = 0.0; i < n; i++) sum += (xt[i] = exp(x[i])); + for (i = 0; i < n; i++) xt[i] /= sum; +} + static R_INLINE double rbetabinom (double size, double prob, double theta) { return rbinom(size,rbeta(prob*theta,(1.0-prob)*theta)); } -static R_INLINE double dbetabinom (double x, double size, double prob, double theta, int give_log) { +static R_INLINE double dbetabinom (double x, double size, double prob, +double theta, int give_log) { double a = theta*prob; double b = theta*(1.0-prob); double f = lchoose(size,x)-lbeta(a,b)+lbeta(a+x,b+size-x); @@ -334,7 +369,8 @@ return rnbinom(size,rbeta(prob*theta,(1.0-prob)*theta)); } -static R_INLINE double dbetanbinom (double x, double mu, double size, double theta, int give_log) { +static R_INLINE double dbetanbinom (double x, double mu, double size, +double theta, int give_log) { double prob = size/(size+mu); double a = theta*prob; double b = theta*(1.0-prob); From noreply at r-forge.r-project.org Thu Mar 20 22:51:17 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 20 Mar 2014 22:51:17 +0100 (CET) Subject: [Pomp-commits] r899 - www/vignettes Message-ID: <20140320215117.E554018621B@r-forge.r-project.org> Author: kingaa Date: 2014-03-20 22:51:17 +0100 (Thu, 20 Mar 2014) New Revision: 899 Modified: www/vignettes/advanced_topics_in_pomp.R www/vignettes/advanced_topics_in_pomp.Rnw www/vignettes/advanced_topics_in_pomp.pdf www/vignettes/bsmc-ricker-flat-prior.rda www/vignettes/bsmc-ricker-normal-prior.rda www/vignettes/complex-sir-def.rda www/vignettes/gompertz-trajmatch.rda www/vignettes/intro_to_pomp.R www/vignettes/intro_to_pomp.Rnw www/vignettes/intro_to_pomp.pdf www/vignettes/plugin-C-code.rda www/vignettes/plugin-R-code.rda www/vignettes/ricker-comparison.rda www/vignettes/ricker-first-probe.rda www/vignettes/ricker-mif.rda www/vignettes/ricker-probe-match.rda www/vignettes/ricker-probe.rda www/vignettes/sim-sim.rda www/vignettes/sir-pomp-def.rda www/vignettes/vectorized-C-code.rda www/vignettes/vectorized-R-code.rda Log: - edited demo/sir.R and pompBuilder section in Advanced Topics vignette to agree with one another - update vignettes Modified: www/vignettes/advanced_topics_in_pomp.R =================================================================== --- www/vignettes/advanced_topics_in_pomp.R 2014-03-20 18:52:08 UTC (rev 898) +++ www/vignettes/advanced_topics_in_pomp.R 2014-03-20 21:51:17 UTC (rev 899) @@ -305,316 +305,42 @@ ################################################### -### code chunk number 20: sir-def +### code chunk number 20: pomp-builder-measmod ################################################### - pomp( - data=data.frame( - time=seq(from=1/52,to=4,by=1/52), - reports=NA - ), - times="time", - t0=0, - ## native routine for the process simulator: - rprocess=euler.sim( - step.fun="_sir_euler_simulator", - delta.t=1/52/20, - PACKAGE="pomp" - ), - ## native routine for the skeleton: - skeleton.type="vectorfield", - skeleton="_sir_ODE", - ## native measurement-model routines: - rmeasure="_sir_binom_rmeasure", - dmeasure="_sir_binom_dmeasure", - ## name of the shared-object library containing the - PACKAGE="pomp", - ## the order of the observable assumed in the native routines: - obsnames = c("reports"), - ## the order of the state variables assumed in the native routines: - statenames=c("S","I","R","cases","W"), - ## the order of the parameters assumed in the native routines: - paramnames=c( - "gamma","mu","iota", - "beta1","beta.sd","pop","rho", - "S.0","I.0","R.0" - ), - nbasis=3L, # three seasonal basis functions - degree=3L, # use cubic B-splines - period=1.0, # seasonality has period 1yr - ## designate 'cases' as an accumulator variable - ## i.e., set it to zero after each observation - zeronames=c("cases"), - ## parameter transformations in native routines: - parameter.transform="_sir_par_trans", - parameter.inv.transform="_sir_par_untrans", - ## some variables to be used in the initializer - comp.names=c("S","I","R"), - ic.names=c("S.0","I.0","R.0"), - ## parameterization of the initial conditions: - initializer=function(params, t0, comp.names, ic.names, ...) { - snames <- c("S","I","R","cases","W") - fracs <- params[ic.names] - x0 <- numeric(length(snames)) - names(x0) <- snames - x0[comp.names] <- round(params['pop']*fracs/sum(fracs)) - x0 - } - ) -> sir +## negative binomial measurement model +## E[cases|incid] = rho*incid +## Var[cases|incid] = rho*incid*(1+rho*incid/theta) +rmeas <- ' + cases = rnbinom_mu(theta,rho*incid); +' -################################################### -### code chunk number 21: view-sir-source (eval = FALSE) -################################################### -## file.show(file=system.file("examples/sir.c",package="pomp")) +dmeas <- ' + lik = dnbinom_mu(cases,theta,rho*incid,give_log); +' -################################################### -### code chunk number 22: sir-sim (eval = FALSE) -################################################### -## params <- c( -## gamma=26,mu=0.02,iota=0.01, -## beta1=400,beta2=480,beta3=320, -## beta.sd=1e-3, -## pop=2.1e6, -## rho=0.6, -## S.0=26/400,I.0=0.001,R.0=1-0.001-26/400 -## ) -## -## sir <- simulate(sir,params=c(params,nbasis=3,degree=3,period=1),seed=3493885L) -## sims <- simulate(sir,nsim=10,obs=T) -## traj <- trajectory(sir,hmax=1/52) - ################################################### -### code chunk number 23: sir-sim-eval +### code chunk number 21: pomp-builder-stepfn ################################################### -binary.file <- "sim-sim.rda" -if (file.exists(binary.file)) { - load(binary.file) -} else { -params <- c( - gamma=26,mu=0.02,iota=0.01, - beta1=400,beta2=480,beta3=320, - beta.sd=1e-3, - pop=2.1e6, - rho=0.6, - S.0=26/400,I.0=0.001,R.0=1-0.001-26/400 - ) -sir <- simulate(sir,params=c(params,nbasis=3,degree=3,period=1),seed=3493885L) -sims <- simulate(sir,nsim=10,obs=T) -traj <- trajectory(sir,hmax=1/52) - save(sir,sims,traj,file=binary.file,compress='xz') -} - - -################################################### -### code chunk number 24: advanced_topics_in_pomp.Rnw:490-497 -################################################### -pompExample(ou2) -true.p <- coef(ou2) -x0 <- init.state(ou2) -x0 -new.p <- cbind(true.p,true.p,true.p) -new.p["x1.0",] <- 1:3 -init.state(ou2,params=new.p) - - -################################################### -### code chunk number 25: advanced_topics_in_pomp.Rnw:506-509 -################################################### -x <- rprocess(ou2,xstart=x0,times=time(ou2,t0=T),params=true.p) -dim(x) -x[,,1:5] - - -################################################### -### code chunk number 26: advanced_topics_in_pomp.Rnw:517-521 -################################################### -x <- x[,,-1,drop=F] -y <- rmeasure(ou2,x=x,times=time(ou2),params=true.p) -dim(y) -y[,,1:5] - - -################################################### -### code chunk number 27: advanced_topics_in_pomp.Rnw:527-530 -################################################### -fp <- dprocess(ou2,x=x,times=time(ou2),params=true.p) -dim(fp) -fp[,36:40] - - -################################################### -### code chunk number 28: advanced_topics_in_pomp.Rnw:532-535 -################################################### -fm <- dmeasure(ou2,y=y[,1,],x=x,times=time(ou2),params=true.p) -dim(fm) -fm[,36:40] - - -################################################### -### code chunk number 29: all-examples (eval = FALSE) -################################################### -## pompExample() - - -################################################### -### code chunk number 30: pomp-builder (eval = FALSE) -################################################### -## rmeas <- " -## double size = 1.0/sigma/sigma; -## double prob = 1.0/(1.0+rho*cases/size); -## reports = rnbinom(size,prob); -## " -## -## dmeas <- " -## double size = 1.0/sigma/sigma; -## double prob = 1.0/(1.0+rho*cases/size); -## lik = dnbinom(reports,size,prob,give_log); -## " -## -## stepfn <- " -## int nrate = 6; -## int nbasis = 3; -## int degree = 3; -## double period = 1.0; -## double rate[nrate]; // transition rates -## double trans[nrate]; // transition numbers -## double dW; -## double seasonality[nbasis]; -## double beta; -## int k; -## -## dW = rgammawn(beta_sd,dt); // gamma noise, mean=dt, variance=(beta_sd^2 dt) -## periodic_bspline_basis_eval(t,period,degree,nbasis,seasonality); -## beta = beta1*seasonality[0]+beta2*seasonality[1]+beta3*seasonality[2]; -## -## // compute the transition rates -## rate[0] = mu*popsize; // birth into susceptible class -## rate[1] = (iota+beta*I*dW/dt)/popsize; // force of infection -## rate[2] = mu; // death from susceptible class -## rate[3] = gamma; // recovery -## rate[4] = mu; // death from infectious class -## rate[5] = mu; // death from recovered class -## -## // compute the transition numbers -## trans[0] = rpois(rate[0]*dt); // births are Poisson -## reulermultinom(2,S,&rate[1],dt,&trans[1]); -## reulermultinom(2,I,&rate[3],dt,&trans[3]); -## reulermultinom(1,R,&rate[5],dt,&trans[5]); -## -## // balance the equations -## S += trans[0]-trans[1]-trans[2]; -## I += trans[1]-trans[3]-trans[4]; -## R += trans[3]-trans[5]; -## cases += trans[3]; // cases are cumulative recoveries -## if (beta_sd > 0.0) W += (dW-dt)/beta_sd; // mean = 0, variance = dt -## " -## -## skel <- " -## int nrate = 6; -## int nbasis = 3; -## int degree = 3; // degree of seasonal basis functions -## double period = 1.0; -## double rate[nrate]; // transition rates -## double term[nrate]; // terms in the equations -## double beta; -## double seasonality[nbasis]; -## -## // compute transmission rate from seasonality -## periodic_bspline_basis_eval(t,period,degree,nbasis,seasonality); -## beta = exp(log(beta1)*seasonality[0]+log(beta2)*seasonality[1]+log(beta3)*seasonality[2]); -## -## // compute the transition rates -## rate[0] = mu*popsize; // birth into susceptible class -## rate[1] = (iota+beta*I)/popsize; // force of infection -## rate[2] = mu; // death from susceptible class -## rate[3] = gamma; // recovery -## rate[4] = mu; // death from infectious class -## rate[5] = mu; // death from recovered class -## -## // compute the several terms -## term[0] = rate[0]; -## term[1] = rate[1]*S; -## term[2] = rate[2]*S; -## term[3] = rate[3]*I; -## term[4] = rate[4]*I; -## term[5] = rate[5]*R; -## -## // assemble the differential equations -## DS = term[0]-term[1]-term[2]; -## DI = term[1]-term[3]-term[4]; -## DR = term[3]-term[5]; -## Dcases = term[3]; // accumulate the new I->R transitions -## DW = 0; -## " -## -## pompBuilder( -## data=data.frame( -## reports=NA, -## time=seq(0,10,by=1/52) -## ), -## times="time", -## t0=-1/52, -## name="SIR", -## step.fn.delta.t=1/52/20, -## paramnames=c( -## "beta1","beta2","beta3","gamma","mu", -## "beta.sd","rho","popsize","iota","sigma" -## ), -## statenames=c("S","I","R","W","cases"), -## zeronames="cases", -## rmeasure=rmeas, -## dmeasure=dmeas, -## step.fn=stepfn, -## skeleton=skel, -## skeleton.type="vectorfield" -## ) -> sir -## -## simulate( -## sir, -## params=c(gamma=26,mu=0.05,beta.sd=0.1, -## rho=0.6,sigma=0.1,popsize=1e5,iota=10, -## beta1=100,beta2=120,beta3=80, -## S.0=26000,I.0=0,R.0=74000,W.0=0,cases.0=0 -## ) -## ) -> sir - - -################################################### -### code chunk number 31: pomp-builder-eval -################################################### -if (Sys.getenv("POMP_BUILD_VIGNETTES")=="yes") { - require(pomp) -rmeas <- " - double size = 1.0/sigma/sigma; - double prob = 1.0/(1.0+rho*cases/size); - reports = rnbinom(size,prob); -" - -dmeas <- " - double size = 1.0/sigma/sigma; - double prob = 1.0/(1.0+rho*cases/size); - lik = dnbinom(reports,size,prob,give_log); -" - -stepfn <- " +## SIR process model with extra-demographic stochasticity +## and seasonal transmission +step.fn <- ' int nrate = 6; - int nbasis = 3; - int degree = 3; - double period = 1.0; double rate[nrate]; // transition rates double trans[nrate]; // transition numbers - double dW; - double seasonality[nbasis]; - double beta; + double beta; // transmission rate + double dW; // white noise increment int k; - dW = rgammawn(beta_sd,dt); // gamma noise, mean=dt, variance=(beta_sd^2 dt) - periodic_bspline_basis_eval(t,period,degree,nbasis,seasonality); - beta = beta1*seasonality[0]+beta2*seasonality[1]+beta3*seasonality[2]; + // seasonality in transmission + beta = beta1*seas1+beta2*seas2+beta3*seas3; + // compute the environmental stochasticity + dW = rgammawn(beta_sd,dt); + // compute the transition rates rate[0] = mu*popsize; // birth into susceptible class rate[1] = (iota+beta*I*dW/dt)/popsize; // force of infection @@ -633,23 +359,25 @@ S += trans[0]-trans[1]-trans[2]; I += trans[1]-trans[3]-trans[4]; R += trans[3]-trans[5]; - cases += trans[3]; // cases are cumulative recoveries - if (beta_sd > 0.0) W += (dW-dt)/beta_sd; // mean = 0, variance = dt -" + incid += trans[3]; // incidence is cumulative recoveries + if (beta_sd > 0.0) W += (dW-dt)/beta_sd; // increment has mean = 0, variance = dt +' -skel <- " + + +################################################### +### code chunk number 22: pomp-builder-skel +################################################### + +skel <- ' int nrate = 6; - int nbasis = 3; - int degree = 3; // degree of seasonal basis functions - double period = 1.0; double rate[nrate]; // transition rates - double term[nrate]; // terms in the equations - double beta; - double seasonality[nbasis]; + double term[nrate]; // transition numbers + double beta; // transmission rate + double dW; // white noise increment + int k; - // compute transmission rate from seasonality - periodic_bspline_basis_eval(t,period,degree,nbasis,seasonality); - beta = exp(log(beta1)*seasonality[0]+log(beta2)*seasonality[1]+log(beta3)*seasonality[2]); + beta = beta1*seas1+beta2*seas2+beta3*seas3; // compute the transition rates rate[0] = mu*popsize; // birth into susceptible class @@ -671,49 +399,256 @@ DS = term[0]-term[1]-term[2]; DI = term[1]-term[3]-term[4]; DR = term[3]-term[5]; - Dcases = term[3]; // accumulate the new I->R transitions + Dincid = term[3]; // accumulate the new I->R transitions DW = 0; +' + + + +################################################### +### code chunk number 23: pomp-builder-partrans +################################################### + +## parameter transformations +## note we use barycentric coordinates for the initial conditions +## the success of this depends on S0, I0, R0 being in +## adjacent memory locations, in that order +partrans <- " + Tgamma = exp(gamma); + Tmu = exp(mu); + Tiota = exp(iota); + Tbeta1 = exp(beta1); + Tbeta2 = exp(beta2); + Tbeta3 = exp(beta3); + Tbeta_sd = exp(beta_sd); + Trho = expit(rho); + Ttheta = exp(theta); + from_log_barycentric(&TS_0,&S_0,3); " +paruntrans <- " + Tgamma = log(gamma); + Tmu = log(mu); + Tiota = log(iota); + Tbeta1 = log(beta1); + Tbeta2 = log(beta2); + Tbeta3 = log(beta3); + Tbeta_sd = log(beta_sd); + Trho = logit(rho); + Ttheta = log(theta); + to_log_barycentric(&TS_0,&S_0,3); +" + + + +################################################### +### code chunk number 24: pomp-builder-covar +################################################### + +covartab <- data.frame( + time=seq(from=-1/52,to=10+1/52,by=1/26) + ) + +covartab <- cbind( + covartab, + with(covartab, + periodic.bspline.basis( + x=time, + nbasis=3, + degree=3, + period=1, + names="seas%d" + ) + ) + ) + + + +################################################### +### code chunk number 25: pomp-builder (eval = FALSE) +################################################### +## +## pompBuilder( +## name="SIR", +## data=data.frame( +## cases=NA, +## time=seq(0,10,by=1/52) +## ), +## times="time", +## t0=-1/52, +## dmeasure=dmeas, +## rmeasure=rmeas, +## step.fn=step.fn, +## step.fn.delta.t=1/52/20, +## skeleton.type="vectorfield", +## skeleton=skel, +## covar=covartab, +## tcovar="time", +## parameter.transform=partrans, +## parameter.inv.transform=paruntrans, +## statenames=c("S","I","R","incid","W"), +## paramnames=c( +## "gamma","mu","iota", +## "beta1","beta2","beta3","beta.sd", +## "popsize","rho","theta", +## "S.0","I.0","R.0" +## ), +## zeronames=c("incid","W"), +## initializer=function(params, t0, ...) { +## x0 <- setNames(numeric(5),c("S","I","R","incid","W")) +## fracs <- params[c("S.0","I.0","R.0")] +## x0[1:3] <- round(params['popsize']*fracs/sum(fracs)) +## x0 +## } +## ) -> sir +## + + +################################################### +### code chunk number 26: pomp-builder-eval +################################################### +if (Sys.getenv("POMP_BUILD_VIGNETTES")=="yes") { + require(pomp) + pompBuilder( + name="SIR", data=data.frame( - reports=NA, + cases=NA, time=seq(0,10,by=1/52) ), times="time", t0=-1/52, - name="SIR", - step.fn.delta.t=1/52/20, - paramnames=c( - "beta1","beta2","beta3","gamma","mu", - "beta.sd","rho","popsize","iota","sigma" - ), - statenames=c("S","I","R","W","cases"), - zeronames="cases", - rmeasure=rmeas, dmeasure=dmeas, - step.fn=stepfn, + rmeasure=rmeas, + step.fn=step.fn, + step.fn.delta.t=1/52/20, + skeleton.type="vectorfield", skeleton=skel, - skeleton.type="vectorfield" + covar=covartab, + tcovar="time", + parameter.transform=partrans, + parameter.inv.transform=paruntrans, + statenames=c("S","I","R","incid","W"), + paramnames=c( + "gamma","mu","iota", + "beta1","beta2","beta3","beta.sd", + "popsize","rho","theta", + "S.0","I.0","R.0" + ), + zeronames=c("incid","W"), + initializer=function(params, t0, ...) { + x0 <- setNames(numeric(5),c("S","I","R","incid","W")) + fracs <- params[c("S.0","I.0","R.0")] + x0[1:3] <- round(params['popsize']*fracs/sum(fracs)) + x0 + } ) -> sir -simulate( - sir, - params=c(gamma=26,mu=0.05,beta.sd=0.1, - rho=0.6,sigma=0.1,popsize=1e5,iota=10, - beta1=100,beta2=120,beta3=80, - S.0=26000,I.0=0,R.0=74000,W.0=0,cases.0=0 - ) - ) -> sir - simulate(sir) -> x - pfilter(sir,Np=500) -> pf - print(logLik(pf)) } ################################################### -### code chunk number 32: restore-opts +### code chunk number 27: sir-sim (eval = FALSE) ################################################### +## +## coef(sir) <- c( +## gamma=26,mu=0.02,iota=0.01, +## beta1=400,beta2=480,beta3=320, +## beta.sd=0.001, +## popsize=2.1e6, +## rho=0.6,theta=10, +## S.0=26/400,I.0=0.001,R.0=1 +## ) +## +## sir <- simulate(sir,seed=3493885L) +## traj <- trajectory(sir,hmax=1/52) +## + + +################################################### +### code chunk number 28: sir-sim-eval +################################################### +binary.file <- "sim-sim.rda" +if (file.exists(binary.file)) { + load(binary.file) +} else { + +coef(sir) <- c( + gamma=26,mu=0.02,iota=0.01, + beta1=400,beta2=480,beta3=320, + beta.sd=0.001, + popsize=2.1e6, + rho=0.6,theta=10, + S.0=26/400,I.0=0.001,R.0=1 + ) + +sir <- simulate(sir,seed=3493885L) +traj <- trajectory(sir,hmax=1/52) + + save(sir,traj,file=binary.file,compress='xz') +} + + +################################################### +### code chunk number 29: sir-plot +################################################### +plot(sir) + + +################################################### +### code chunk number 30: advanced_topics_in_pomp.Rnw:631-638 +################################################### +pompExample(ou2) +true.p <- coef(ou2) +x0 <- init.state(ou2) +x0 +new.p <- cbind(true.p,true.p,true.p) +new.p["x1.0",] <- 1:3 +init.state(ou2,params=new.p) + + +################################################### +### code chunk number 31: advanced_topics_in_pomp.Rnw:647-650 +################################################### +x <- rprocess(ou2,xstart=x0,times=time(ou2,t0=T),params=true.p) +dim(x) +x[,,1:5] + + +################################################### +### code chunk number 32: advanced_topics_in_pomp.Rnw:658-662 +################################################### +x <- x[,,-1,drop=F] +y <- rmeasure(ou2,x=x,times=time(ou2),params=true.p) +dim(y) +y[,,1:5] + + +################################################### +### code chunk number 33: advanced_topics_in_pomp.Rnw:668-671 +################################################### +fp <- dprocess(ou2,x=x,times=time(ou2),params=true.p) +dim(fp) +fp[,36:40] + + +################################################### +### code chunk number 34: advanced_topics_in_pomp.Rnw:673-676 +################################################### +fm <- dmeasure(ou2,y=y[,1,],x=x,times=time(ou2),params=true.p) +dim(fm) +fm[,36:40] + + +################################################### +### code chunk number 35: all-examples (eval = FALSE) +################################################### +## pompExample() + + +################################################### +### code chunk number 36: restore-opts +################################################### options(glop) Modified: www/vignettes/advanced_topics_in_pomp.Rnw =================================================================== --- www/vignettes/advanced_topics_in_pomp.Rnw 2014-03-20 18:52:08 UTC (rev 898) +++ www/vignettes/advanced_topics_in_pomp.Rnw 2014-03-20 21:51:17 UTC (rev 899) @@ -338,115 +338,6 @@ Doing \Sexpr{n.Cvect} simulations of \code{ou2.Cvect} took \Sexpr{round(etime.Cvect,2)}~\Sexpr{units(etime.Cvect)}, a \Sexpr{round(speedup)}-fold speed-up relative to \code{ou2.Rplug}. -\subsection{More on native codes and plug-ins} - -It's possible to use native codes for \code{dprocess} and for the measurement model portions of the \code{pomp} as well. -In the ``Introduction to pomp'' vignette, we looked at the SIR model, which we implemented using an Euler-multinomial approximation to the continuous-time Markov process. -Here is the same model implemented using native C codes: -<>= - pomp( - data=data.frame( - time=seq(from=1/52,to=4,by=1/52), - reports=NA - ), - times="time", - t0=0, - ## native routine for the process simulator: - rprocess=euler.sim( - step.fun="_sir_euler_simulator", - delta.t=1/52/20, - PACKAGE="pomp" - ), - ## native routine for the skeleton: - skeleton.type="vectorfield", - skeleton="_sir_ODE", - ## native measurement-model routines: - rmeasure="_sir_binom_rmeasure", - dmeasure="_sir_binom_dmeasure", - ## name of the shared-object library containing the - PACKAGE="pomp", - ## the order of the observable assumed in the native routines: - obsnames = c("reports"), - ## the order of the state variables assumed in the native routines: - statenames=c("S","I","R","cases","W"), - ## the order of the parameters assumed in the native routines: - paramnames=c( - "gamma","mu","iota", - "beta1","beta.sd","pop","rho", - "S.0","I.0","R.0" - ), - nbasis=3L, # three seasonal basis functions - degree=3L, # use cubic B-splines - period=1.0, # seasonality has period 1yr - ## designate 'cases' as an accumulator variable - ## i.e., set it to zero after each observation - zeronames=c("cases"), - ## parameter transformations in native routines: - parameter.transform="_sir_par_trans", - parameter.inv.transform="_sir_par_untrans", - ## some variables to be used in the initializer - comp.names=c("S","I","R"), - ic.names=c("S.0","I.0","R.0"), - ## parameterization of the initial conditions: - initializer=function(params, t0, comp.names, ic.names, ...) { - snames <- c("S","I","R","cases","W") - fracs <- params[ic.names] - x0 <- numeric(length(snames)) - names(x0) <- snames - x0[comp.names] <- round(params['pop']*fracs/sum(fracs)) - x0 - } - ) -> sir -@ -The source code for the native routines \verb+_sir_euler_simulator+, \verb+_sir_ODE+, \verb+_sir_binom_rmeasure+, and \verb+_sir_binom_dmeasure+ is provided with the package (in the \code{examples} directory). -To see the source code, do -<>= -file.show(file=system.file("examples/sir.c",package="pomp")) -@ -In the \code{demo} directory is an \R\ script that shows how to compile \verb+sir.c+ into a shared-object library and link it with \R. -Do \code{demo(sir)} to run and view this script. -Note that the native routines for this model are included in the package, which is why we give the \verb+PACKAGE="pomp"+ argument to \code{pomp}. -When you write your own model using native routines, you'll compile them into a dynamically-loadable library. -In this case, you'll want to specify the name of that library using the \code{PACKAGE} argument. -Again, refer to the SIR example included in the \code{examples} directory to see how this is done. - -You can also use the R package \pkg{inline} to put C or FORTRAN codes directly into your R functions. - -There is an important issue that arises when using native codes. -This has to do with the order in which parameters, states, and observables are passed to these codes. -\pkg{pomp} relies on the names (also row-names and column-names) attributes to identify variables in vectors and arrays. -When you write a C or FORTRAN version of \code{rprocess} or \code{dmeasure} for example, you write a routine that takes parameters, state variables, and/or observables in the form of a vector. -However, you have no control over the order in which these are given to you. -Without some means of knowing which element of each vector corresponds to which variable, you cannot write the codes correctly. -This is where the \code{paramnames}, \code{statenames}, \code{covarnames}, and \code{obsnames} arguments to \code{pomp} come in: use these arguments to specify the order in which your C code expects to see the parameters, state variables, covariates, and observables (data variables). -\code{pomp} will match these names against the corresponding names attributes of vectors. -It will then pass to your native routines index vectors you can use to locate the correct variables. -See the source code to see how this is done. - -Let's specify some parameters, simulate, and compute a deterministic trajectory: -<>= -params <- c( - gamma=26,mu=0.02,iota=0.01, - beta1=400,beta2=480,beta3=320, - beta.sd=1e-3, - pop=2.1e6, - rho=0.6, - S.0=26/400,I.0=0.001,R.0=1-0.001-26/400 - ) - -sir <- simulate(sir,params=c(params,nbasis=3,degree=3,period=1),seed=3493885L) -sims <- simulate(sir,nsim=10,obs=T) -traj <- trajectory(sir,hmax=1/52) -<>= -binary.file <- "sim-sim.rda" -if (file.exists(binary.file)) { - load(binary.file) -} else { -<> - save(sir,sims,traj,file=binary.file,compress='xz') -} -@ - \section{Accumulator variables} Recall the SIR example discussed in the ``Introduction to \pkg{pomp}'' vignette. @@ -477,106 +368,49 @@ setting \code{zeronames} will have no effect on custom \code{rprocess} codes. \clearpage -\section{The low-level interface} +\section{Incorporating native codes using \code{pompBuilder}} -There is a low-level interface to \code{pomp} objects, primarily designed for package developers. -Ordinary users should have little reason to use this interface. -In this section, each of the methods that make up this interface will be introduced. +It's possible to use native codes for \code{dprocess} and for the measurement model portions of the \code{pomp} as well. +In the ``Introduction to pomp'' vignette, we looked at the SIR model, which we implemented using an Euler-multinomial approximation to the continuous-time Markov process. +Here, we implement a similar model using native C codes. +The new, and still experimental, \code{pompBuilder} function helps us do this. -\subsection{Getting initial states} +We'll start by writing snippets of C code to implement each of the important parts of our model. +First, we encode a negative binomial measurement model. +<>= -The \code{init.state} method is called to initialize the state (unobserved) process. -It takes a vector or matrix of parameters and returns a matrix of initial states. -<<>>= -pompExample(ou2) -true.p <- coef(ou2) -x0 <- init.state(ou2) -x0 -new.p <- cbind(true.p,true.p,true.p) -new.p["x1.0",] <- 1:3 -init.state(ou2,params=new.p) -@ +## negative binomial measurement model +## E[cases|incid] = rho*incid +## Var[cases|incid] = rho*incid*(1+rho*incid/theta) +rmeas <- ' + cases = rnbinom_mu(theta,rho*incid); +' -\subsection{Simulating the process model} +dmeas <- ' + lik = dnbinom_mu(cases,theta,rho*incid,give_log); +' -The \code{rprocess} method gives access to the process model simulator. -It takes initial conditions (which need not correspond to the zero-time \code{t0} specified when the \code{pomp} object was constructed), a set of times, and a set of parameters. -The initial states and parameters must be matrices, and they are checked for commensurability. -The method returns a rank-3 array containing simulated state trajectories, sampled at the times specified. -<<>>= -x <- rprocess(ou2,xstart=x0,times=time(ou2,t0=T),params=true.p) -dim(x) -x[,,1:5] @ -Note that the dimensions of \code{x} are \verb+nvars x nreps x ntimes+, where \code{nvars} is the number of state variables, \code{nreps} is the number of simulated trajectories (which is the number of columns in the \code{params} and \code{xstart} matrices), and \code{ntimes} is the length of the \code{times} argument. -Note also that \verb+x[,,1]+ is identical to \verb+xstart+. -\subsection{Simulating the measurement model} +Next the function that takes one Euler step. +<>= -The \code{rmeasure} method gives access to the measurement model simulator: -<<>>= -x <- x[,,-1,drop=F] -y <- rmeasure(ou2,x=x,times=time(ou2),params=true.p) -dim(y) -y[,,1:5] -@ - -\subsection{Process and measurement model densities} - -The \code{dmeasure} and \code{dprocess} methods give access to the measurement and process model densities, respectively. -<<>>= -fp <- dprocess(ou2,x=x,times=time(ou2),params=true.p) -dim(fp) -fp[,36:40] -@ -<<>>= -fm <- dmeasure(ou2,y=y[,1,],x=x,times=time(ou2),params=true.p) -dim(fm) -fm[,36:40] -@ -All of these are to be preferred to direct access to the slots of the \code{pomp} object, because they do error checking on the inputs and outputs. - -\section{Other examples} - -There are a number of example \code{pomp} objects included with the package. -These can be found by running -<>= -pompExample() -@ -The \R\ scripts that generated these are included in the \code{examples} directory of the installed package. -The majority of these use compiled code, which can be found in the package source. - -\section{Pomp Builder} - -<>= -rmeas <- " - double size = 1.0/sigma/sigma; - double prob = 1.0/(1.0+rho*cases/size); - reports = rnbinom(size,prob); -" - -dmeas <- " - double size = 1.0/sigma/sigma; - double prob = 1.0/(1.0+rho*cases/size); - lik = dnbinom(reports,size,prob,give_log); -" - -stepfn <- " +## SIR process model with extra-demographic stochasticity +## and seasonal transmission +step.fn <- ' int nrate = 6; - int nbasis = 3; - int degree = 3; - double period = 1.0; double rate[nrate]; // transition rates double trans[nrate]; // transition numbers - double dW; - double seasonality[nbasis]; - double beta; + double beta; // transmission rate + double dW; // white noise increment int k; - dW = rgammawn(beta_sd,dt); // gamma noise, mean=dt, variance=(beta_sd^2 dt) - periodic_bspline_basis_eval(t,period,degree,nbasis,seasonality); - beta = beta1*seasonality[0]+beta2*seasonality[1]+beta3*seasonality[2]; + // seasonality in transmission + beta = beta1*seas1+beta2*seas2+beta3*seas3; + // compute the environmental stochasticity + dW = rgammawn(beta_sd,dt); + // compute the transition rates rate[0] = mu*popsize; // birth into susceptible class rate[1] = (iota+beta*I*dW/dt)/popsize; // force of infection @@ -595,23 +429,25 @@ S += trans[0]-trans[1]-trans[2]; I += trans[1]-trans[3]-trans[4]; R += trans[3]-trans[5]; - cases += trans[3]; // cases are cumulative recoveries - if (beta_sd > 0.0) W += (dW-dt)/beta_sd; // mean = 0, variance = dt -" + incid += trans[3]; // incidence is cumulative recoveries + if (beta_sd > 0.0) W += (dW-dt)/beta_sd; // increment has mean = 0, variance = dt +' -skel <- " +@ + +Now the deterministic skeleton. +The ``D'' prepended to each state variable indicates the derivative of the state variable. +<>= + [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 899 From noreply at r-forge.r-project.org Thu Mar 20 22:51:41 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 20 Mar 2014 22:51:41 +0100 (CET) Subject: [Pomp-commits] r900 - in pkg/pomp: R demo inst/examples man tests Message-ID: <20140320215141.84C7D18621B@r-forge.r-project.org> Author: kingaa Date: 2014-03-20 22:51:41 +0100 (Thu, 20 Mar 2014) New Revision: 900 Removed: pkg/pomp/inst/examples/sir.c Modified: pkg/pomp/R/mif.R pkg/pomp/demo/sir.R pkg/pomp/inst/examples/bbs.R pkg/pomp/inst/examples/euler.sir.R pkg/pomp/man/mif.Rd pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/dacca.Rout.save pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/pfilter.Rout.save Log: - removed inst/examples/sir.c - edited demo/sir.R and pompBuilder section in Advanced Topics vignette to agree with one another - small change to bbs example - euler.sir example now uses negative binomial measurement error - when 'mif' is called on a 'mif' object, pars are no longer copied but rather taken from 'rw.sd' - clean up 'dacca' test - update tests Modified: pkg/pomp/R/mif.R =================================================================== --- pkg/pomp/R/mif.R 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/R/mif.R 2014-03-20 21:51:41 UTC (rev 900) @@ -491,7 +491,7 @@ signature=signature(object="mif"), function (object, Nmif, start, - pars, ivps, + ivps, particles, rw.sd, Np, ic.lag, var.factor, cooling.type, cooling.fraction, @@ -502,7 +502,6 @@ if (missing(Nmif)) Nmif <- object at Nmif if (missing(start)) start <- coef(object) - if (missing(pars)) pars <- object at pars if (missing(ivps)) ivps <- object at ivps if (missing(particles)) particles <- object at particles if (missing(rw.sd)) rw.sd <- object at random.walk.sd @@ -520,7 +519,6 @@ object=as(object,"pomp"), Nmif=Nmif, start=start, - pars=pars, ivps=ivps, particles=particles, rw.sd=rw.sd, Modified: pkg/pomp/demo/sir.R =================================================================== --- pkg/pomp/demo/sir.R 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/demo/sir.R 2014-03-20 21:51:41 UTC (rev 900) @@ -1,15 +1,18 @@ require(pomp) ## negative binomial measurement model -dmeas <- " - double prob = theta/(theta+rho*incid); - lik = dnbinom(cases,theta,prob,give_log); -" -rmeas <- " - double prob = theta/(theta+rho*incid); - cases = rnbinom(theta,prob); -" +## E[cases|incid] = rho*incid +## Var[cases|incid] = rho*incid*(1+rho*incid/theta) +rmeas <- ' + cases = rnbinom_mu(theta,rho*incid); +' + +dmeas <- ' + lik = dnbinom_mu(cases,theta,rho*incid,give_log); +' + ## SIR process model with extra-demographic stochasticity +## and seasonal transmission step.fn <- ' int nrate = 6; double rate[nrate]; // transition rates @@ -18,6 +21,7 @@ double dW; // white noise increment int k; + // seasonality in transmission beta = beta1*seas1+beta2*seas2+beta3*seas3; // compute the environmental stochasticity @@ -41,9 +45,10 @@ S += trans[0]-trans[1]-trans[2]; I += trans[1]-trans[3]-trans[4]; R += trans[3]-trans[5]; - incid += trans[3]; // cases are cumulative recoveries + incid += trans[3]; // incidence is cumulative recoveries if (beta_sd > 0.0) W += (dW-dt)/beta_sd; // increment has mean = 0, variance = dt ' + skel <- ' int nrate = 6; double rate[nrate]; // transition rates @@ -77,9 +82,12 @@ Dincid = term[3]; // accumulate the new I->R transitions DW = 0; ' + ## parameter transformations +## note we use barycentric coordinates for the initial conditions +## the success of this depends on S0, I0, R0 being in +## adjacent memory locations, in that order partrans <- " - double sum; Tgamma = exp(gamma); Tmu = exp(mu); Tiota = exp(iota); @@ -89,16 +97,10 @@ Tbeta_sd = exp(beta_sd); Trho = expit(rho); Ttheta = exp(theta); - TS_0 = exp(S_0); - TI_0 = exp(I_0); - TR_0 = exp(R_0); - sum = TS_0+TI_0+TR_0; - TS_0 /= sum; - TI_0 /= sum; - TR_0 /= sum; + from_log_barycentric(&TS_0,&S_0,3); " + paruntrans <- " - double sum; Tgamma = log(gamma); Tmu = log(mu); Tiota = log(iota); @@ -108,10 +110,7 @@ Tbeta_sd = log(beta_sd); Trho = logit(rho); Ttheta = log(theta); - sum = S_0+I_0+R_0; - TS_0 = log(S_0/sum); - TI_0 = log(I_0/sum); - TR_0 = log(R_0/sum); + to_log_barycentric(&TS_0,&S_0,3); " data(LondonYorke) @@ -170,7 +169,7 @@ beta1=120,beta2=140,beta3=100, beta.sd=0.01, popsize=5e6, - rho=0.2,theta=0.001, + rho=0.1,theta=1, S.0=0.22,I.0=0.0018,R.0=0.78 ) @@ -189,18 +188,3 @@ print(toc-tic) plot(incid~time,data=x,col=as.factor(x$sim),pch=16) - -coef(po) <- coef( - traj.match( - pomp( - window(po,end=1930) - ## window(po,end=1930), - ## measurement.model=cases~norm(mean=rho*incid,sd=100) - ), - est=c("S.0","I.0","R.0"), - transform=TRUE - ) - ) - -pf <- pfilter(po,Np=1000,max.fail=100) -print(round(logLik(pf),1)) Modified: pkg/pomp/inst/examples/bbs.R =================================================================== --- pkg/pomp/inst/examples/bbs.R 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/inst/examples/bbs.R 2014-03-20 21:51:41 UTC (rev 900) @@ -37,13 +37,13 @@ ), skeleton.type="vectorfield", skeleton="_sir_ODE", - measurement.model=reports~nbinom(mu=rho*cases,size=1/sigma), + measurement.model=reports~nbinom(mu=rho*cases,size=1/sigma^2), PACKAGE="pomp", obsnames = c("reports"), statenames=c("S","I","R","cases","W"), paramnames=c( "gamma","mu","iota", - "beta","beta.sd","pop","rho", + "beta","beta.sd","pop","rho","sigma", "S.0","I.0","R.0" ), zeronames=c("cases"), Modified: pkg/pomp/inst/examples/euler.sir.R =================================================================== --- pkg/pomp/inst/examples/euler.sir.R 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/inst/examples/euler.sir.R 2014-03-20 21:51:41 UTC (rev 900) @@ -220,7 +220,7 @@ beta1=400,beta2=480,beta3=320, beta.sd=1e-3, pop=2.1e6, - rho=0.6, + rho=0.6,overdisp=1, S.0=26/400,I.0=0.001,R.0=1-26/400 ), rprocess=euler.sim( @@ -237,7 +237,7 @@ statenames=c("S","I","R","cases","W"), paramnames=c( "gamma","mu","iota", - "beta1","beta.sd","pop","rho", + "beta1","beta.sd","pop","rho","overdisp", "S.0","I.0","R.0" ), zeronames=c("cases"), Deleted: pkg/pomp/inst/examples/sir.c =================================================================== --- pkg/pomp/inst/examples/sir.c 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/inst/examples/sir.c 2014-03-20 21:51:41 UTC (rev 900) @@ -1,165 +0,0 @@ -// dear emacs, please treat this as -*- C++ -*- - -#include -#include -#include -#include - -// SIR example as described in the "Advanced Topics in pomp" vignette. -// for a demonstration of how to compile, link, and run this example, -// do 'demo("sir",package="pomp")' at the R prompt. - -// some macros to make the code easier to read. -// note how variables and parameters use the indices. -// the integer vectors parindex, stateindex, obsindex -// are computed by pomp by matching the names of input vectors -// against parnames, statenames, and obsnames, respectively. - -#define GAMMA (p[parindex[0]]) // recovery rate -#define MU (p[parindex[1]]) // baseline birth and death rate -#define IOTA (p[parindex[2]]) // import rate -#define BETA (&p[parindex[3]]) // transmission rate -#define BETA_SD (p[parindex[4]]) // environmental stochasticity SD in transmission rate -#define POPSIZE (p[parindex[5]]) // population size -#define RHO (p[parindex[6]]) // reporting probability -#define NBASIS (p[parindex[7]]) // number of periodic B-spline basis functions -#define DEGREE (p[parindex[8]]) // degree of periodic B-spline basis functions -#define PERIOD (p[parindex[9]]) // period of B-spline basis functions - -#define SUSC (x[stateindex[0]]) // number of susceptibles -#define INFD (x[stateindex[1]]) // number of infectives -#define RCVD (x[stateindex[2]]) // number of recovereds -#define CASE (x[stateindex[3]]) // number of cases (accumulated per reporting period) -#define W (x[stateindex[4]]) // integrated white noise - -#define REPORTS (y[obsindex[0]]) // the data - -#define DSDT (f[stateindex[0]]) -#define DIDT (f[stateindex[1]]) -#define DRDT (f[stateindex[2]]) -#define DCDT (f[stateindex[3]]) -#define DWDT (f[stateindex[4]]) - -// the measurement model. -// note that dmeasure and rmeasure are mirrors of each other. - -void binomial_dmeasure (double *lik, double *y, double *x, double *p, int give_log, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovars, double *covars, double t) { - *lik = dbinom(REPORTS,nearbyint(CASE),RHO,give_log); -} - -void binomial_rmeasure (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovars, double *covars, double t) { - REPORTS = rbinom(nearbyint(CASE),RHO); -} - -// the process model: -// an SIR model with Euler-multinomial step, -// transmission is seasonal, implemented using B-spline basis functions passed as covariates. -// the population size is constant and specified by a parameter. -// there is environmental stochasticity in transmission (dW). -void sir_euler_simulator (double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int covdim, const double *covar, - double t, double dt) -{ - int nrate = 6; - double rate[nrate]; // transition rates - double trans[nrate]; // transition numbers - double beta; // transmission rate - double dW; // white noise increment - int nbasis = (int) NBASIS; // number of seasonal basis functions - int deg = (int) DEGREE; // degree of seasonal basis functions - int k; - double seasonality[nbasis]; - void (*eval_basis)(double,double,int,int,double*); - void (*reulmult)(int,double,double*,double,double*); - - // to evaluate the basis functions and compute the transmission rate, use some of - // pomp's built-in C-level facilities: - eval_basis = (void (*)(double,double,int,int,double*)) R_GetCCallable("pomp","periodic_bspline_basis_eval"); - // pomp's C-level eulermultinomial simulator - reulmult = (void (*)(int,double,double*,double,double*)) R_GetCCallable("pomp","reulermultinom"); - - // compute transmission rate from seasonality - if (nbasis <= 0) return; - eval_basis(t,PERIOD,deg,nbasis,&seasonality[0]); // evaluate the periodic B-spline basis - for (k = 0, beta = 0; k < nbasis; k++) - beta += BETA[k]*seasonality[k]; - - // compute the environmental stochasticity - dW = rgammawn(BETA_SD,dt); - - // compute the transition rates - rate[0] = MU*POPSIZE; // birth into susceptible class - rate[1] = (IOTA+beta*INFD*dW/dt)/POPSIZE; // force of infection - rate[2] = MU; // death from susceptible class - rate[3] = GAMMA; // recovery - rate[4] = MU; // death from infectious class - rate[5] = MU; // death from recovered class - - // compute the transition numbers - trans[0] = rpois(rate[0]*dt); // births are Poisson - (*reulmult)(2,SUSC,&rate[1],dt,&trans[1]); // euler-multinomial exits from S class - (*reulmult)(2,INFD,&rate[3],dt,&trans[3]); // euler-multinomial exits from I class - (*reulmult)(1,RCVD,&rate[5],dt,&trans[5]); // euler-multinomial exits from R class - - // balance the equations - SUSC += trans[0]-trans[1]-trans[2]; - INFD += trans[1]-trans[3]-trans[4]; - RCVD += trans[3]-trans[5]; - CASE += trans[3]; // cases are cumulative recoveries - if (BETA_SD > 0.0) W += (dW-dt)/BETA_SD; // increment has mean = 0, variance = dt - -} - -void sir_ODE (double *f, double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int covdim, const double *covar, double t) -{ - int nrate = 6; - double rate[nrate]; // transition rates - double term[nrate]; // terms in the equations - double beta; - int nbasis = (int) NBASIS; // number of seasonal basis functions - int deg = (int) DEGREE; // degree of seasonal basis functions - int k; - double seasonality[nbasis]; - void (*eval_basis)(double,double,int,int,double*); - - // to evaluate the basis functions and compute the transmission rate, use some of - // pomp's built-in C-level facilities: - eval_basis = (void (*)(double,double,int,int,double*)) R_GetCCallable("pomp","periodic_bspline_basis_eval"); - - // compute transmission rate from seasonality - if (nbasis <= 0) return; - eval_basis(t,PERIOD,deg,nbasis,&seasonality[0]); // evaluate the periodic B-spline basis - for (k = 0, beta = 0; k < nbasis; k++) - beta += BETA[k]*seasonality[k]; - - // compute the transition rates - rate[0] = MU*POPSIZE; // birth into susceptible class - rate[1] = (IOTA+beta*INFD)/POPSIZE; // force of infection - rate[2] = MU; // death from susceptible class - rate[3] = GAMMA; // recovery - rate[4] = MU; // death from infectious class - rate[5] = MU; // death from recovered class - - // compute the several terms - term[0] = rate[0]; - term[1] = rate[1]*SUSC; - term[2] = rate[2]*SUSC; - term[3] = rate[3]*INFD; - term[4] = rate[4]*INFD; - term[5] = rate[5]*RCVD; - - // assemble the differential equations - DSDT = term[0]-term[1]-term[2]; - DIDT = term[1]-term[3]-term[4]; - DRDT = term[3]-term[5]; - DCDT = term[3]; // accumulate the new I->R transitions - DWDT = 0; - -} Modified: pkg/pomp/man/mif.Rd =================================================================== --- pkg/pomp/man/mif.Rd 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/man/mif.Rd 2014-03-20 21:51:41 UTC (rev 900) @@ -23,7 +23,7 @@ tol = 1e-17, max.fail = Inf, verbose = getOption("verbose"), transform = FALSE, \dots) \S4method{mif}{pfilterd.pomp}(object, Nmif = 1, Np, tol, \dots) -\S4method{mif}{mif}(object, Nmif, start, pars, ivps, +\S4method{mif}{mif}(object, Nmif, start, ivps, particles, rw.sd, Np, ic.lag, var.factor, cooling.type, cooling.fraction, method, tol, transform, \dots) Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/tests/bbs.Rout.save 2014-03-20 21:51:41 UTC (rev 900) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > pompExample(bbs) @@ -51,17 +52,17 @@ Walker's alias method used: results are different from R < 2.2.0 > signif(coef(fit1),3) gamma mu iota beta beta.sd pop rho sigma - 0.333 0.000 0.000 3.630 0.000 1400.000 0.900 2.220 + 0.333 0.000 0.000 4.300 0.000 1400.000 0.900 2.050 S.0 I.0 R.0 0.999 0.001 0.000 > > fit2 <- traj.match(bbs,est=c("beta","sigma"),transform=TRUE) > signif(coef(fit2),3) gamma mu iota beta beta.sd pop rho sigma - 0.333 0.000 0.000 2.020 0.000 1400.000 0.900 0.426 + 0.333 0.000 0.000 2.090 0.000 1400.000 0.900 0.474 S.0 I.0 R.0 0.999 0.001 0.000 > > proc.time() user system elapsed - 2.784 0.068 2.880 + 2.908 0.064 3.003 Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/tests/dacca.Rout.save 2014-03-20 21:51:41 UTC (rev 900) @@ -64,6 +64,8 @@ + r + } + ++ op <- options(warn=-1) ++ + set.seed(7777+7) + params.tricky <- dacca.rprior(dacca.hyperparams) + m7 <- mif( @@ -99,6 +101,8 @@ + transform=TRUE + ) + ++ options(op) ++ + } Loading required package: mvtnorm Loading required package: subplex @@ -106,16 +110,7 @@ Loading required package: deSolve newly created pomp object(s): dacca -Warning messages: -1: 11 filtering failures occurred in 'pfilter' -2: 4 filtering failures occurred in 'pfilter' -3: 1 filtering failure occurred in 'pfilter' -4: 16 filtering failures occurred in 'pfilter' -5: 2 filtering failures occurred in 'pfilter' -6: 2 filtering failures occurred in 'pfilter' -7: 1 filtering failure occurred in 'pfilter' -8: 7 filtering failures occurred in 'pfilter' > > proc.time() user system elapsed - 11.092 0.056 11.206 + 11.068 0.104 11.227 Modified: pkg/pomp/tests/ou2-mif.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif.Rout.save 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/tests/ou2-mif.Rout.save 2014-03-20 21:51:41 UTC (rev 900) @@ -229,6 +229,7 @@ + } Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve newly created pomp object(s): ou2 @@ -272,10 +273,9 @@ pfilter timestep 90 of 100 finished pfilter timestep 95 of 100 finished pfilter timestep 100 of 100 finished -Warning messages: -1: mif warning: the variables 'alpha.3', 'x2.0' have positive random-walk SDs specified, but are included in neither 'pars' nor 'ivps'. These random walk SDs will be ignored. -2: mif warning: the variable 'x2.0' has positive random-walk SD specified, but is included in neither 'pars' nor 'ivps'. This random walk SD will be ignored. +Warning message: +mif warning: the variables 'alpha.3', 'x2.0' have positive random-walk SDs specified, but are included in neither 'pars' nor 'ivps'. These random walk SDs will be ignored. > > proc.time() user system elapsed - 11.740 0.092 11.978 + 11.960 0.064 12.167 Modified: pkg/pomp/tests/pfilter.Rout.save =================================================================== --- pkg/pomp/tests/pfilter.Rout.save 2014-03-20 21:51:17 UTC (rev 899) +++ pkg/pomp/tests/pfilter.Rout.save 2014-03-20 21:51:41 UTC (rev 900) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > pompExample(ou2) @@ -52,8 +53,8 @@ > print(coef(pf)) gamma mu iota beta1 beta2 beta3 beta.sd pop 2.60e+01 2.00e-02 1.00e-02 4.00e+02 4.80e+02 3.20e+02 1.00e-03 2.10e+06 - rho S.0 I.0 R.0 -6.00e-01 6.50e-02 1.00e-03 9.35e-01 + rho overdisp S.0 I.0 R.0 +6.00e-01 1.00e+00 6.50e-02 1.00e-03 9.35e-01 > print(pf$loglik,digits=4) [1] -947.4 > @@ -64,8 +65,8 @@ > print(coef(pf)) gamma mu iota beta1 beta2 beta3 beta.sd pop 2.60e+01 2.00e-02 1.00e+00 4.00e+02 4.80e+02 3.20e+02 1.00e-03 2.10e+06 - rho S.0 I.0 R.0 -6.00e-01 6.50e-02 1.00e-03 9.35e-01 + rho overdisp S.0 I.0 R.0 +6.00e-01 1.00e+00 6.50e-02 1.00e-03 9.35e-01 > print(logLik(pf),digits=4) [1] -945.4 > plot(cond.loglik~time,data=as(pf,"data.frame"),type='l') @@ -78,4 +79,4 @@ > > proc.time() user system elapsed - 6.084 0.052 6.316 + 6.124 0.060 6.351 From noreply at r-forge.r-project.org Fri Mar 21 13:07:48 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Mar 2014 13:07:48 +0100 (CET) Subject: [Pomp-commits] r901 - in www: . content vignettes Message-ID: <20140321120748.4974B186DEE@r-forge.r-project.org> Author: kingaa Date: 2014-03-21 13:07:47 +0100 (Fri, 21 Mar 2014) New Revision: 901 Added: www/content/NEWS.html www/vignettes/pomp.pdf Modified: www/content/vignettes.htm www/index.php Log: - link to development version of manual and NEWS Added: www/content/NEWS.html =================================================================== --- www/content/NEWS.html (rev 0) +++ www/content/NEWS.html 2014-03-21 12:07:47 UTC (rev 901) @@ -0,0 +1,1210 @@ + +R: News for Package 'pomp' + + + + +
NEWSR Documentation
+ +

News for Package 'pomp'

+ +

Changes in pomp version 0.49-1

+ + +
    +
  • A new method, 'probe.match.objfun', constructs objective functions suitable for use in optimizers. +

    +
  • +
  • 'pomp' now depends on 'nloptr', which provides a suite of optimization algorithms. +This package can now be used in various methods for optimization of an objective function. +

    +
  • +
  • New inline C functions 'to_log_barycentric' and 'from_log_barycentric' are provided in 'pomp.h' to facilitate log-barycentric transformations. +These have proven very useful in dealing with parameters constrained to sum to one (e.g., initial conditions of compartmental models). +

    +
+ + + +

Changes in pomp version 0.48-3

+ + +
    +
  • Correct a bug in 'abc' to do with parameter transformation. +

    +
+ + + +

Changes in pomp version 0.48-1

+ + +
    +
  • Create new 'dprior' and 'rprior' slots for 'pomp' objects. +These will be used by the Bayesian methods (currently 'abc', 'bsmc', and 'pmcmc'). +The 'hyperparams' argument to these methods has been removed; +hyperparameters are now treated just as any others. +

    +
  • +
  • 'bsmc' can now be called so that the particles are drawn from the prior distribution (as set by the 'rpior' slot). +

    +
  • +
  • Some of the longer tests will only be run if an environment variable is set. +

    +
+ + + +

Changes in pomp version 0.47-4

+ + +
    +
  • Revisit 'dacca' bug. Set negative compartments to zero along with compartments immediately downstream. +

    +
+ + + +

Changes in pomp version 0.47-3

+ + +
    +
  • Fix bug that arises only very occasionally in the 'dacca' cholera example. +

    +
  • +
  • Modify 'dacca' model so that rare positivity violations are punished in a different way. +This modifies the formal model slightly. +

    +
+ + + +

Changes in pomp version 0.47-2

+ + +
    +
  • By default, 'pompBuilder' now creates all files in the temporary directory. +

    +
+ + + +

Changes in pomp version 0.47-1

+ + +
    +
  • 'abc' implements Approximate Bayesian Computation for pomp models. +

    +
+ + + +

Changes in pomp version 0.46-1

+ + +
    +
  • 'pompExample' now has an optional argument, 'envir', determining which environment the pomp object will be loaded into. +

    +
  • +
  • 'logmeanexp' now has an optional argument, 'se', allowing for computation of an approximate standard error. +

    +
+ + + +

Changes in pomp version 0.45-8

+ + +
    +
  • bug fix in 'gompertz' example. +

    +
+ + + +

Changes in pomp version 0.45-7

+ + +
    +
  • bug fix in 'pmcmc': Metropolis-Hastings ratio was incorrect except for flat priors! +

    +
+ + + +

Changes in pomp version 0.45-6

+ + +
    +
  • a fix so that 'pompBuilder' will find 'pomp.h' header file on Windows machines. Thanks to Dave Hayman for finding the problem. +

    +
  • +
  • new 'logmeanexp' function. +

    +
  • +
  • some reorganization of the source package structure. +

    +
+ + + +

Changes in pomp version 0.45-4

+ + +
    +
  • changes in the way 'reulermultinom', 'deulermultinom', 'dot_product' are exported to other packages. Rather than just being exported as linkables, these are now also defined as static inline functions in the 'pomp.h' header. +

    +
+ + + +

Changes in pomp version 0.45-3

+ + +
    +
  • fix bug with 'continue' and method 'mif2' +

    +
+ + + +

Changes in pomp version 0.45-2

+ + +
    +
  • new method to coerce 'pfilterd.pomp' objects to data-frames. +

    +
+ + + +

Changes in pomp version 0.45-1

+ + +
    +
  • 'profileDesign' can now handle variables of mixed type. +

    +
+ + + +

Changes in pomp version 0.44-1

+ + +
    +
  • New 'mif2' option for 'mif'. +

    +
  • +
  • The default behavior for 'mif' and 'pfilter' with respect to filtering failures has been changed. +Before, the default behavior has been to stop with an error on the first filtering failure ('max.fail=0'). +Now, the default is 'max.fail=Inf', i.e., an error is never triggered. +

    +
  • +
  • The implementation of MIF cooling schedules has been changed to make it more general. +The cooling schedule is now specified by a 'type' and a 'fraction'. +Currently, supported 'cooling.type's include 'geometric' (the old behavior) and 'hyperbolic', i.e., a 1/(1+n) schedule. +The 'cooling.fraction' argument specifies the cooling at 50 iterations. +That is, if s is the intensity of the random-walk perturbation to parameters at the first iteration ('rw.sd'), then the intensity at iteration 50 is s*cooling.fraction. +

    +
  • +
  • Remove all data()-loadable pomp objects. +To load the prebuilt example pomp objects from previous versions, use the new 'pompExample' function. +E.g., instead of 'data(euler.sir)', do 'pompExample("euler.sir")'. +

    +
+ + + +

Changes in pomp version 0.43-4

+ + +
    +
  • Clean up tests. +

    +
+ + + +

Changes in pomp version 0.43-3

+ + +
    +
  • Fix bug in 'pompBuilder' on mac. +

    +
  • +
  • Fix bug in 'dmeasure' when log=TRUE. Bug located by R. Reiner. +

    +
  • +
  • Add 'eff.sample.size' and 'cond.logLik' methods for 'pfilterd.pomp' objects. +

    +
+ + + +

Changes in pomp version 0.43-1

+ + +
    +
  • Modify 'traj.match.objfun' to allow arbitrary parameters to be passed to the ODE integrator. +

    +
  • +
  • Add 'params' argument to 'pomp' so that parameters can be specified at the time the pomp object is created. +

    +
+ + + +

Changes in pomp version 0.42-6

+ + +
    +
  • Improve error checking in 'pomp'. +

    +
  • +
  • Add support for covariates to 'pompBuilder'. +

    +
  • +
  • Add native parameter transformation routines to the demos. +

    +
  • +
  • Change the warning behavior in 'lookup_table' so that warnings are not generated unless true extrapolation is performed (i.e., eliminate the warnings at the boundary). +

    +
  • +
  • Some small modifications to the 'pomp.h' header file. +

    +
+ + + +

Changes in pomp version 0.42-4

+ + +
    +
  • When 'trajectory' calls 'ode', there is a need to preserve information across calls to the vectorfield-evaluating function. +The code has been modified to do this in a cleaner way. +

    +
+ + + +

Changes in pomp version 0.42-2

+ + +
    +
  • Several minor bugs have been fixed. +See the ChangeLog for details. +

    +
+ + + +

Changes in pomp version 0.42-1

+ + +
    +
  • An EXPERIMENTAL facility for constructing pomp objects out of native C routines is now included (pompBuilder). +This facility is being actively developed and future changes may not be backward compatible. +

    +
  • +
  • A new facility allowing access to the 'userdata' slot of a pomp object from compiled 'rprocess', 'rmeasure', 'dprocess', 'dmeasure', 'skeleton', and 'partrans' codes is now available. +Calls to the new C routines 'get_pomp_userdata', 'get_pomp_userdata_int', and 'get_pomp_userdata_double' allow retrieval of these elements. +

    +
  • +
  • Some of the data()-loadable examples have been reworked to make use of the above facility. +The parameterization of these examples has changed. +These changes are not backward compatible: codes that depend on the data()-loadable examples may be broken. +

    +
+ + + +

Changes in pomp version 0.41-8

+ + +
    +
  • A demonstration of 'pompBuilder' has been put into the 'advanced topics' vignette. +

    +
+ + + +

Changes in pomp version 0.41-7

+ + +
    +
  • A bug in the 'blowflies' example has been fixed. +Thanks to Greg Minshall for discovering it. +

    +
+ + + +

Changes in pomp version 0.41-6

+ + +
    +
  • The 'gompertz' example parameter transformations have been changed. +No longer are the names of the parameter vector changed in the transformation. +This change is not backward-compatible, but only codes using this example are affected. +

    +
  • +
  • The 'euler.sir' and 'gillespie.sir' examples have been changed. +The transmission rate beta(t) is now the arithmetic sum of the seasonality basis functions. +Before, it was the geometric sum. +R0 is now given by the arithmetic average of the beta parameters divided by (gamma+mu). +This change is not backward-compatible, but only codes using these examples are affected. +

    +
+ + + +

Changes in pomp version 0.41-5

+ + +
    +
  • An experimental facility for constructing pomp objects with native C routines is now included. +

    +
+ + + +

Changes in pomp version 0.41-4

+ + +
    +
  • The 'blowflies', 'euler.sir', 'gillespie.sir', 'bbs', and 'ricker' data()-loadable examples have been changed to make the parameterization simpler and more natural. +This change is not backward-compatible, but only codes using this example are affected. +

    +
+ + + +

Changes in pomp version 0.41-3

+ + +
    +
  • In 'trajectory', all vectorfield and map evaluation is now done in C for speed. +For continuous-time dynamical systems, this gives an approximately 4-fold speedup. +

    +
  • +
  • Demos have been created to show some examples. +

    +
+ + + +

Changes in pomp version 0.41-2

+ + +
    +
  • A segfault bug in 'bbs' example has been fixed. +

    +
  • +
  • The posterior medians (not means) are now stored in the 'params' slot of the 'bsmcd.pomp' object. +

    +
+ + + +

Changes in pomp version 0.41-1

+ + +
    +
  • New arguments in 'mif', 'nlf', 'bsmc', 'pmcmc', 'probe-match', and 'traj-match' allow the estimation to be done on a transformed parameter space. +When 'transform=TRUE' in these commands ('transform.params=TRUE' for 'nlf'), estimation is performed on the transformed parameter space. +This is described and demonstrated in the 'intro_to_pomp' vignette. +

    +
  • +
  • The data()-loadable examples have been re-implemented to make use of the above-mentioned facility. +Note that this new functionality makes it unnecessary to "un-transform" model parameters within the user-specified 'rprocess', 'dprocess', 'rmeasure', 'dmeasure', 'skeleton', and 'initializer' codes. +This change is not backward-compatible, but only codes using these data()-loadable example are affected. +

    +
  • +
  • The Bayesian sequential Monte Carlo command 'bsmc' now returns not a list but an object of class 'bsmcd.pomp'. +An experimental 'plot' method for objects of this class now exists. +Also, the parameter posterior means are now stored in the 'params' slot of the 'bsmcd.pomp' object: +access them with the 'coef' command as usual. +

    +
  • +
  • A new example, using data from an influenza outbreak in a British boarding school and an SIR model, has been included. +Do 'data(bbs)' to load it. +

    +
+ + + +

Changes in pomp version 0.40-9

+ + +
    +
  • Setting the new argument 'as.data.frame' to 'TRUE' in 'simulate' and 'trajectory' causes the results to be returned as a data-frame. +

    +
+ + + +

Changes in pomp version 0.40-8

+ + +
    +
  • A new method 'partrans' allows transformation of vectors or matrices of parameters. +The parameter transformations have been pushed into C for speed. +It is possible to specify native parameter transformation routines in addition to C functions, but this last facility has not yet been extensively tested. +A new slot 'has.trans' has been introduced into the 'pomp' class, and the types of slots 'par.trans' and 'par.untrans' have changed. +

    +
+ + + +

Changes in pomp version 0.40-7

+ + +
    +
  • 'parmat' now gracefully handles the case when 'params' is already a matrix. +

    +
  • +
  • Error in the documentation of 'pfilter' repaired. +Thanks to Alex Smith for pointing this out. +

    +
  • +
  • Improvements in the documentation of the Nicholson blowflies data 'data(blowflies)'. +

    +
+ + + +

Changes in pomp version 0.40-6

+ + +
    +
  • When a pomp object is updated using 'pomp', the 'params' slot will now be copied over (appropriately transformed). +Before, it was simply dropped. +

    +
  • +
  • The 'gillespie.sir' example has been changed to make the reporting rate equal to 'rho'. +Before, it was fixed at 10%. +

    +
  • +
  • A new error-trap has been put into 'probe' and 'probe.match' for the case nsim < nprobes. +Thanks to Dani Jonas for finding this error. +

    +
+ + + +

Changes in pomp version 0.40-5

+ + +
    +
  • More informative error messages when dimension of state space or data space disagree internally. +

    +
  • +
  • The 'weighted' argument to 'mif' and 'continue' is now deprecated in favor of a new argument 'method'. +The old 'weighted=T' corresponds to 'method="mif"' while the old 'weighted=F' corresponds to 'method="unweighted"'. +

    +
+ + + +

Changes in pomp version 0.40-4

+ + +
    +
  • New functions 'traj.match.objfun' and 'probe.match.objfun' have been added. +These functions construct functions of one argument suitable for use as objective functions in 'optim'-like optimizers (iincluding 'subplex' and 'sannbox'). +Minimizing these functions solves the trajectory-matching problem and probe-matching problem, respectively. +This allows the user much greater flexibility in choice of optimization algorithm than is afforded by 'traj.match' and 'probe.match'. +

    +
  • +
  • The 'sannbox' optimizer, which performs simulated annealing with box constraints, is now exported and available for general use. +

    +
+ + + +

Changes in pomp version 0.40-3

+ + +
    +
  • The 'bsmc' method has been improved, due to the contributions of Pierre Jacob. +Specifically, 'bsmc' no longer reports a log-likelihood (which it never actually computed anyway) but a log-evidence. +The latter computation was supplied by Pierre Jacob. +

    +
  • +
  • A new helper function, 'exp2geom_rate_correction' has been added to the 'pomp.h' file. +This function computes the rate r such that if N ~ geometric(prob=1-exp(-r*dt)) and T ~ exponential(rate=R), then E[N*dt] = E[T]. +This is useful in approximating a continuous-time death process by a discrete time (Euler) process. +In particular, in such a case, T is the waiting time to death in the former and N*dt is the waiting time to death in the latter. +An Euler binomial or multinomial process with rate r=exp2geom_rate_correction(R,dt) will have the same mean waiting time as the exponential process with rate R. +Thanks to Sebastien Ballesteros for suggesting this. +

    +
  • +
  • A new helper function, 'rgammawn' has been added, with both R and C interfaces. +This function draws an increment of a Gamma white-noise process with a given intensity. +Specifically, dw=rgammwn(sigma,dt) is Gamma distributed with mean dt and variance sigma^2*dt. +In this case, mu*dw/dt is suitable for use as a random rate in an Euler-multinomial process. +Thanks to Sebastien Ballesteros for suggesting this. +

    +
+ + + +

Changes in pomp version 0.40-2

+ + +
    +
  • A bug to do with computation of the number of steps needed in discrete-time simulation and trajectory computations has been fixed. +This bug was introduced in version 0.40-1. +

    +
+ + + +

Changes in pomp version 0.40-1

+ + +
    +
  • It is now possible for discrete-time determistic skeletons to have a general step-size. +Before, the stepsize was always forced to be 1. +The new argument 'skelmap.delta.t' in 'pomp' (default value 1) sets this step-size. +NB: in implementing this feature, a new slot has been added to the basic 'pomp' class. +'pomp' objects created with versions <0.40-1 will not therefore work with this version and must be re-created. +

    +
  • +
  • The deterministic skeleton trajectory functions now look for variables named in 'zeronames' and treat these variables as accumulators. +This brings the behavior of the deterministic skeleton functions into line with 'rprocess'. +A new section of the "advanced topics" vignette discusses accumulator variables and 'zeronames'. +

    +
  • +
  • Include the user manual PDF among the vignettes. +

    +
  • +
  • The new function 'parmat' creates a suitable matrix of parameters in one line. +

    +
+ + + +

Changes in pomp version 0.39-5

+ + +
    +
  • Bug fix in 'bsmc' that arises when the state space is 1-D. +Thanks to Arnab Bhattacharya for finding the bug. +

    +
  • +
  • Some inconsistencies in the arguments of 'bsmc' have been fixed. +

    +
+ + + +

Changes in pomp version 0.39-4

+ + +
    +
  • Minor corrections to the documentation for 'spect', 'probe', and 'traj.match'. +

    +
  • +
  • Fix infelicity in 'traj.match' and 'nlf' that arises when the 'data' slot has no rownames. +Rownames are not strictly required for the 'data' slot. +

    +
  • +
  • The 'sannbox' algorithm now should work even when the objective function throws a non-finite value. +The behavior now is to replace non-finite values with a large number. +This behavior follows that of the 'SANN' method in 'optim. +

    +
+ + + +

Changes in pomp version 0.39-3

+ + +
    +
  • The help files for 'pfilter' and 'mif' have been updated to explain how to use a variable number of particles in the particle filtering algorithm. +

    +
  • +
  • Inside 'init.state', a check has been added to make sure that the user's initializer function returns a vector of uniform size, as per the algorithms' assumptions. +Thanks to Micaela Martinez-Bakker for catching this. +

    +
  • +
  • 'mif' has been modified so as to allow estimation of initial-value parameters alone via fixed-lag smoothing. +

    +
+ + + +

Changes in pomp version 0.39-2

+ + +
    +
  • When 'po' is a 'pomp'-class object with covariates, 'as.data.frame(po)' and 'as(po,"data.frame")' now contain columns for the covariates. +The latter are interpolated, if necessary, at the observation times. +

    +
  • +
  • Bug fix: when 'pfilter' is called with a single parameter vector supplied in the 'params' argument, these parameters are copied into the 'params' slot of the resulting 'pfilterd.pomp' object. +Before, this failed when the 'params' slot of the 'pomp' object was empty. +A similar bug existed in 'traj.match' and has likewise been fixed. +

    +
  • +
  • To eliminate warnings and confusion during package check, 'profile.design' has been replaced by 'profileDesign'. +For parallelism, 'slice.design' and 'sobol.design' have been replaced by 'sliceDesign' and 'sobolDesign', respectively. +The older forms are now deprecated and will be removed in a future release. +

    +
+ + + +

Changes in pomp version 0.39-1

+ + +
    +
  • New facilities for parameter transformation are provided. +New optional arguments 'parameter.transform' and 'parameter.inv.transform' to 'pomp' allow the user to specify transformations between natural and internal parameter scalings. +A new option 'transfom' to 'coef' and 'coef<-' allows the user to get and set parameters on the natural scale. +See 'pomp?coef' and the "intro_to_pomp" vignette for details and examples. +Similarly, the 'conv.rec' method now takes an optional 'transform' argument. +

    +
  • +
  • Minor improvements to the documentation. +

    +
+ + + +

Changes in pomp version 0.38-5

+ + +
    +
  • 'pfilter' will now give an error if ever a non-finite likelihood (dmeasure value) is returned. +Before, errors were only generated when dmeasure returned NA. +

    +
  • +
  • 'spect' now returns frequencies reflective of the observation times. +Before, the frequencies were given as fractions of the sampling frequency. +

    +
+ + + +

Changes in pomp version 0.38-4

+ + +
    +
  • Improvements to the documentation. +

    +
+ + + +

Changes in pomp version 0.38-3

+ + +
    +
  • Clarifications and minor improvements in the help pages. +

    +
+ + + +

Changes in pomp version 0.38-2

+ + +
    +
  • A new section describing and demonstrating nonlinear forecasting has been added to the "intro to pomp" vignette. +

    +
  • +
  • Fixed bug in 'nlf': desire for transient period (nconverge>0) was unrecognized. +

    +
+ + + +

Changes in pomp version 0.38-1

+ + +
    +
  • Fixed bug in 'pomp' when 'data' is of class 'pomp': userdata should be preserved. +

    +
  • +
  • Improved discussion of SIR model in "Intro to pomp" vignette. +

    +
  • +
  • In 'pfilterd.pomp' objects, 'saved.states' and 'saved.params' slots are now length-ntimes lists of arrays. +

    +
  • +
  • It is now possible to use variable numbers of particles in 'pfilter'. +The 'Np' argument may be specified as a single number as before, or now as either a vector of numbers or a function. +

    +
+ + + +

Changes in pomp version 0.37-2

+ + +
    +
  • The "advanced topics" vignette has been much augmented and improved. +

    +
  • +
  • The 'euler.sir' example (load it with 'data(euler.sir)') has a different measurement model: a discretized normal distribution with the same mean and variance as before. +

    +
+ + + +

Changes in pomp version 0.37-1

+ + +
    +
  • The arguments 'skeleton.map' and 'skeleton.vectorfield' are now deprecated. +Specify a discrete-time skeleton using 'skeleton.type="map"' and a continuous-time skeleton via 'skeleton.type="vectorfield"'. +

    +
  • +
  • 'pomp' is now a generic function. +Calling it on a 'pomp' object copies the object; one can optionally modify some of the slots. +

    +
  • +
  • Two new files 'gompertz.R' and 'gompertz.c' are in the 'examples' directory. +These contain codes needed to reproduce the Gompertz example in the 'intro_to_pomp' vignette. +

    +
  • +
  • The warning messages to do with the default behaviors of 'simulate' and 'trajectory' with respect to the arguments 'times' and 't0' have been removed. +These warnings were introduced in version 0.34-1 to alert users to changes in the default behavior of 'simulate' and 'trajectory' introduced with that version. +See the help ("pomp?simulate", "pomp?trajectory") for details. +

    +
  • +
  • It is now possible to save both the states and particles portions of the filtering distributions computed in 'pfilter'. +This is accomplished by means of the logical 'save.states' and 'save.params' arguments to 'pfilter'. +The particles are stored in rank-3 arrays in the slots 'saved.states' and 'saved.params'. +This results in the need for a change in the structure of 'pfilterd.pomp' objects: note that 'pfilterd.pomp' objects (including 'mif' and 'pmcmc' objects) created under pre-0.37-1 version of the package will not load under versions >= 0.37-1. +

    +
+ + + +

Changes in pomp version 0.36-7

+ + +
    +
  • 'trajectory' now gives a more informative error when no skeleton is present +

    +
  • +
  • 'pred.mean', 'pred.var', and 'filter.mean' methods are now defined for 'pfilterd.pomp' objects (and not just 'mif' objects) +

    +
  • +
  • A new 'data()'-loadable example is included: do '?blowflies' to read about it. +

    +
+ + + +

Changes in pomp version 0.36-6

+ + +
    +
  • The B-spline basis construction functions 'bspline.basis' and 'periodic.bspline.basis' now take a 'names' argument that allows one to give names to the basis functions. +

    +
+ + + +

Changes in pomp version 0.36-5

+ + +
    +
  • The "intro_to_pomp" vignette has been updated. The first part of the vignette centers on a new, more transparent first example. +

    +
  • +
  • A bug in 'pfilter' has been fixed. This bug was introduced in version 0.32-6 (SVN revision 315). Upon filtering failure, state variables were left un-updated. Thanks to Karim Khader for reporting circumstances that led to the identification of this bug. +

    +
  • +
  • There is now a method for 'loglik' on 'probed.pomp' objects. This returns the synthetic likelihood. +

    +
  • +
  • The box-constrained simulated annealing optimization method 'sannbox' is now an option in 'probe.match'. +

    +
  • +
  • Calling 'states' on a pomp object having no unobserved states now fails gracefully (returning NULL rather than generating an error). +

    +
  • +
  • The rprocess plugin 'discrete.time.sim' now takes an optional 'delta.t' argument to allow for arbitrary (but still necessarily regular) spacing of observations. By default, delta.t=1. +

    +
+ + + +

Changes in pomp version 0.36-1

+ + +
    +
  • There are two new classes: 'traj.matched.pomp' and 'pfilterd.pomp' to hold the results of 'traj.match' and 'pfilter' computations, respectively. The old classes 'mif' and 'pmcmc' now inherit from 'pfilterd.pomp' in a natural way. +

    +
  • +
  • When 'traj.match' is called, the returned 'traj.matched.pomp' object has its 'states' slot filled with the model trajectory at the fitted parameters. +

    +
  • +
  • More optimization methods are now provided in 'traj.match'. These include the new algorithm "sannbox", an optionally box-constrained simulated annealing algorithm. +

    +
  • +
  • 'probe.match' is now an S4 method (like 'pfilter', 'mif', 'pmcmc', and 'traj.match') with methods for classes 'pomp', 'probed.pomp', and 'probe.matched.pomp'. +

    +
  • +
  • There is a change to the interface to 'pfilter' in that 'save.states' results in the filling of the 'last.states' slot. Before version 0.36-1, the 'pfilter' returned a list. The element 'states' of that list corresponds to the slot 'last.states' in version 0.36-1. It was necessary to make this name-change in order to avoid a conflict with the 'states' slot inherited from the 'pomp' class. +

    +
+ + + +

Changes in pomp version 0.35-1

+ + +
    +
  • Added a facility for computation of "synthetic likelihood" (Wood 2010) using a robust estimate of the covariance. A new slot in objects of class 'probed.pomp' holds this value. +

    +
  • +
  • The synthetic likelihood is now the quantity that is maximized in 'probe.match'. +

    +
  • +
  • Added the argument 'type' to 'probe.ccf' so that either cross-covariance or cross-correlation can be returned. 'probe.ccf' and 'probe.acf' now have comparable interfaces. +

    +
  • +
  • Changed the way that 'probe.acf' accepts lags. Now an arbitrary set of lags can be selected. +

    +
  • +
  • A bug in the new method 'obs' has been fixed. +

    +
  • +
  • A protection-stack overflow bug in 'probe' has been fixed. +

    +
  • +
  • The 'seed' slot in 'probed.pomp' and 'spect.pomp' objects has been removed, along with unwanted behavior to do with it. +

    +
+ + + +

Changes in pomp version 0.34-2

+ + +
    +
  • Added a method to coerce 'probed.pomp' objects to 'data.frame' objects. +

    +
  • +
  • Fix bug when 'simulate' is run on objects that inherit from 'pomp' but are not themselves pomps. +'simulate' should return 'pomp' objects when obs=F and states=F, regardless of what class 'object' is. +

    +
  • +
  • 'simulate' and 'rprocess' are accelerated somewhat through judicious use of 'memcpy'. +

    +
+ + + +

Changes in pomp version 0.34-1

+ + +
    +
  • The default behaviors of 'simulate' and 'trajectory' with respect to the argument 'times' has changed. +There is a new argument, 't0', which specifies the time at which the initial conditions obtain. +The default for 't0' is 'timezero(object)'. +The default for 'times' is now 'time(object,t0=FALSE)' (it was 'time(object,t0=TRUE)'). +This change eliminates an infelicity in which 'simulate' and 'trajectory' returned undesired values at the initial time. +Users can ensure that their codes will continue to function as intended by specifying the values of the 'times' and 't0' arguments to these functions, thus removing dependence on the defaults. +To aid users in modifying their codes, a warning is now displayed whenever a potentially affected call is made. +These warnings will be removed in a future release. +See the documentation ("pomp?simulate", "pomp?trajectory") for a description of the new default behaviors. +

    +
  • +
  • The 'states' slot now holds values of the state process only at the times given in the 'times' slot. +This is a change from the earlier behavior in which the 'states' slot sometimes included the value of the state process at 't0'. +

    +
  • +
  • 'simulate' has been re-implemented in C for speed. +

    +
  • +
  • A new method 'obs' for pomp objects returns the contents of the 'data' slot. +It is synonymous with 'data.array'. +

    +
  • +
  • A banner is now displayed on package attachment. +

    +
  • +
  • 'coef<-' now behaves like ordinary vector assignment. +

    +
  • +
  • 'probe' and 'spect' now take an argument 'params'. +

    +
  • +
  • 'probe.cov' and 'probe.cor' have been removed in favor of 'probe.acf' and 'probe.ccf'. +

    +
  • +
  • The functions 'euler.simulate', 'onestep.simulate', and 'onestep.density', deprecated since version 0.29-1, have been removed. +

    +
+ + + +

Changes in pomp version 0.33-1

+ + +
    +
  • Major improvements in speed in the probe-matching routines have been realized by coding the computationally-intensive portions of these calculations in C. +

    +
  • +
  • New probes recommended by Simon Wood (Nature 466:1102-1104, 2010) have been implemented. +In particular, the new function 'probe.marginal' regresses the marginal distributions of actual and simulated data against a reference distribution, returning as probes the regression coefficients. +'probe.marginal' and 'probe.acf' have been coded in C for speed. +

    +
+ + + +

Changes in pomp version 0.32-1

+ + +
    +
  • pomp now includes parameter estimation methods based on probe-matching and power-spectrum-matching as explained in papers by Kendall et al. (B. E. Kendall, C. J. Briggs, W. M. Murdoch, P. Turchin, S. P. Ellner, E. McCauley, R. M. Nisbet, S. N. Wood (1999) Why do populations cycle? A synthesis of statistical and mechanistic modeling approaches. Ecology, 80:1789–1805) and Reuman et al. (D.C. Reuman, R.A. Desharnais, R.F. Costantino, O. Ahmad, J.E. Cohen (2006) Power spectra reveal the influence of stochasticity on nonlinear population dynamics. Proc. Nat'l. Acad. Sci., U.S.A.} 103:18860–18865). +

    +
+ + + +

Changes in pomp version 0.31-2

+ + +
    +
  • new "window", "timezero", and "timezero<-" methods are available for manipulating 'pomp' objects. +

    +
+ + + +

Changes in pomp version 0.31-1

+ + +
    +
  • pomp now includes an implementation of the particle Markov chain Monte Carlo algorithm of Andrieu et al. (Andrieu, C., Doucet, A., & Holenstein, R. (2010) Particle Markov chain Monte Carlo methods. J. R. Stat. Soc. B 72:1–33). +This algorithm is implemented in the method 'pmcmc': see 'help(pmcmc)' for details. +Implementation primarily due to Ed Ionides. +

    +
+ + + +

Changes in pomp version 0.30-1

+ + +
    +
  • pomp now includes an implementation of the approximate Bayesian Sequential Monte Carlo algorithm of Liu & West (Liu, J. & West, M. (2001) Combining Parameter and State Estimation in Simulation-Based Filtering. In Doucet, A.; de Freitas, N. & Gordon, N. J. (eds.) Sequential Monte Carlo Methods in Practice, Springer, New York, pp. 197–224). +This algorithm is implemented in the method 'bsmc': see 'help(bsmc)' for details. +Thanks to Matt Ferrari and Michael Lavine for the implementation. +

    +
+ + + +

Changes in pomp version 0.29-5

+ + +
    +
  • The cholera transmission model from King, A. A., Ionides, E. L., Pascual, M., and Bouma, M. J. (2008) Inapparent infections and cholera dynamics, Nature 454:877–880 together with data from the Dacca district of historic Bengal are now included. +See 'help(dacca)' for details. +

    +
+ + + +

Changes in pomp version 0.29-1

+ + +
    +
  • This is a major revision. +

    +
  • +
  • Big improvements to the documentation, including worked examples in vignettes and improvements to the manual pages. +

    +
  • [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 901 From noreply at r-forge.r-project.org Fri Mar 21 16:32:17 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Mar 2014 16:32:17 +0100 (CET) Subject: [Pomp-commits] r902 - www/vignettes Message-ID: <20140321153217.61583186950@r-forge.r-project.org> Author: kingaa Date: 2014-03-21 16:32:17 +0100 (Fri, 21 Mar 2014) New Revision: 902 Modified: www/vignettes/pomp.pdf Log: - update manual Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Fri Mar 21 16:46:30 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Mar 2014 16:46:30 +0100 (CET) Subject: [Pomp-commits] r903 - in pkg/pomp: . inst man Message-ID: <20140321154630.A8C611867A8@r-forge.r-project.org> Author: kingaa Date: 2014-03-21 16:46:30 +0100 (Fri, 21 Mar 2014) New Revision: 903 Added: pkg/pomp/inst/NEWS.Rd Modified: pkg/pomp/DESCRIPTION pkg/pomp/inst/NEWS pkg/pomp/man/pomp.Rd Log: - remove some outdated remarks in 'pomp' man page - put NEWS into Rd format Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-21 15:32:17 UTC (rev 902) +++ pkg/pomp/DESCRIPTION 2014-03-21 15:46:30 UTC (rev 903) @@ -2,7 +2,7 @@ Type: Package Title: Statistical inference for partially observed Markov processes Version: 0.49-1 -Date: 2014-03-20 +Date: 2014-03-21 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-03-21 15:32:17 UTC (rev 902) +++ pkg/pomp/inst/NEWS 2014-03-21 15:46:30 UTC (rev 903) @@ -1,566 +1,927 @@ -NEWS -0.49-1 - o A new method, 'probe.match.objfun', constructs objective functions suitable for use in optimizers. +_N_e_w_s _f_o_r _P_a_c_k_a_g_e '_p_o_m_p' - o 'pomp' now depends on 'nloptr', which provides a suite of optimization algorithms. - This package can now be used in various methods for optimization of an objective function. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_9-_1: - o New inline C functions 'to_log_barycentric' and 'from_log_barycentric' are provided in 'pomp.h' to facilitate log-barycentric transformations. - These have proven very useful in dealing with parameters constrained to sum to one (e.g., initial conditions of compartmental models). + ? A new method, 'probe.match.objfun', constructs objective + functions suitable for use in optimizers. -0.48-3 - o Correct a bug in 'abc' to do with parameter transformation. + ? 'pomp' now depends on 'nloptr', which provides a suite of + optimization algorithms. This package can now be used in + various methods for optimization of an objective function. -0.48-1 - o Create new 'dprior' and 'rprior' slots for 'pomp' objects. - These will be used by the Bayesian methods (currently 'abc', 'bsmc', and 'pmcmc'). - The 'hyperparams' argument to these methods has been removed; - hyperparameters are now treated just as any others. + ? New inline C functions 'to_log_barycentric' and + 'from_log_barycentric' are provided in 'pomp.h' to facilitate + log-barycentric transformations. These have proven very + useful in dealing with parameters constrained to sum to one + (e.g., initial conditions of compartmental models). - o 'bsmc' can now be called so that the particles are drawn from the prior distribution (as set by the 'rpior' slot). +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_8-_3: - o Some of the longer tests will only be run if an environment variable is set. + ? Correct a bug in 'abc' to do with parameter transformation. -0.47-4 - o Revisit 'dacca' bug. Set negative compartments to zero along with compartments immediately downstream. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_8-_1: -0.47-3 - o Fix bug that arises only very occasionally in the 'dacca' cholera example. + ? Create new 'dprior' and 'rprior' slots for 'pomp' objects. + These will be used by the Bayesian methods (currently 'abc', + 'bsmc', and 'pmcmc'). The 'hyperparams' argument to these + methods has been removed; hyperparameters are now treated + just as any others. - o Modify 'dacca' model so that rare positivity violations are punished in a different way. - This modifies the formal model slightly. + ? 'bsmc' can now be called so that the particles are drawn from + the prior distribution (as set by the 'rpior' slot). -0.47-2 - o By default, 'pompBuilder' now creates all files in the temporary directory. + ? Some of the longer tests will only be run if an environment + variable is set. -0.47-1 - o 'abc' implements Approximate Bayesian Computation for pomp models. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_7-_4: -0.46-1 - o 'pompExample' now has an optional argument, 'envir', determining which environment the pomp object will be loaded into. + ? Revisit 'dacca' bug. Set negative compartments to zero along + with compartments immediately downstream. - o 'logmeanexp' now has an optional argument, 'se', allowing for computation of an approximate standard error. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_7-_3: -0.45-8 - o bug fix in 'gompertz' example. + ? Fix bug that arises only very occasionally in the 'dacca' + cholera example. -0.45-7 - o bug fix in 'pmcmc': Metropolis-Hastings ratio was incorrect except for flat priors! - -0.45-6 - o a fix so that 'pompBuilder' will find 'pomp.h' header file on Windows machines. Thanks to Dave Hayman for finding the problem. + ? Modify 'dacca' model so that rare positivity violations are + punished in a different way. This modifies the formal model + slightly. - o new 'logmeanexp' function. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_7-_2: - o some reorganization of the source package structure. + ? By default, 'pompBuilder' now creates all files in the + temporary directory. -0.45-4 - o changes in the way 'reulermultinom', 'deulermultinom', 'dot_product' are exported to other packages. Rather than just being exported as linkables, these are now also defined as static inline functions in the 'pomp.h' header. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_7-_1: -0.45-3 - o fix bug with 'continue' and method 'mif2' + ? 'abc' implements Approximate Bayesian Computation for pomp + models. -0.45-2 - o new method to coerce 'pfilterd.pomp' objects to data-frames. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_6-_1: -0.45-1 - o 'profileDesign' can now handle variables of mixed type. + ? 'pompExample' now has an optional argument, 'envir', + determining which environment the pomp object will be loaded + into. -0.44-1 - o New 'mif2' option for 'mif'. + ? 'logmeanexp' now has an optional argument, 'se', allowing for + computation of an approximate standard error. - o The default behavior for 'mif' and 'pfilter' with respect to filtering failures has been changed. - Before, the default behavior has been to stop with an error on the first filtering failure ('max.fail=0'). - Now, the default is 'max.fail=Inf', i.e., an error is never triggered. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_5-_8: - o The implementation of MIF cooling schedules has been changed to make it more general. - The cooling schedule is now specified by a 'type' and a 'fraction'. - Currently, supported 'cooling.type's include 'geometric' (the old behavior) and 'hyperbolic', i.e., a 1/(1+n) schedule. - The 'cooling.fraction' argument specifies the cooling at 50 iterations. - That is, if s is the intensity of the random-walk perturbation to parameters at the first iteration ('rw.sd'), then the intensity at iteration 50 is s*cooling.fraction. + ? bug fix in 'gompertz' example. - o Remove all data()-loadable pomp objects. - To load the prebuilt example pomp objects from previous versions, use the new 'pompExample' function. - E.g., instead of 'data(euler.sir)', do 'pompExample("euler.sir")'. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_5-_7: -0.43-4 - o Clean up tests. + ? bug fix in 'pmcmc': Metropolis-Hastings ratio was incorrect + except for flat priors! -0.43-3 - o Fix bug in 'pompBuilder' on mac. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_5-_6: - o Fix bug in 'dmeasure' when log=TRUE. Bug located by R. Reiner. + ? a fix so that 'pompBuilder' will find 'pomp.h' header file on + Windows machines. Thanks to Dave Hayman for finding the + problem. - o Add 'eff.sample.size' and 'cond.logLik' methods for 'pfilterd.pomp' objects. + ? new 'logmeanexp' function. -0.43-1 - o Modify 'traj.match.objfun' to allow arbitrary parameters to be passed to the ODE integrator. + ? some reorganization of the source package structure. - o Add 'params' argument to 'pomp' so that parameters can be specified at the time the pomp object is created. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_5-_4: -0.42-6 - o Improve error checking in 'pomp'. + ? changes in the way 'reulermultinom', 'deulermultinom', + 'dot_product' are exported to other packages. Rather than + just being exported as linkables, these are now also defined + as static inline functions in the 'pomp.h' header. - o Add support for covariates to 'pompBuilder'. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_5-_3: - o Add native parameter transformation routines to the demos. + ? fix bug with 'continue' and method 'mif2' - o Change the warning behavior in 'lookup_table' so that warnings are not generated unless true extrapolation is performed (i.e., eliminate the warnings at the boundary). +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_5-_2: - o Some small modifications to the 'pomp.h' header file. + ? new method to coerce 'pfilterd.pomp' objects to data-frames. -0.42-4 - o When 'trajectory' calls 'ode', there is a need to preserve information across calls to the vectorfield-evaluating function. - The code has been modified to do this in a cleaner way. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_5-_1: -0.42-2 - o Several minor bugs have been fixed. - See the ChangeLog for details. + ? 'profileDesign' can now handle variables of mixed type. -0.42-1 - o An EXPERIMENTAL facility for constructing pomp objects out of native C routines is now included (pompBuilder). - This facility is being actively developed and future changes may not be backward compatible. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_4-_1: - o A new facility allowing access to the 'userdata' slot of a pomp object from compiled 'rprocess', 'rmeasure', 'dprocess', 'dmeasure', 'skeleton', and 'partrans' codes is now available. - Calls to the new C routines 'get_pomp_userdata', 'get_pomp_userdata_int', and 'get_pomp_userdata_double' allow retrieval of these elements. + ? New 'mif2' option for 'mif'. - o Some of the data()-loadable examples have been reworked to make use of the above facility. - The parameterization of these examples has changed. - These changes are not backward compatible: codes that depend on the data()-loadable examples may be broken. + ? The default behavior for 'mif' and 'pfilter' with respect to + filtering failures has been changed. Before, the default + behavior has been to stop with an error on the first + filtering failure ('max.fail=0'). Now, the default is + 'max.fail=Inf', i.e., an error is never triggered. -0.41-8 - o A demonstration of 'pompBuilder' has been put into the 'advanced topics' vignette. + ? The implementation of MIF cooling schedules has been changed + to make it more general. The cooling schedule is now + specified by a 'type' and a 'fraction'. Currently, supported + 'cooling.type's include 'geometric' (the old behavior) and + 'hyperbolic', i.e., a 1/(1+n) schedule. The + 'cooling.fraction' argument specifies the cooling at 50 + iterations. That is, if s is the intensity of the + random-walk perturbation to parameters at the first iteration + ('rw.sd'), then the intensity at iteration 50 is + s*cooling.fraction. -0.41-7 - o A bug in the 'blowflies' example has been fixed. - Thanks to Greg Minshall for discovering it. + ? Remove all data()-loadable pomp objects. To load the + prebuilt example pomp objects from previous versions, use the + new 'pompExample' function. E.g., instead of + 'data(euler.sir)', do 'pompExample("euler.sir")'. -0.41-6 - o The 'gompertz' example parameter transformations have been changed. - No longer are the names of the parameter vector changed in the transformation. - This change is not backward-compatible, but only codes using this example are affected. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_3-_4: - o The 'euler.sir' and 'gillespie.sir' examples have been changed. - The transmission rate beta(t) is now the arithmetic sum of the seasonality basis functions. - Before, it was the geometric sum. - R0 is now given by the arithmetic average of the beta parameters divided by (gamma+mu). - This change is not backward-compatible, but only codes using these examples are affected. + ? Clean up tests. -0.41-5 - o An experimental facility for constructing pomp objects with native C routines is now included. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_3-_3: -0.41-4 - o The 'blowflies', 'euler.sir', 'gillespie.sir', 'bbs', and 'ricker' data()-loadable examples have been changed to make the parameterization simpler and more natural. - This change is not backward-compatible, but only codes using this example are affected. + ? Fix bug in 'pompBuilder' on mac. -0.41-3 - o In 'trajectory', all vectorfield and map evaluation is now done in C for speed. - For continuous-time dynamical systems, this gives an approximately 4-fold speedup. + ? Fix bug in 'dmeasure' when log=TRUE. Bug located by R. + Reiner. - o Demos have been created to show some examples. + ? Add 'eff.sample.size' and 'cond.logLik' methods for + 'pfilterd.pomp' objects. -0.41-2 - o A segfault bug in 'bbs' example has been fixed. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_3-_1: - o The posterior medians (not means) are now stored in the 'params' slot of the 'bsmcd.pomp' object. + ? Modify 'traj.match.objfun' to allow arbitrary parameters to + be passed to the ODE integrator. -0.41-1 - o New arguments in 'mif', 'nlf', 'bsmc', 'pmcmc', 'probe-match', and 'traj-match' allow the estimation to be done on a transformed parameter space. - When 'transform=TRUE' in these commands ('transform.params=TRUE' for 'nlf'), estimation is performed on the transformed parameter space. - This is described and demonstrated in the 'intro_to_pomp' vignette. + ? Add 'params' argument to 'pomp' so that parameters can be + specified at the time the pomp object is created. - o The data()-loadable examples have been re-implemented to make use of the above-mentioned facility. - Note that this new functionality makes it unnecessary to "un-transform" model parameters within the user-specified 'rprocess', 'dprocess', 'rmeasure', 'dmeasure', 'skeleton', and 'initializer' codes. - This change is not backward-compatible, but only codes using these data()-loadable example are affected. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_2-_6: - o The Bayesian sequential Monte Carlo command 'bsmc' now returns not a list but an object of class 'bsmcd.pomp'. - An experimental 'plot' method for objects of this class now exists. - Also, the parameter posterior means are now stored in the 'params' slot of the 'bsmcd.pomp' object: - access them with the 'coef' command as usual. + ? Improve error checking in 'pomp'. - o A new example, using data from an influenza outbreak in a British boarding school and an SIR model, has been included. - Do 'data(bbs)' to load it. + ? Add support for covariates to 'pompBuilder'. -0.40-9 - o Setting the new argument 'as.data.frame' to 'TRUE' in 'simulate' and 'trajectory' causes the results to be returned as a data-frame. + ? Add native parameter transformation routines to the demos. -0.40-8 - o A new method 'partrans' allows transformation of vectors or matrices of parameters. - The parameter transformations have been pushed into C for speed. - It is possible to specify native parameter transformation routines in addition to C functions, but this last facility has not yet been extensively tested. - A new slot 'has.trans' has been introduced into the 'pomp' class, and the types of slots 'par.trans' and 'par.untrans' have changed. + ? Change the warning behavior in 'lookup_table' so that + warnings are not generated unless true extrapolation is + performed (i.e., eliminate the warnings at the boundary). -0.40-7 - o 'parmat' now gracefully handles the case when 'params' is already a matrix. + ? Some small modifications to the 'pomp.h' header file. - o Error in the documentation of 'pfilter' repaired. - Thanks to Alex Smith for pointing this out. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_2-_4: - o Improvements in the documentation of the Nicholson blowflies data 'data(blowflies)'. + ? When 'trajectory' calls 'ode', there is a need to preserve + information across calls to the vectorfield-evaluating + function. The code has been modified to do this in a cleaner + way. -0.40-6 - o When a pomp object is updated using 'pomp', the 'params' slot will now be copied over (appropriately transformed). - Before, it was simply dropped. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_2-_2: - o The 'gillespie.sir' example has been changed to make the reporting rate equal to 'rho'. - Before, it was fixed at 10%. + ? Several minor bugs have been fixed. See the ChangeLog for + details. - o A new error-trap has been put into 'probe' and 'probe.match' for the case nsim < nprobes. - Thanks to Dani Jonas for finding this error. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_2-_1: -0.40-5 - o More informative error messages when dimension of state space or data space disagree internally. + ? An EXPERIMENTAL facility for constructing pomp objects out of + native C routines is now included (pompBuilder). This + facility is being actively developed and future changes may + not be backward compatible. - o The 'weighted' argument to 'mif' and 'continue' is now deprecated in favor of a new argument 'method'. - The old 'weighted=T' corresponds to 'method="mif"' while the old 'weighted=F' corresponds to 'method="unweighted"'. + ? A new facility allowing access to the 'userdata' slot of a + pomp object from compiled 'rprocess', 'rmeasure', 'dprocess', + 'dmeasure', 'skeleton', and 'partrans' codes is now + available. Calls to the new C routines 'get_pomp_userdata', + 'get_pomp_userdata_int', and 'get_pomp_userdata_double' allow + retrieval of these elements. -0.40-4 - o New functions 'traj.match.objfun' and 'probe.match.objfun' have been added. - These functions construct functions of one argument suitable for use as objective functions in 'optim'-like optimizers (iincluding 'subplex' and 'sannbox'). - Minimizing these functions solves the trajectory-matching problem and probe-matching problem, respectively. - This allows the user much greater flexibility in choice of optimization algorithm than is afforded by 'traj.match' and 'probe.match'. + ? Some of the data()-loadable examples have been reworked to + make use of the above facility. The parameterization of + these examples has changed. These changes are not backward + compatible: codes that depend on the data()-loadable examples + may be broken. - o The 'sannbox' optimizer, which performs simulated annealing with box constraints, is now exported and available for general use. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_8: -0.40-3 - o The 'bsmc' method has been improved, due to the contributions of Pierre Jacob. - Specifically, 'bsmc' no longer reports a log-likelihood (which it never actually computed anyway) but a log-evidence. - The latter computation was supplied by Pierre Jacob. + ? A demonstration of 'pompBuilder' has been put into the + 'advanced topics' vignette. - o A new helper function, 'exp2geom_rate_correction' has been added to the 'pomp.h' file. - This function computes the rate r such that if N ~ geometric(prob=1-exp(-r*dt)) and T ~ exponential(rate=R), then E[N*dt] = E[T]. - This is useful in approximating a continuous-time death process by a discrete time (Euler) process. - In particular, in such a case, T is the waiting time to death in the former and N*dt is the waiting time to death in the latter. - An Euler binomial or multinomial process with rate r=exp2geom_rate_correction(R,dt) will have the same mean waiting time as the exponential process with rate R. - Thanks to Sebastien Ballesteros for suggesting this. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_7: - o A new helper function, 'rgammawn' has been added, with both R and C interfaces. - This function draws an increment of a Gamma white-noise process with a given intensity. - Specifically, dw=rgammwn(sigma,dt) is Gamma distributed with mean dt and variance sigma^2*dt. - In this case, mu*dw/dt is suitable for use as a random rate in an Euler-multinomial process. - Thanks to Sebastien Ballesteros for suggesting this. + ? A bug in the 'blowflies' example has been fixed. Thanks to + Greg Minshall for discovering it. -0.40-2 - o A bug to do with computation of the number of steps needed in discrete-time simulation and trajectory computations has been fixed. - This bug was introduced in version 0.40-1. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_6: -0.40-1 - o It is now possible for discrete-time determistic skeletons to have a general step-size. - Before, the stepsize was always forced to be 1. - The new argument 'skelmap.delta.t' in 'pomp' (default value 1) sets this step-size. - NB: in implementing this feature, a new slot has been added to the basic 'pomp' class. - 'pomp' objects created with versions <0.40-1 will not therefore work with this version and must be re-created. + ? The 'gompertz' example parameter transformations have been + changed. No longer are the names of the parameter vector + changed in the transformation. This change is not + backward-compatible, but only codes using this example are + affected. - o The deterministic skeleton trajectory functions now look for variables named in 'zeronames' and treat these variables as accumulators. - This brings the behavior of the deterministic skeleton functions into line with 'rprocess'. - A new section of the "advanced topics" vignette discusses accumulator variables and 'zeronames'. + ? The 'euler.sir' and 'gillespie.sir' examples have been + changed. The transmission rate beta(t) is now the arithmetic + sum of the seasonality basis functions. Before, it was the + geometric sum. R0 is now given by the arithmetic average of + the beta parameters divided by (gamma+mu). This change is + not backward-compatible, but only codes using these examples + are affected. - o Include the user manual PDF among the vignettes. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_5: - o The new function 'parmat' creates a suitable matrix of parameters in one line. + ? An experimental facility for constructing pomp objects with + native C routines is now included. -0.39-5 - o Bug fix in 'bsmc' that arises when the state space is 1-D. - Thanks to Arnab Bhattacharya for finding the bug. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_4: - o Some inconsistencies in the arguments of 'bsmc' have been fixed. + ? The 'blowflies', 'euler.sir', 'gillespie.sir', 'bbs', and + 'ricker' data()-loadable examples have been changed to make + the parameterization simpler and more natural. This change + is not backward-compatible, but only codes using this example + are affected. -0.39-4 - o Minor corrections to the documentation for 'spect', 'probe', and 'traj.match'. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_3: - o Fix infelicity in 'traj.match' and 'nlf' that arises when the 'data' slot has no rownames. - Rownames are not strictly required for the 'data' slot. + ? In 'trajectory', all vectorfield and map evaluation is now + done in C for speed. For continuous-time dynamical systems, + this gives an approximately 4-fold speedup. - o The 'sannbox' algorithm now should work even when the objective function throws a non-finite value. - The behavior now is to replace non-finite values with a large number. - This behavior follows that of the 'SANN' method in 'optim. + ? Demos have been created to show some examples. -0.39-3 - o The help files for 'pfilter' and 'mif' have been updated to explain how to use a variable number of particles in the particle filtering algorithm. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_2: - o Inside 'init.state', a check has been added to make sure that the user's initializer function returns a vector of uniform size, as per the algorithms' assumptions. - Thanks to Micaela Martinez-Bakker for catching this. + ? A segfault bug in 'bbs' example has been fixed. - o 'mif' has been modified so as to allow estimation of initial-value parameters alone via fixed-lag smoothing. + ? The posterior medians (not means) are now stored in the + 'params' slot of the 'bsmcd.pomp' object. -0.39-2 - o When 'po' is a 'pomp'-class object with covariates, 'as.data.frame(po)' and 'as(po,"data.frame")' now contain columns for the covariates. - The latter are interpolated, if necessary, at the observation times. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_1-_1: - o Bug fix: when 'pfilter' is called with a single parameter vector supplied in the 'params' argument, these parameters are copied into the 'params' slot of the resulting 'pfilterd.pomp' object. - Before, this failed when the 'params' slot of the 'pomp' object was empty. - A similar bug existed in 'traj.match' and has likewise been fixed. + ? New arguments in 'mif', 'nlf', 'bsmc', 'pmcmc', + 'probe-match', and 'traj-match' allow the estimation to be + done on a transformed parameter space. When 'transform=TRUE' + in these commands ('transform.params=TRUE' for 'nlf'), + estimation is performed on the transformed parameter space. + This is described and demonstrated in the 'intro_to_pomp' + vignette. - o To eliminate warnings and confusion during package check, 'profile.design' has been replaced by 'profileDesign'. - For parallelism, 'slice.design' and 'sobol.design' have been replaced by 'sliceDesign' and 'sobolDesign', respectively. - The older forms are now deprecated and will be removed in a future release. + ? The data()-loadable examples have been re-implemented to make + use of the above-mentioned facility. Note that this new + functionality makes it unnecessary to "un-transform" model + parameters within the user-specified 'rprocess', 'dprocess', + 'rmeasure', 'dmeasure', 'skeleton', and 'initializer' codes. + This change is not backward-compatible, but only codes using + these data()-loadable example are affected. -0.39-1 - o New facilities for parameter transformation are provided. - New optional arguments 'parameter.transform' and 'parameter.inv.transform' to 'pomp' allow the user to specify transformations between natural and internal parameter scalings. - A new option 'transfom' to 'coef' and 'coef<-' allows the user to get and set parameters on the natural scale. - See 'pomp?coef' and the "intro_to_pomp" vignette for details and examples. - Similarly, the 'conv.rec' method now takes an optional 'transform' argument. + ? The Bayesian sequential Monte Carlo command 'bsmc' now + returns not a list but an object of class 'bsmcd.pomp'. An + experimental 'plot' method for objects of this class now + exists. Also, the parameter posterior means are now stored + in the 'params' slot of the 'bsmcd.pomp' object: access them + with the 'coef' command as usual. - o Minor improvements to the documentation. + ? A new example, using data from an influenza outbreak in a + British boarding school and an SIR model, has been included. + Do 'data(bbs)' to load it. -0.38-5 - o 'pfilter' will now give an error if ever a non-finite likelihood (dmeasure value) is returned. - Before, errors were only generated when dmeasure returned NA. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_0-_9: - o 'spect' now returns frequencies reflective of the observation times. - Before, the frequencies were given as fractions of the sampling frequency. + ? Setting the new argument 'as.data.frame' to 'TRUE' in + 'simulate' and 'trajectory' causes the results to be returned + as a data-frame. -0.38-4 - o Improvements to the documentation. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_0-_8: -0.38-3 - o Clarifications and minor improvements in the help pages. + ? A new method 'partrans' allows transformation of vectors or + matrices of parameters. The parameter transformations have + been pushed into C for speed. It is possible to specify + native parameter transformation routines in addition to C + functions, but this last facility has not yet been + extensively tested. A new slot 'has.trans' has been + introduced into the 'pomp' class, and the types of slots + 'par.trans' and 'par.untrans' have changed. -0.38-2 - o A new section describing and demonstrating nonlinear forecasting has been added to the "intro to pomp" vignette. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_0-_7: - o Fixed bug in 'nlf': desire for transient period (nconverge>0) was unrecognized. + ? 'parmat' now gracefully handles the case when 'params' is + already a matrix. -0.38-1 - o Fixed bug in 'pomp' when 'data' is of class 'pomp': userdata should be preserved. + ? Error in the documentation of 'pfilter' repaired. Thanks to + Alex Smith for pointing this out. - o Improved discussion of SIR model in "Intro to pomp" vignette. + ? Improvements in the documentation of the Nicholson blowflies + data 'data(blowflies)'. - o In 'pfilterd.pomp' objects, 'saved.states' and 'saved.params' slots are now length-ntimes lists of arrays. +_C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_0-_6: - o It is now possible to use variable numbers of particles in 'pfilter'. - The 'Np' argument may be specified as a single number as before, or now as either a vector of numbers or a function. + ? When a pomp object is updated using 'pomp', the 'params' slot + will now be copied over (appropriately transformed). Before, + it was simply dropped. -0.37-2 - o The "advanced topics" vignette has been much augmented and improved. + ? The 'gillespie.sir' example has been changed to make the + reporting rate equal to 'rho'. Before, it was fixed at 10%. - o The 'euler.sir' example (load it with 'data(euler.sir)') has a different measurement model: a discretized normal distribution with the same mean and variance as before. + ? A new error-trap has been put into 'probe' and 'probe.match' + for the case nsim < nprobes. Thanks to Dani Jonas for + finding this error. -0.37-1 - o The arguments 'skeleton.map' and 'skeleton.vectorfield' are now deprecated. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 903 From noreply at r-forge.r-project.org Fri Mar 21 18:41:10 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Mar 2014 18:41:10 +0100 (CET) Subject: [Pomp-commits] r904 - in www: content vignettes Message-ID: <20140321174110.4AA8018468D@r-forge.r-project.org> Author: kingaa Date: 2014-03-21 18:41:09 +0100 (Fri, 21 Mar 2014) New Revision: 904 Modified: www/content/about.htm www/content/refs.htm www/content/refs.tex www/vignettes/pomp.bib Log: - add some new references Modified: www/content/about.htm =================================================================== --- www/content/about.htm 2014-03-21 15:46:30 UTC (rev 903) +++ www/content/about.htm 2014-03-21 17:41:09 UTC (rev 904) @@ -11,16 +11,18 @@
  • the particle Markov chain Monte Carlo method of Andrieu et al. (2010),
  • +
  • approximate Bayesian computation (ABC; Toni et al. 2009)
  • +
  • the iterated filtering method of Ionides, Breto, & King (2006),
  • -
  • the nonlinear forecasting method of Ellner & Kendall,
  • +
  • probe-matching methods (e.g., Kendall et al. 1999)
  • -
  • probe-matching methods (e.g., Kendall et al. 1999), and
  • +
  • the nonlinear forecasting method of Ellner & Kendall,and
  • power-spectrum-matching methods of Reuman et al. (2006).
-

Simple worked examples are provided in vignettes and in the examples directory of the installed package.

+

Simple worked examples are provided in vignettes and in the examples directory of the installed package.

Future support for a variety of other algorithms is envisioned. A working group of the National Center for Ecological Analysis and Synthesis (NCEAS), "Inference for Mechanistic Models", is currently implementing additional methods for this package.

Modified: www/content/refs.htm =================================================================== --- www/content/refs.htm 2014-03-21 15:46:30 UTC (rev 903) +++ www/content/refs.htm 2014-03-21 17:41:09 UTC (rev 904) @@ -1,63 +1,73 @@ -

References

+

References

-
Andrieu, C., A. Doucet, and R. Holenstein. 2010.
+
Andrieu, C., A. Doucet, and R. Holenstein. 2010.
Particle Markov chain Monte Carlo methods.
Journal of the Royal Statistical Society, Series B, 72:269-342.
-
Arulampalam, M. S., S. Maskell, N. Gordon, and T. Clapp. 2002.
+
Arulampalam, M. S., S. Maskell, N. Gordon, and T. Clapp. 2002.
A Tutorial on Particle Filters for Online Nonlinear, Non-Gaussian Bayesian Tracking.
IEEE Transactions on Signal Processing, 50:174 - 188.
-
Bretó, C., D. He, E. L. Ionides, and A. A. King. 2009.
+
Bretó, C., D. He, E. L. Ionides, and A. A. King. 2009.
Time series analysis via mechanistic models.
Annals of Applied Statistics, 3:319-348.
-
Ellner, S. P., B. A. Bailey, G. V. Bobashev, A. R. Gallant, B. T. Grenfell, and D. W. Nychka. 1998.
+
Ellner, S. P., B. A. Bailey, G. V. Bobashev, A. R. Gallant, B. T. Grenfell, and D. W. Nychka. 1998.
Noise and nonlinearity in measles epidemics: Combining mechanistic and statistical approaches to population modeling.
American Naturalist, 151:425-440.
-
He, D., E. L. Ionides, and A. A. King. 2010.
+
He, D., E. L. Ionides, and A. A. King. 2010.
Plug-and-play inference for disease dynamics: measles in large and small populations as a case study.
Journal of the Royal Society Interface, 7:271-283.
-
Ionides, E. L., C. Bretó, and A. A. King. 2006.
+
Ionides, E. L., C. Bretó, and A. A. King. 2006.
Inference for nonlinear dynamical systems.
Proceedings of the National Academy of Sciences of the U.S.A., 103:18438-18443.
-
Kendall, B. E., C. J. Briggs, W. W. Murdoch, P. Turchin, S. P. Ellner, E. McCauley, R. M. Nisbet, and S. N. Wood. 1999.
+
Kendall, B. E., C. J. Briggs, W. W. Murdoch, P. Turchin, S. P. Ellner, E. McCauley, R. M. Nisbet, and S. N. Wood. 1999.
Why do populations cycle? A synthesis of statistical and mechanistic modeling approaches.
Ecology, 80:1789-1805.
-
Kendall, B. E., S. P. Ellner, E. McCauley, S. N. Wood, C. J. Briggs, W. M. Murdoch, and P. Turchin. 2005.
+
Kendall, B. E., S. P. Ellner, E. McCauley, S. N. Wood, C. J. Briggs, W. M. Murdoch, and P. Turchin. 2005.
Population cycles in the pine looper moth: Dynamical tests of mechanistic hypotheses.
Ecological Monographs, 75:259-276.
-
King, A. A., E. L. Ionides, M. Pascual, and M. J. Bouma. 2008.
+
King, A. A., E. L. Ionides, M. Pascual, and M. J. Bouma. 2008.
Inapparent infections and cholera dynamics.
Nature, 454:877-880.
-
Liu, J. and M. West. 2001.
+
Liu, J. and M. West. 2001.
Combining Parameter and State Estimation in Simulation-Based Filtering.
In A. Doucet, N. de Freitas, and N. J. Gordon, editors, Sequential Monte Carlo Methods in Practice, pages 197-224. Springer, New York.
-
Reuman, D. C., R. A. Desharnais, R. F. Costantino, O. S. Ahmad, and J. E. Cohen. 2006.
+
Reuman, D. C., R. A. Desharnais, R. F. Costantino, O. S. Ahmad, and J. E. Cohen. 2006.
Power spectra reveal the influence of stochasticity on nonlinear population dynamics.
Proceedings of the National Academy of Sciences of the U.S.A., 103:18860-18865.
-
Wood, S. N. 2010.
+
Toni, T. and M. P. H. Stumpf. 2010.
+
Simulation-based model selection for dynamical systems in systems and population biology.
+ Bioinformatics, 26:104-110.
+ +
Toni, T., D. Welch, N. Strelkowa, A. Ipsen, and M. P. H. Stumpf. 2009.
+ +
Approximate Bayesian computation scheme for parameter inference and model selection in dynamical systems.
+ Journal of the Royal Society, Interface, 6:187-202.
+ +
Wood, S. N. 2010.
+
Statistical inference for noisy nonlinear ecological dynamic systems.
Nature, 466:1102-1104.
Modified: www/content/refs.tex =================================================================== --- www/content/refs.tex 2014-03-21 15:46:30 UTC (rev 903) +++ www/content/refs.tex 2014-03-21 17:41:09 UTC (rev 904) @@ -16,9 +16,11 @@ \nocite{King2008} \nocite{Liu2001b} \nocite{Reuman2006} +\nocite{Toni2009a} +\nocite{Toni2010} \nocite{Wood2010} \bibliographystyle{ecology} -\bibliography{pomp} +\bibliography{../vignettes/pomp} \end{document} Modified: www/vignettes/pomp.bib =================================================================== --- www/vignettes/pomp.bib 2014-03-21 15:46:30 UTC (rev 903) +++ www/vignettes/pomp.bib 2014-03-21 17:41:09 UTC (rev 904) @@ -1,585 +1,384 @@ -% This file was created with JabRef 2.7b. +% This file was created with JabRef 2.10. % Encoding: UTF8 - at ARTICLE{Andrieu2010, - author = {Andrieu, Christophe and Doucet, Arnaud and Holenstein, Roman}, - title = {{P}article {M}arkov chain {M}onte {C}arlo methods}, - journal = {Journal of the Royal Statistical Society, Series B}, - year = {2010}, - volume = {72}, - pages = {269--342}, - number = {3}, - abstract = {Markov chain Monte Carlo and sequential Monte Carlo methods have emerged - as the two main tools to sample from high dimensional probability - distributions. Although asymptotic convergence of Markov chain Monte - Carlo algorithms is ensured under weak assumptions, the performance - of these algorithms is unreliable when the proposal distributions - that are used to explore the space are poorly chosen and/or if highly - correlated variables are updated independently. We show here how - it is possible to build efficient high dimensional proposal distributions - by using sequential Monte Carlo methods. This allows us not only - to improve over standard Markov chain Monte Carlo schemes but also - to make Bayesian inference feasible for a large class of statistical - models where this was not previously so. We demonstrate these algorithms - on a non-linear state space model and a Levy-driven stochastic volatility - model.}, - doi = {10.1111/j.1467-9868.2009.00736.x}, - file = {Andrieu2010.pdf:Andrieu2010.pdf:PDF}, - owner = {kingaa}, - timestamp = {2010.06.30} + + at Article{Andrieu2010, + Title = {{P}article {M}arkov chain {M}onte {C}arlo methods}, + Author = {Andrieu, Christophe and Doucet, Arnaud and Holenstein, Roman}, + Journal = {Journal of the Royal Statistical Society, Series B}, + Year = {2010}, + Number = {3}, + Pages = {269--342}, + Volume = {72}, + + Abstract = {Markov chain Monte Carlo and sequential Monte Carlo methods have emerged as the two main tools to sample from high dimensional probability distributions. Although asymptotic convergence of Markov chain Monte Carlo algorithms is ensured under weak assumptions, the performance of these algorithms is unreliable when the proposal distributions that are used to explore the space are poorly chosen and/or if highly correlated variables are updated independently. We show here how it is possible to build efficient high dimensional proposal distributions by using sequential Monte Carlo methods. This allows us not only to improve over standard Markov chain Monte Carlo schemes but also to make Bayesian inference feasible for a large class of statistical models where this was not previously so. We demonstrate these algorithms on a non-linear state space model and a Levy-driven stochastic volatility model.}, + Doi = {10.1111/j.1467-9868.2009.00736.x}, + File = {Andrieu2010.pdf:Andrieu2010.pdf:PDF}, + Owner = {kingaa}, + Timestamp = {2010.06.30} } - at ARTICLE{Arulampalam2002, - author = {Arulampalam, M. S. and Maskell, S. and Gordon, N. and Clapp, T.}, - title = {{A} {T}utorial on {P}article {F}ilters for {O}nline {N}onlinear, - {N}on-{G}aussian {B}ayesian {T}racking}, - journal = {IEEE Transactions on Signal Processing}, - year = {2002}, - volume = {50}, - pages = {174 -- 188}, - doi = {10.1109/78.978374}, - file = {Arulampalam2002.pdf:Desktop/Arulampalam2002.pdf:PDF}, - owner = {kingaa}, - timestamp = {2007.07.20} + at Article{Arulampalam2002, + Title = {{A} {T}utorial on {P}article {F}ilters for {O}nline {N}onlinear, {N}on-{G}aussian {B}ayesian {T}racking}, + Author = {Arulampalam, M. S. and Maskell, S. and Gordon, N. and Clapp, T.}, + Journal = {IEEE Transactions on Signal Processing}, + Year = {2002}, + Pages = {174 -- 188}, + Volume = {50}, + + Doi = {10.1109/78.978374}, + File = {Arulampalam2002.pdf:Desktop/Arulampalam2002.pdf:PDF}, + Owner = {kingaa}, + Timestamp = {2007.07.20} } - at ARTICLE{Bhadra2010, - author = {Bhadra, Anindya}, - title = {{D}iscussion of `{P}article {M}arkov chain {M}onte {C}arlo methods' - by {C}.\ {A}ndrieu, {A}.\ {D}oucet and {R}.\ {H}olenstein}, - journal = {Journal of the Royal Statistical Society, Series B}, - year = {2010}, - volume = {72}, - pages = {314--315}, - doi = {10.1111/j.1467-9868.2009.00736.x}, - textref = {Bhadra, A. (2010), Discussion of `Particle Markov chain Monte Carlo - methods' by C. Andrieu, A. Doucet and R. Holenstein, J. Roy. Stat. - Soc B 72:314-315} + at Article{Bhadra2010, + Title = {{D}iscussion of `{P}article {M}arkov chain {M}onte {C}arlo methods' by {C}.\ {A}ndrieu, {A}.\ {D}oucet and {R}.\ {H}olenstein}, + Author = {Bhadra, Anindya}, + Journal = {Journal of the Royal Statistical Society, Series B}, + Year = {2010}, + Pages = {314--315}, + Volume = {72}, + + Doi = {10.1111/j.1467-9868.2009.00736.x}, + Textref = {Bhadra, A. (2010), Discussion of `Particle Markov chain Monte Carlo methods' by C. Andrieu, A. Doucet and R. Holenstein, J. Roy. Stat. Soc B 72:314-315} } - at ARTICLE{Breto2009, - author = {Carles Bret\'{o} and Daihai He and Edward L. Ionides and Aaron A. - King}, - title = {{T}ime series analysis via mechanistic models}, - journal = {Annals of Applied Statistics}, - year = {2009}, - volume = {3}, - pages = {319--348}, - number = {1}, - abstract = {The purpose of time series analysis via mechanistic models is to reconcile - the known or hypothesized structure of a dynamical system with observations - collected over time. We develop a framework for constructing nonlinear - mechanistic models and carrying out inference. Our framework permits - the consideration of implicit dynamic models, meaning statistical - models for stochastic dynamical systems which are specified by a - simulation algorithm to generate sample paths. Inference procedures - that operate on implicit models are said to have the plug-and-play - property. Our work builds on recently developed plug-and-play inference - methodology for partially observed Markov models. We introduce a - class of implicitly specified Markov chains with stochastic transition - rates, and we demonstrate its applicability to open problems in statistical - inference for biological systems. As one example, these models are - shown to give a fresh perspective on measles transmission dynamics. - As a second example, we present a mechanistic analysis of cholera - incidence data, involving interaction between two competing strains - of the pathogen Vibrio cholerae.}, - doi = {10.1214/08-AOAS201}, - file = {Breto2009.pdf:Breto2009.pdf:PDF;:Breto2009_supp.pdf:PDF}, - owner = {kingaa}, - timestamp = {2009.09.15} + at Article{Breto2011, + Title = {Compound Markov counting processes and their applications to modeling infinitesimally over-dispersed systems}, + Author = {Bret{\'o}, Carles and Ionides, Edward L.}, + Journal = {Stochastic Processes and their Applications}, + Year = {2011}, + + Month = nov, + Number = {11}, + Pages = {2571--2591}, + Volume = {121}, + + __markedentry = {[kingaa:]}, + Abstract = {We propose an infinitesimal dispersion index for Markov counting processes. We show that, under standard moment existence conditions, a process is infinitesimally (over-)equi-dispersed if, and only if, it is simple (compound), i.e.?it increases in jumps of one (or more) unit(s), even though infinitesimally equi-dispersed processes might be under-, equi- or over-dispersed using previously studied indices. Compound processes arise, for example, when introducing continuous-time white noise to the rates of simple processes resulting in L{\'e}vy-driven SDEs. We construct multivariate infinitesimally over-dispersed compartment models and queuing networks, suitable for applications where moment constraints inherent to simple processes do not hold.}, + Doi = {10.1016/j.spa.2011.07.005}, + File = {Breto2011.pdf:Breto2011.pdf:PDF}, + ISSN = {0304-4149}, + Keywords = {Continuous time, Counting Markov process, Birth?death process, Environmental stochasticity, Infinitesimal over-dispersion, Simultaneous events}, + Owner = {kingaa}, + Timestamp = {2012.01.17} } - at ARTICLE{Breto2011, - author = {Bret{\'o}, Carles and Ionides, Edward L.}, - title = {Compound Markov counting processes and their applications to modeling - infinitesimally over-dispersed systems}, - journal = {Stochastic Processes and their Applications}, - year = {2011}, - volume = {121}, - pages = {2571--2591}, - number = {11}, - month = nov, - __markedentry = {[kingaa:]}, - abstract = {We propose an infinitesimal dispersion index for Markov counting processes. - We show that, under standard moment existence conditions, a process - is infinitesimally (over-)equi-dispersed if, and only if, it is simple - (compound), i.e.?it increases in jumps of one (or more) unit(s), - even though infinitesimally equi-dispersed processes might be under-, - equi- or over-dispersed using previously studied indices. Compound - processes arise, for example, when introducing continuous-time white - noise to the rates of simple processes resulting in L{\'e}vy-driven - SDEs. We construct multivariate infinitesimally over-dispersed compartment - models and queuing networks, suitable for applications where moment - constraints inherent to simple processes do not hold.}, - doi = {10.1016/j.spa.2011.07.005}, - file = {Breto2011.pdf:Breto2011.pdf:PDF}, - issn = {0304-4149}, - keywords = {Continuous time, Counting Markov process, Birth?death process, Environmental - stochasticity, Infinitesimal over-dispersion, Simultaneous events}, - owner = {kingaa}, - timestamp = {2012.01.17} + at Article{Breto2009, + Title = {{T}ime series analysis via mechanistic models}, + Author = {Carles Bret\'{o} and Daihai He and Edward L. Ionides and Aaron A. King}, + Journal = {Annals of Applied Statistics}, + Year = {2009}, + Number = {1}, + Pages = {319--348}, + Volume = {3}, + + Abstract = {The purpose of time series analysis via mechanistic models is to reconcile the known or hypothesized structure of a dynamical system with observations collected over time. We develop a framework for constructing nonlinear mechanistic models and carrying out inference. Our framework permits the consideration of implicit dynamic models, meaning statistical models for stochastic dynamical systems which are specified by a simulation algorithm to generate sample paths. Inference procedures that operate on implicit models are said to have the plug-and-play property. Our work builds on recently developed plug-and-play inference methodology for partially observed Markov models. We introduce a class of implicitly specified Markov chains with stochastic transition rates, and we demonstrate its applicability to open problems in statistical inference for biological systems. As one example, these models are shown to give a fresh perspective on measles transmission dynamics. As a second example, we present a mechanistic analysis of cholera incidence data, involving interaction between two competing strains of the pathogen Vibrio cholerae.}, + Doi = {10.1214/08-AOAS201}, + File = {Breto2009.pdf:Breto2009.pdf:PDF;:Breto2009_supp.pdf:PDF}, + Owner = {kingaa}, + Timestamp = {2009.09.15} } - at BOOK{Davison1997, - title = {{B}ootstrap {M}ethods and their {A}pplication}, - publisher = {Cambridge University Press}, - year = {1997}, - author = {A.C. Davison and D.V. Hinkley}, - address = {New York}, - owner = {kingaa}, - timestamp = {2011.05.26} + at Book{Davison1997, + Title = {{B}ootstrap {M}ethods and their {A}pplication}, + Author = {A.C. Davison and D.V. Hinkley}, + Publisher = {Cambridge University Press}, + Year = {1997}, + + Address = {New York}, + + Owner = {kingaa}, + Timestamp = {2011.05.26} } - at ARTICLE{Ellner1998, - author = {S. P. Ellner and B. A. Bailey and G. V. Bobashev and A. R. Gallant - and B. T. Grenfell and D. W. Nychka}, - title = {{N}oise and nonlinearity in measles epidemics: {C}ombining mechanistic - and statistical approaches to population modeling}, - journal = {American Naturalist}, - year = {1998}, - volume = {151}, - pages = {425--440}, - abstract = {We present and evaluate an approach to analyzing population dynamics - data using semimechanistic models. These models incorporate reliable - information on population structure and underlying dynamic mechanisms - but use nonparametric surface-fitting methods to avoid unsupported - assumptions about the precise form of rate equations. Using historical - data on measles epidemics as a case study, we show how this approach - can lead to better forecasts, better characterizations of the dynamics, - and a better understanding of the factors causing complex population - dynamics relative to either mechanistic models or purely descriptive - statistical time-series models. The semimechanistic models are found - to have better forecasting accuracy than either of the model types - used in previous analyses when tested on data not used to fit the - models. The dynamics are characterized as being both nonlinear and - noisy, and the global dynamics are clustered very tightly near the - border of stability (dominant Lyapunov exponent lambda approximate - to 0). However, locally in state space the dynamics oscillate between - strong short-term stability and strong short-term chaos (i.e., between - negative and positive local Lyapunov exponents). There is statistically - significant evidence for short-term chaos in all data sets examined. - Thus the nonlinearity in these systems is characterized by the variance - over state space in local measures of chaos versus stability rather - than a single summary measure of the overall dynamics as either chaotic - or nonchaotic.}, - file = {Ellner1998.pdf:Ellner1998.pdf:PDF}, - owner = {kingaa}, - timestamp = {2009.09.22} + at Article{Ellner1998, + Title = {{N}oise and nonlinearity in measles epidemics: {C}ombining mechanistic and statistical approaches to population modeling}, + Author = {S. P. Ellner and B. A. Bailey and G. V. Bobashev and A. R. Gallant and B. T. Grenfell and D. W. Nychka}, + Journal = {American Naturalist}, + Year = {1998}, + Pages = {425--440}, + Volume = {151}, + + Abstract = {We present and evaluate an approach to analyzing population dynamics data using semimechanistic models. These models incorporate reliable information on population structure and underlying dynamic mechanisms but use nonparametric surface-fitting methods to avoid unsupported assumptions about the precise form of rate equations. Using historical data on measles epidemics as a case study, we show how this approach can lead to better forecasts, better characterizations of the dynamics, and a better understanding of the factors causing complex population dynamics relative to either mechanistic models or purely descriptive statistical time-series models. The semimechanistic models are found to have better forecasting accuracy than either of the model types used in previous analyses when tested on data not used to fit the models. The dynamics are characterized as being both nonlinear and noisy, and the global dynamics are clustered very tightly near the border of stability (dominant Lyapunov exponent lambda approximate to 0). However, locally in state space the dynamics oscillate between strong short-term stability and strong short-term chaos (i.e., between negative and positive local Lyapunov exponents). There is statistically significant evidence for short-term chaos in all data sets examined. Thus the nonlinearity in these systems is characterized by the variance over state space in local measures of chaos versus stability rather than a single summary measure of the overall dynamics as either chaotic or nonchaotic.}, + File = {Ellner1998.pdf:Ellner1998.pdf:PDF}, + Owner = {kingaa}, + Timestamp = {2009.09.22} } - at ARTICLE{Gillespie1977a, - author = {D. T. Gillespie}, - title = {{E}xact {S}tochastic {S}imulation of {C}oupled {C}hemical {R}eactions}, - journal = {Journal of Physical Chemistry}, - year = {1977}, - volume = {81}, - pages = {2340--2361}, - file = {Gillespie1977a.pdf:Gillespie1977a.pdf:PDF}, - owner = {kingaa}, - timestamp = {2007.03.13} + at Article{Gillespie1977a, + Title = {{E}xact {S}tochastic {S}imulation of {C}oupled {C}hemical {R}eactions}, + Author = {D. T. Gillespie}, + Journal = {Journal of Physical Chemistry}, + Year = {1977}, + Pages = {2340--2361}, + Volume = {81}, + + File = {Gillespie1977a.pdf:Gillespie1977a.pdf:PDF}, + Owner = {kingaa}, + Timestamp = {2007.03.13} } - at BOOK{Gourieroux1996, - title = {{S}imulation-based {E}conometric {M}ethods}, - publisher = {Oxford University Press}, - year = {1996}, - author = {C. Gouri\'{e}roux and A. Monfort}, - owner = {kingaa}, - timestamp = {2011.05.26} + at Book{Gourieroux1996, + Title = {{S}imulation-based {E}conometric {M}ethods}, + Author = {C. Gouri\'{e}roux and A. Monfort}, + Publisher = {Oxford University Press}, + Year = {1996}, + + Owner = {kingaa}, + Timestamp = {2011.05.26} } - at ARTICLE{He2010, - author = {He, Daihai and Ionides, Edward L. and King, Aaron A.}, - title = {{P}lug-and-play inference for disease dynamics: measles in large - and small populations as a case study}, - journal = {Journal of the Royal Society Interface}, - year = {2010}, - volume = {7}, - pages = {271--283}, - month = jun, - abstract = {Statistical inference for mechanistic models of partially observed - dynamic systems is an active area of research. Most existing inference - methods place substantial restrictions upon the form of models that - can be fitted and hence upon the nature of the scientific hypotheses - that can be entertained and the data that can be used to evaluate - them. In contrast, the so-called methods require only simulations - from a model and are thus free of such restrictions. We show the - utility of the plug-and-play approach in the context of an investigation - of measles transmission dynamics. Our novel methodology enables us - to ask and answer questions that previous analyses have been unable - to address. Specifically, we demonstrate that plug-and-play methods - permit the development of a modelling and inference framework applicable - to data from both large and small populations. We thereby obtain - novel insights into the nature of heterogeneity in mixing and comment - on the importance of including extra-demographic stochasticity as - a means of dealing with environmental stochasticity and model misspecification. - Our approach is readily applicable to many other epidemiological - and ecological systems.}, - doi = {10.1098/rsif.2009.0151}, - file = {He2010.pdf:He2010.pdf:PDF;:He2010_Supplement.pdf:PDF}, - owner = {kingaa}, - timestamp = {2009.06.26} + at Article{He2010, + Title = {{P}lug-and-play inference for disease dynamics: measles in large and small populations as a case study}, + Author = {He, Daihai and Ionides, Edward L. and King, Aaron A.}, + Journal = {Journal of the Royal Society Interface}, + Year = {2010}, + + Month = jun, + Pages = {271--283}, + Volume = {7}, + + Abstract = {Statistical inference for mechanistic models of partially observed dynamic systems is an active area of research. Most existing inference methods place substantial restrictions upon the form of models that can be fitted and hence upon the nature of the scientific hypotheses that can be entertained and the data that can be used to evaluate them. In contrast, the so-called methods require only simulations from a model and are thus free of such restrictions. We show the utility of the plug-and-play approach in the context of an investigation of measles transmission dynamics. Our novel methodology enables us to ask and answer questions that previous analyses have been unable to address. Specifically, we demonstrate that plug-and-play methods permit the development of a modelling and inference framework applicable to data from both large and small populations. We thereby obtain novel insights into the nature of heterogeneity in mixing and comment on the importance of including extra-demographic stochasticity as a means of dealing with environmental stochasticity and model misspecification. Our approach is readily applicable to many other epidemiological and ecological systems.}, + Doi = {10.1098/rsif.2009.0151}, + File = {He2010.pdf:He2010.pdf:PDF;:He2010_Supplement.pdf:PDF}, + Owner = {kingaa}, + Timestamp = {2009.06.26} } - at ARTICLE{Ionides2011, - author = {E. L. Ionides and A. Bhadra and Y. Atchad{\'e} and A. A. King}, - title = {Iterated filtering}, - journal = {Annals of Statistics}, - year = {2011}, - volume = {39}, - pages = {1776--1802}, - number = {3}, - abstract = {Inference for partially observed Markov process models has been a - longstanding methodological challenge with many scientific and engineering - applications. Iterated filtering algorithms maximize the likelihood - function for partially observed Markov process models by solving - a recursive sequence of filtering problems. We present new theoretical - results pertaining to the convergence of iterated filtering algorithms - implemented via sequential Monte Carlo filters. This theory complements - the growing body of empirical evidence that iterated filtering algorithms - provide an effective inference strategy for scientific models of - nonlinear dynamic systems. The first step in our theory involves - studying a new recursive approach for maximizing the likelihood function - of a latent variable model, when this likelihood is evaluated via - importance sampling. This leads to the consideration of an iterated - importance sampling algorithm which serves as a simple special case - of iterated filtering, and may have applicability in its own right.}, - doi = {10.1214/11-AOS886}, - file = {Ionides2011.pdf:Ionides2011.pdf:PDF}, - owner = {kingaa}, - timestamp = {2011.03.07} + at Article{Ionides2011, + Title = {Iterated filtering}, + Author = {E. L. Ionides and A. Bhadra and Y. Atchad{\'e} and A. A. King}, + Journal = {Annals of Statistics}, + Year = {2011}, + Number = {3}, + Pages = {1776--1802}, + Volume = {39}, + [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 904 From noreply at r-forge.r-project.org Sat Mar 22 20:58:33 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 22 Mar 2014 20:58:33 +0100 (CET) Subject: [Pomp-commits] r905 - in pkg/pomp: . inst inst/doc man src Message-ID: <20140322195833.5184818681A@r-forge.r-project.org> Author: kingaa Date: 2014-03-22 20:58:32 +0100 (Sat, 22 Mar 2014) New Revision: 905 Added: pkg/pomp/inst/doc/ pkg/pomp/inst/doc/manual.pdf Removed: pkg/pomp/inst/doc/Makefile pkg/pomp/inst/doc/advanced_topics_in_pomp.Rnw pkg/pomp/inst/doc/intro_to_pomp.Rnw pkg/pomp/vignettes/ Modified: pkg/pomp/DESCRIPTION pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/inst/doc/advanced_topics_in_pomp.pdf pkg/pomp/inst/doc/index.html pkg/pomp/inst/doc/intro_to_pomp.pdf pkg/pomp/man/LondonYorke.Rd pkg/pomp/man/gompertz.Rd pkg/pomp/man/plugins.Rd pkg/pomp/man/pmcmc.Rd pkg/pomp/man/pomp-package.Rd pkg/pomp/man/pomp.Rd pkg/pomp/src/bspline.c pkg/pomp/src/skeleton.c pkg/pomp/src/trajectory.c Log: - fix bug in 'periodic.bspline.basis'. - use dynamic memory allocation in 'skeleton' and 'trajectory' to avoid UBSanitizer error in CRAN check - use dynamic memory allocation in 'bspline_internal' to avoid memtest error in CRAN check - update included vignettes (!) - remove pomp/vignettes/Makefile - replace pomp/vignettes with pomp/inst/doc Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-21 17:41:09 UTC (rev 904) +++ pkg/pomp/DESCRIPTION 2014-03-22 19:58:32 UTC (rev 905) @@ -2,7 +2,7 @@ Type: Package Title: Statistical inference for partially observed Markov processes Version: 0.49-1 -Date: 2014-03-21 +Date: 2014-03-22 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2014-03-21 17:41:09 UTC (rev 904) +++ pkg/pomp/inst/NEWS 2014-03-22 19:58:32 UTC (rev 905) @@ -15,6 +15,11 @@ useful in dealing with parameters constrained to sum to one (e.g., initial conditions of compartmental models). + ? Bug fix in 'periodic.bspline.basis'. + + ? Package vignettes are no longer available via 'vignette()' + but can be reached from the help index. + _C_h_a_n_g_e_s _i_n _p_o_m_p _v_e_r_s_i_o_n _0._4_8-_3: ? Correct a bug in 'abc' to do with parameter transformation. Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2014-03-21 17:41:09 UTC (rev 904) +++ pkg/pomp/inst/NEWS.Rd 2014-03-22 19:58:32 UTC (rev 905) @@ -4,9 +4,11 @@ \itemize{ \item A new method, 'probe.match.objfun', constructs objective functions suitable for use in optimizers. \item 'pomp' now depends on 'nloptr', which provides a suite of optimization algorithms. - This package can now be used in various methods for optimization of an objective function. + This package can now be used in various methods for optimization of an objective function. \item New inline C functions 'to_log_barycentric' and 'from_log_barycentric' are provided in 'pomp.h' to facilitate log-barycentric transformations. - These have proven very useful in dealing with parameters constrained to sum to one (e.g., initial conditions of compartmental models). + These have proven very useful in dealing with parameters constrained to sum to one (e.g., initial conditions of compartmental models). + \item Bug fix in 'periodic.bspline.basis'. + \item Package vignettes are no longer available via 'vignette()' but can be reached from the help index. } } \section{Changes in pomp version 0.48-3}{ @@ -17,9 +19,9 @@ \section{Changes in pomp version 0.48-1}{ \itemize{ \item Create new 'dprior' and 'rprior' slots for 'pomp' objects. - These will be used by the Bayesian methods (currently 'abc', 'bsmc', and 'pmcmc'). - The 'hyperparams' argument to these methods has been removed; - hyperparameters are now treated just as any others. + These will be used by the Bayesian methods (currently 'abc', 'bsmc', and 'pmcmc'). + The 'hyperparams' argument to these methods has been removed; + hyperparameters are now treated just as any others. \item 'bsmc' can now be called so that the particles are drawn from the prior distribution (as set by the 'rpior' slot). \item Some of the longer tests will only be run if an environment variable is set. } @@ -33,7 +35,7 @@ \itemize{ \item Fix bug that arises only very occasionally in the 'dacca' cholera example. \item Modify 'dacca' model so that rare positivity violations are punished in a different way. - This modifies the formal model slightly. + This modifies the formal model slightly. } } \section{Changes in pomp version 0.47-2}{ @@ -93,16 +95,16 @@ \itemize{ \item New 'mif2' option for 'mif'. \item The default behavior for 'mif' and 'pfilter' with respect to filtering failures has been changed. - Before, the default behavior has been to stop with an error on the first filtering failure ('max.fail=0'). - Now, the default is 'max.fail=Inf', i.e., an error is never triggered. + Before, the default behavior has been to stop with an error on the first filtering failure ('max.fail=0'). + Now, the default is 'max.fail=Inf', i.e., an error is never triggered. \item The implementation of MIF cooling schedules has been changed to make it more general. - The cooling schedule is now specified by a 'type' and a 'fraction'. - Currently, supported 'cooling.type's include 'geometric' (the old behavior) and 'hyperbolic', i.e., a 1/(1+n) schedule. - The 'cooling.fraction' argument specifies the cooling at 50 iterations. - That is, if s is the intensity of the random-walk perturbation to parameters at the first iteration ('rw.sd'), then the intensity at iteration 50 is s*cooling.fraction. + The cooling schedule is now specified by a 'type' and a 'fraction'. + Currently, supported 'cooling.type's include 'geometric' (the old behavior) and 'hyperbolic', i.e., a 1/(1+n) schedule. + The 'cooling.fraction' argument specifies the cooling at 50 iterations. + That is, if s is the intensity of the random-walk perturbation to parameters at the first iteration ('rw.sd'), then the intensity at iteration 50 is s*cooling.fraction. \item Remove all data()-loadable pomp objects. - To load the prebuilt example pomp objects from previous versions, use the new 'pompExample' function. - E.g., instead of 'data(euler.sir)', do 'pompExample("euler.sir")'. + To load the prebuilt example pomp objects from previous versions, use the new 'pompExample' function. + E.g., instead of 'data(euler.sir)', do 'pompExample("euler.sir")'. } } \section{Changes in pomp version 0.43-4}{ @@ -135,24 +137,24 @@ \section{Changes in pomp version 0.42-4}{ \itemize{ \item When 'trajectory' calls 'ode', there is a need to preserve information across calls to the vectorfield-evaluating function. - The code has been modified to do this in a cleaner way. + The code has been modified to do this in a cleaner way. } } \section{Changes in pomp version 0.42-2}{ \itemize{ \item Several minor bugs have been fixed. - See the ChangeLog for details. + See the ChangeLog for details. } } \section{Changes in pomp version 0.42-1}{ \itemize{ \item An EXPERIMENTAL facility for constructing pomp objects out of native C routines is now included (pompBuilder). - This facility is being actively developed and future changes may not be backward compatible. + This facility is being actively developed and future changes may not be backward compatible. \item A new facility allowing access to the 'userdata' slot of a pomp object from compiled 'rprocess', 'rmeasure', 'dprocess', 'dmeasure', 'skeleton', and 'partrans' codes is now available. - Calls to the new C routines 'get_pomp_userdata', 'get_pomp_userdata_int', and 'get_pomp_userdata_double' allow retrieval of these elements. + Calls to the new C routines 'get_pomp_userdata', 'get_pomp_userdata_int', and 'get_pomp_userdata_double' allow retrieval of these elements. \item Some of the data()-loadable examples have been reworked to make use of the above facility. - The parameterization of these examples has changed. - These changes are not backward compatible: codes that depend on the data()-loadable examples may be broken. + The parameterization of these examples has changed. + These changes are not backward compatible: codes that depend on the data()-loadable examples may be broken. } } \section{Changes in pomp version 0.41-8}{ @@ -163,19 +165,19 @@ \section{Changes in pomp version 0.41-7}{ \itemize{ \item A bug in the 'blowflies' example has been fixed. - Thanks to Greg Minshall for discovering it. + Thanks to Greg Minshall for discovering it. } } \section{Changes in pomp version 0.41-6}{ \itemize{ \item The 'gompertz' example parameter transformations have been changed. - No longer are the names of the parameter vector changed in the transformation. - This change is not backward-compatible, but only codes using this example are affected. + No longer are the names of the parameter vector changed in the transformation. + This change is not backward-compatible, but only codes using this example are affected. \item The 'euler.sir' and 'gillespie.sir' examples have been changed. - The transmission rate beta(t) is now the arithmetic sum of the seasonality basis functions. - Before, it was the geometric sum. - R0 is now given by the arithmetic average of the beta parameters divided by (gamma+mu). - This change is not backward-compatible, but only codes using these examples are affected. + The transmission rate beta(t) is now the arithmetic sum of the seasonality basis functions. + Before, it was the geometric sum. + R0 is now given by the arithmetic average of the beta parameters divided by (gamma+mu). + This change is not backward-compatible, but only codes using these examples are affected. } } \section{Changes in pomp version 0.41-5}{ @@ -186,13 +188,13 @@ \section{Changes in pomp version 0.41-4}{ \itemize{ \item The 'blowflies', 'euler.sir', 'gillespie.sir', 'bbs', and 'ricker' data()-loadable examples have been changed to make the parameterization simpler and more natural. - This change is not backward-compatible, but only codes using this example are affected. + This change is not backward-compatible, but only codes using this example are affected. } } \section{Changes in pomp version 0.41-3}{ \itemize{ \item In 'trajectory', all vectorfield and map evaluation is now done in C for speed. - For continuous-time dynamical systems, this gives an approximately 4-fold speedup. + For continuous-time dynamical systems, this gives an approximately 4-fold speedup. \item Demos have been created to show some examples. } } @@ -205,17 +207,17 @@ \section{Changes in pomp version 0.41-1}{ \itemize{ \item New arguments in 'mif', 'nlf', 'bsmc', 'pmcmc', 'probe-match', and 'traj-match' allow the estimation to be done on a transformed parameter space. - When 'transform=TRUE' in these commands ('transform.params=TRUE' for 'nlf'), estimation is performed on the transformed parameter space. - This is described and demonstrated in the 'intro_to_pomp' vignette. + When 'transform=TRUE' in these commands ('transform.params=TRUE' for 'nlf'), estimation is performed on the transformed parameter space. + This is described and demonstrated in the 'intro_to_pomp' vignette. \item The data()-loadable examples have been re-implemented to make use of the above-mentioned facility. - Note that this new functionality makes it unnecessary to "un-transform" model parameters within the user-specified 'rprocess', 'dprocess', 'rmeasure', 'dmeasure', 'skeleton', and 'initializer' codes. - This change is not backward-compatible, but only codes using these data()-loadable example are affected. + Note that this new functionality makes it unnecessary to "un-transform" model parameters within the user-specified 'rprocess', 'dprocess', 'rmeasure', 'dmeasure', 'skeleton', and 'initializer' codes. + This change is not backward-compatible, but only codes using these data()-loadable example are affected. \item The Bayesian sequential Monte Carlo command 'bsmc' now returns not a list but an object of class 'bsmcd.pomp'. - An experimental 'plot' method for objects of this class now exists. - Also, the parameter posterior means are now stored in the 'params' slot of the 'bsmcd.pomp' object: - access them with the 'coef' command as usual. + An experimental 'plot' method for objects of this class now exists. + Also, the parameter posterior means are now stored in the 'params' slot of the 'bsmcd.pomp' object: + access them with the 'coef' command as usual. \item A new example, using data from an influenza outbreak in a British boarding school and an SIR model, has been included. - Do 'data(bbs)' to load it. + Do 'data(bbs)' to load it. } } \section{Changes in pomp version 0.40-9}{ @@ -226,79 +228,79 @@ \section{Changes in pomp version 0.40-8}{ \itemize{ \item A new method 'partrans' allows transformation of vectors or matrices of parameters. - The parameter transformations have been pushed into C for speed. - It is possible to specify native parameter transformation routines in addition to C functions, but this last facility has not yet been extensively tested. - A new slot 'has.trans' has been introduced into the 'pomp' class, and the types of slots 'par.trans' and 'par.untrans' have changed. + The parameter transformations have been pushed into C for speed. + It is possible to specify native parameter transformation routines in addition to C functions, but this last facility has not yet been extensively tested. + A new slot 'has.trans' has been introduced into the 'pomp' class, and the types of slots 'par.trans' and 'par.untrans' have changed. } } \section{Changes in pomp version 0.40-7}{ \itemize{ \item 'parmat' now gracefully handles the case when 'params' is already a matrix. \item Error in the documentation of 'pfilter' repaired. - Thanks to Alex Smith for pointing this out. + Thanks to Alex Smith for pointing this out. \item Improvements in the documentation of the Nicholson blowflies data 'data(blowflies)'. } } \section{Changes in pomp version 0.40-6}{ \itemize{ \item When a pomp object is updated using 'pomp', the 'params' slot will now be copied over (appropriately transformed). - Before, it was simply dropped. + Before, it was simply dropped. \item The 'gillespie.sir' example has been changed to make the reporting rate equal to 'rho'. - Before, it was fixed at 10\%. + Before, it was fixed at 10\%. \item A new error-trap has been put into 'probe' and 'probe.match' for the case nsim < nprobes. - Thanks to Dani Jonas for finding this error. + Thanks to Dani Jonas for finding this error. } } \section{Changes in pomp version 0.40-5}{ \itemize{ \item More informative error messages when dimension of state space or data space disagree internally. \item The 'weighted' argument to 'mif' and 'continue' is now deprecated in favor of a new argument 'method'. - The old 'weighted=T' corresponds to 'method="mif"' while the old 'weighted=F' corresponds to 'method="unweighted"'. + The old 'weighted=T' corresponds to 'method="mif"' while the old 'weighted=F' corresponds to 'method="unweighted"'. } } \section{Changes in pomp version 0.40-4}{ \itemize{ \item New functions 'traj.match.objfun' and 'probe.match.objfun' have been added. - These functions construct functions of one argument suitable for use as objective functions in 'optim'-like optimizers (iincluding 'subplex' and 'sannbox'). - Minimizing these functions solves the trajectory-matching problem and probe-matching problem, respectively. - This allows the user much greater flexibility in choice of optimization algorithm than is afforded by 'traj.match' and 'probe.match'. + These functions construct functions of one argument suitable for use as objective functions in 'optim'-like optimizers (iincluding 'subplex' and 'sannbox'). + Minimizing these functions solves the trajectory-matching problem and probe-matching problem, respectively. + This allows the user much greater flexibility in choice of optimization algorithm than is afforded by 'traj.match' and 'probe.match'. \item The 'sannbox' optimizer, which performs simulated annealing with box constraints, is now exported and available for general use. } } \section{Changes in pomp version 0.40-3}{ \itemize{ \item The 'bsmc' method has been improved, due to the contributions of Pierre Jacob. - Specifically, 'bsmc' no longer reports a log-likelihood (which it never actually computed anyway) but a log-evidence. - The latter computation was supplied by Pierre Jacob. + Specifically, 'bsmc' no longer reports a log-likelihood (which it never actually computed anyway) but a log-evidence. + The latter computation was supplied by Pierre Jacob. \item A new helper function, 'exp2geom_rate_correction' has been added to the 'pomp.h' file. - This function computes the rate r such that if N ~ geometric(prob=1-exp(-r*dt)) and T ~ exponential(rate=R), then E[N*dt] = E[T]. - This is useful in approximating a continuous-time death process by a discrete time (Euler) process. - In particular, in such a case, T is the waiting time to death in the former and N*dt is the waiting time to death in the latter. - An Euler binomial or multinomial process with rate r=exp2geom_rate_correction(R,dt) will have the same mean waiting time as the exponential process with rate R. - Thanks to Sebastien Ballesteros for suggesting this. + This function computes the rate r such that if N ~ geometric(prob=1-exp(-r*dt)) and T ~ exponential(rate=R), then E[N*dt] = E[T]. + This is useful in approximating a continuous-time death process by a discrete time (Euler) process. + In particular, in such a case, T is the waiting time to death in the former and N*dt is the waiting time to death in the latter. + An Euler binomial or multinomial process with rate r=exp2geom_rate_correction(R,dt) will have the same mean waiting time as the exponential process with rate R. + Thanks to Sebastien Ballesteros for suggesting this. \item A new helper function, 'rgammawn' has been added, with both R and C interfaces. - This function draws an increment of a Gamma white-noise process with a given intensity. - Specifically, dw=rgammwn(sigma,dt) is Gamma distributed with mean dt and variance sigma^2*dt. - In this case, mu*dw/dt is suitable for use as a random rate in an Euler-multinomial process. - Thanks to Sebastien Ballesteros for suggesting this. + This function draws an increment of a Gamma white-noise process with a given intensity. + Specifically, dw=rgammwn(sigma,dt) is Gamma distributed with mean dt and variance sigma^2*dt. + In this case, mu*dw/dt is suitable for use as a random rate in an Euler-multinomial process. + Thanks to Sebastien Ballesteros for suggesting this. } } \section{Changes in pomp version 0.40-2}{ \itemize{ \item A bug to do with computation of the number of steps needed in discrete-time simulation and trajectory computations has been fixed. - This bug was introduced in version 0.40-1. + This bug was introduced in version 0.40-1. } } \section{Changes in pomp version 0.40-1}{ \itemize{ \item It is now possible for discrete-time determistic skeletons to have a general step-size. - Before, the stepsize was always forced to be 1. - The new argument 'skelmap.delta.t' in 'pomp' (default value 1) sets this step-size. - NB: in implementing this feature, a new slot has been added to the basic 'pomp' class. - 'pomp' objects created with versions <0.40-1 will not therefore work with this version and must be re-created. + Before, the stepsize was always forced to be 1. + The new argument 'skelmap.delta.t' in 'pomp' (default value 1) sets this step-size. + NB: in implementing this feature, a new slot has been added to the basic 'pomp' class. + 'pomp' objects created with versions <0.40-1 will not therefore work with this version and must be re-created. \item The deterministic skeleton trajectory functions now look for variables named in 'zeronames' and treat these variables as accumulators. - This brings the behavior of the deterministic skeleton functions into line with 'rprocess'. - A new section of the "advanced topics" vignette discusses accumulator variables and 'zeronames'. + This brings the behavior of the deterministic skeleton functions into line with 'rprocess'. + A new section of the "advanced topics" vignette discusses accumulator variables and 'zeronames'. \item Include the user manual PDF among the vignettes. \item The new function 'parmat' creates a suitable matrix of parameters in one line. } @@ -306,7 +308,7 @@ \section{Changes in pomp version 0.39-5}{ \itemize{ \item Bug fix in 'bsmc' that arises when the state space is 1-D. - Thanks to Arnab Bhattacharya for finding the bug. + Thanks to Arnab Bhattacharya for finding the bug. \item Some inconsistencies in the arguments of 'bsmc' have been fixed. } } @@ -314,48 +316,48 @@ \itemize{ \item Minor corrections to the documentation for 'spect', 'probe', and 'traj.match'. \item Fix infelicity in 'traj.match' and 'nlf' that arises when the 'data' slot has no rownames. - Rownames are not strictly required for the 'data' slot. + Rownames are not strictly required for the 'data' slot. \item The 'sannbox' algorithm now should work even when the objective function throws a non-finite value. - The behavior now is to replace non-finite values with a large number. - This behavior follows that of the 'SANN' method in 'optim. + The behavior now is to replace non-finite values with a large number. + This behavior follows that of the 'SANN' method in 'optim. } } \section{Changes in pomp version 0.39-3}{ \itemize{ \item The help files for 'pfilter' and 'mif' have been updated to explain how to use a variable number of particles in the particle filtering algorithm. \item Inside 'init.state', a check has been added to make sure that the user's initializer function returns a vector of uniform size, as per the algorithms' assumptions. - Thanks to Micaela Martinez-Bakker for catching this. + Thanks to Micaela Martinez-Bakker for catching this. \item 'mif' has been modified so as to allow estimation of initial-value parameters alone via fixed-lag smoothing. } } \section{Changes in pomp version 0.39-2}{ \itemize{ \item When 'po' is a 'pomp'-class object with covariates, 'as.data.frame(po)' and 'as(po,"data.frame")' now contain columns for the covariates. - The latter are interpolated, if necessary, at the observation times. + The latter are interpolated, if necessary, at the observation times. \item Bug fix: when 'pfilter' is called with a single parameter vector supplied in the 'params' argument, these parameters are copied into the 'params' slot of the resulting 'pfilterd.pomp' object. - Before, this failed when the 'params' slot of the 'pomp' object was empty. - A similar bug existed in 'traj.match' and has likewise been fixed. + Before, this failed when the 'params' slot of the 'pomp' object was empty. + A similar bug existed in 'traj.match' and has likewise been fixed. \item To eliminate warnings and confusion during package check, 'profile.design' has been replaced by 'profileDesign'. - For parallelism, 'slice.design' and 'sobol.design' have been replaced by 'sliceDesign' and 'sobolDesign', respectively. - The older forms are now deprecated and will be removed in a future release. + For parallelism, 'slice.design' and 'sobol.design' have been replaced by 'sliceDesign' and 'sobolDesign', respectively. + The older forms are now deprecated and will be removed in a future release. } } \section{Changes in pomp version 0.39-1}{ \itemize{ \item New facilities for parameter transformation are provided. - New optional arguments 'parameter.transform' and 'parameter.inv.transform' to 'pomp' allow the user to specify transformations between natural and internal parameter scalings. - A new option 'transfom' to 'coef' and 'coef<-' allows the user to get and set parameters on the natural scale. - See 'pomp?coef' and the "intro_to_pomp" vignette for details and examples. - Similarly, the 'conv.rec' method now takes an optional 'transform' argument. + New optional arguments 'parameter.transform' and 'parameter.inv.transform' to 'pomp' allow the user to specify transformations between natural and internal parameter scalings. + A new option 'transfom' to 'coef' and 'coef<-' allows the user to get and set parameters on the natural scale. + See 'pomp?coef' and the "intro_to_pomp" vignette for details and examples. + Similarly, the 'conv.rec' method now takes an optional 'transform' argument. \item Minor improvements to the documentation. } } \section{Changes in pomp version 0.38-5}{ \itemize{ \item 'pfilter' will now give an error if ever a non-finite likelihood (dmeasure value) is returned. - Before, errors were only generated when dmeasure returned NA. + Before, errors were only generated when dmeasure returned NA. \item 'spect' now returns frequencies reflective of the observation times. - Before, the frequencies were given as fractions of the sampling frequency. + Before, the frequencies were given as fractions of the sampling frequency. } } \section{Changes in pomp version 0.38-4}{ @@ -380,7 +382,7 @@ \item Improved discussion of SIR model in "Intro to pomp" vignette. \item In 'pfilterd.pomp' objects, 'saved.states' and 'saved.params' slots are now length-ntimes lists of arrays. \item It is now possible to use variable numbers of particles in 'pfilter'. - The 'Np' argument may be specified as a single number as before, or now as either a vector of numbers or a function. + The 'Np' argument may be specified as a single number as before, or now as either a vector of numbers or a function. } } \section{Changes in pomp version 0.37-2}{ @@ -392,18 +394,18 @@ \section{Changes in pomp version 0.37-1}{ \itemize{ \item The arguments 'skeleton.map' and 'skeleton.vectorfield' are now deprecated. - Specify a discrete-time skeleton using 'skeleton.type="map"' and a continuous-time skeleton via 'skeleton.type="vectorfield"'. + Specify a discrete-time skeleton using 'skeleton.type="map"' and a continuous-time skeleton via 'skeleton.type="vectorfield"'. \item 'pomp' is now a generic function. - Calling it on a 'pomp' object copies the object; one can optionally modify some of the slots. + Calling it on a 'pomp' object copies the object; one can optionally modify some of the slots. \item Two new files 'gompertz.R' and 'gompertz.c' are in the 'examples' directory. - These contain codes needed to reproduce the Gompertz example in the 'intro_to_pomp' vignette. + These contain codes needed to reproduce the Gompertz example in the 'intro_to_pomp' vignette. \item The warning messages to do with the default behaviors of 'simulate' and 'trajectory' with respect to the arguments 'times' and 't0' have been removed. - These warnings were introduced in version 0.34-1 to alert users to changes in the default behavior of 'simulate' and 'trajectory' introduced with that version. - See the help ("pomp?simulate", "pomp?trajectory") for details. + These warnings were introduced in version 0.34-1 to alert users to changes in the default behavior of 'simulate' and 'trajectory' introduced with that version. + See the help ("pomp?simulate", "pomp?trajectory") for details. \item It is now possible to save both the states and particles portions of the filtering distributions computed in 'pfilter'. - This is accomplished by means of the logical 'save.states' and 'save.params' arguments to 'pfilter'. - The particles are stored in rank-3 arrays in the slots 'saved.states' and 'saved.params'. - This results in the need for a change in the structure of 'pfilterd.pomp' objects: note that 'pfilterd.pomp' objects (including 'mif' and 'pmcmc' objects) created under pre-0.37-1 version of the package will not load under versions >= 0.37-1. + This is accomplished by means of the logical 'save.states' and 'save.params' arguments to 'pfilter'. + The particles are stored in rank-3 arrays in the slots 'saved.states' and 'saved.params'. + This results in the need for a change in the structure of 'pfilterd.pomp' objects: note that 'pfilterd.pomp' objects (including 'mif' and 'pmcmc' objects) created under pre-0.37-1 version of the package will not load under versions >= 0.37-1. } } \section{Changes in pomp version 0.36-7}{ @@ -452,26 +454,26 @@ \itemize{ \item Added a method to coerce 'probed.pomp' objects to 'data.frame' objects. \item Fix bug when 'simulate' is run on objects that inherit from 'pomp' but are not themselves pomps. - 'simulate' should return 'pomp' objects when obs=F and states=F, regardless of what class 'object' is. + 'simulate' should return 'pomp' objects when obs=F and states=F, regardless of what class 'object' is. \item 'simulate' and 'rprocess' are accelerated somewhat through judicious use of 'memcpy'. } } \section{Changes in pomp version 0.34-1}{ \itemize{ \item The default behaviors of 'simulate' and 'trajectory' with respect to the argument 'times' has changed. - There is a new argument, 't0', which specifies the time at which the initial conditions obtain. - The default for 't0' is 'timezero(object)'. - The default for 'times' is now 'time(object,t0=FALSE)' (it was 'time(object,t0=TRUE)'). - This change eliminates an infelicity in which 'simulate' and 'trajectory' returned undesired values at the initial time. - Users can ensure that their codes will continue to function as intended by specifying the values of the 'times' and 't0' arguments to these functions, thus removing dependence on the defaults. - To aid users in modifying their codes, a warning is now displayed whenever a potentially affected call is made. - These warnings will be removed in a future release. - See the documentation ("pomp?simulate", "pomp?trajectory") for a description of the new default behaviors. + There is a new argument, 't0', which specifies the time at which the initial conditions obtain. + The default for 't0' is 'timezero(object)'. + The default for 'times' is now 'time(object,t0=FALSE)' (it was 'time(object,t0=TRUE)'). + This change eliminates an infelicity in which 'simulate' and 'trajectory' returned undesired values at the initial time. + Users can ensure that their codes will continue to function as intended by specifying the values of the 'times' and 't0' arguments to these functions, thus removing dependence on the defaults. + To aid users in modifying their codes, a warning is now displayed whenever a potentially affected call is made. + These warnings will be removed in a future release. + See the documentation ("pomp?simulate", "pomp?trajectory") for a description of the new default behaviors. \item The 'states' slot now holds values of the state process only at the times given in the 'times' slot. - This is a change from the earlier behavior in which the 'states' slot sometimes included the value of the state process at 't0'. + This is a change from the earlier behavior in which the 'states' slot sometimes included the value of the state process at 't0'. \item 'simulate' has been re-implemented in C for speed. \item A new method 'obs' for pomp objects returns the contents of the 'data' slot. - It is synonymous with 'data.array'. + It is synonymous with 'data.array'. \item A banner is now displayed on package attachment. \item 'coef<-' now behaves like ordinary vector assignment. \item 'probe' and 'spect' now take an argument 'params'. @@ -483,8 +485,8 @@ \itemize{ \item Major improvements in speed in the probe-matching routines have been realized by coding the computationally-intensive portions of these calculations in C. \item New probes recommended by Simon Wood (Nature 466:1102-1104, 2010) have been implemented. - In particular, the new function 'probe.marginal' regresses the marginal distributions of actual and simulated data against a reference distribution, returning as probes the regression coefficients. - 'probe.marginal' and 'probe.acf' have been coded in C for speed. + In particular, the new function 'probe.marginal' regresses the marginal distributions of actual and simulated data against a reference distribution, returning as probes the regression coefficients. + 'probe.marginal' and 'probe.acf' have been coded in C for speed. } } \section{Changes in pomp version 0.32-1}{ @@ -500,21 +502,21 @@ \section{Changes in pomp version 0.31-1}{ \itemize{ \item pomp now includes an implementation of the particle Markov chain Monte Carlo algorithm of Andrieu et al. (Andrieu, C., Doucet, A., & Holenstein, R. (2010) Particle Markov chain Monte Carlo methods. J. R. Stat. Soc. B 72:1--33). - This algorithm is implemented in the method 'pmcmc': see 'help(pmcmc)' for details. - Implementation primarily due to Ed Ionides. [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 905 From noreply at r-forge.r-project.org Sat Mar 22 21:03:42 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 22 Mar 2014 21:03:42 +0100 (CET) Subject: [Pomp-commits] r906 - pkg/pomp/man Message-ID: <20140322200342.8445C186911@r-forge.r-project.org> Author: kingaa Date: 2014-03-22 21:03:41 +0100 (Sat, 22 Mar 2014) New Revision: 906 Modified: pkg/pomp/man/gompertz.Rd Log: - minor error Modified: pkg/pomp/man/gompertz.Rd =================================================================== --- pkg/pomp/man/gompertz.Rd 2014-03-22 19:58:32 UTC (rev 905) +++ pkg/pomp/man/gompertz.Rd 2014-03-22 20:03:41 UTC (rev 906) @@ -18,6 +18,6 @@ coef(gompertz,transform=TRUE) } \seealso{ - \code{\link{pomp-class}} and the "intro_to_pomp" vignette}. + \code{\link{pomp-class}} and the "intro_to_pomp" vignette. } \keyword{datasets} From noreply at r-forge.r-project.org Sat Mar 22 21:04:49 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 22 Mar 2014 21:04:49 +0100 (CET) Subject: [Pomp-commits] r907 - pkg/pomp/inst/doc Message-ID: <20140322200449.AA5E7186950@r-forge.r-project.org> Author: kingaa Date: 2014-03-22 21:04:48 +0100 (Sat, 22 Mar 2014) New Revision: 907 Modified: pkg/pomp/inst/doc/manual.pdf Log: - fix manual Modified: pkg/pomp/inst/doc/manual.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Sun Mar 23 00:09:41 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 23 Mar 2014 00:09:41 +0100 (CET) Subject: [Pomp-commits] r908 - in pkg: . tao tao/R tao/inst tao/man Message-ID: <20140322230941.84D56180AC2@r-forge.r-project.org> Author: kingaa Date: 2014-03-23 00:09:40 +0100 (Sun, 23 Mar 2014) New Revision: 908 Added: pkg/tao/ pkg/tao/DESCRIPTION pkg/tao/NAMESPACE pkg/tao/R/ pkg/tao/R/do.nothing.R pkg/tao/R/do.nothing.else.R pkg/tao/inst/ pkg/tao/inst/GPL pkg/tao/inst/LICENSE pkg/tao/man/ pkg/tao/man/do.nothing.Rd pkg/tao/man/tao.Rd Log: Added: pkg/tao/DESCRIPTION =================================================================== --- pkg/tao/DESCRIPTION (rev 0) +++ pkg/tao/DESCRIPTION 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,9 @@ +Package: tao +Version: 1.0-1 +Date: 2009-04-01 +Title: Tao +Author: Aaron A. King, Bruce E. Kendall, Steve Ellner +Maintainer: Aaron A. King +Depends: R (>= 2.5.1) +Description: The package that can be described is not the Tao package. +License: GPL (>= 2) Added: pkg/tao/NAMESPACE =================================================================== --- pkg/tao/NAMESPACE (rev 0) +++ pkg/tao/NAMESPACE 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,4 @@ +export( + do.nothing, + do.nothing.else + ) Added: pkg/tao/R/do.nothing.R =================================================================== --- pkg/tao/R/do.nothing.R (rev 0) +++ pkg/tao/R/do.nothing.R 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,3 @@ +do.nothing <- function (...) { + invisible(NULL) +} Added: pkg/tao/R/do.nothing.else.R =================================================================== --- pkg/tao/R/do.nothing.else.R (rev 0) +++ pkg/tao/R/do.nothing.else.R 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,6 @@ +do.nothing.else <- function (...) { + while (TRUE) { + do.nothing(...) + } + invisible(NULL) +} Added: pkg/tao/inst/GPL =================================================================== --- pkg/tao/inst/GPL (rev 0) +++ pkg/tao/inst/GPL 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,118 @@ + GNU GENERAL PUBLIC LICENSE Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + Copyright (C) 19yy + +This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + +, 1 April 1989 Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. Added: pkg/tao/inst/LICENSE =================================================================== --- pkg/tao/inst/LICENSE (rev 0) +++ pkg/tao/inst/LICENSE 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,16 @@ +The tao package: The great Tao package + +This package is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +This package is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave., Cambridge, MA 02139 USA. + Added: pkg/tao/man/do.nothing.Rd =================================================================== --- pkg/tao/man/do.nothing.Rd (rev 0) +++ pkg/tao/man/do.nothing.Rd 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,31 @@ +\name{do.nothing} +\alias{do.nothing} +\alias{do.nothing.else} +\title{Do nothing, do not do nothing.} +\description{ + Nothing is done, nothing is left undone. +} +\usage{ +do.nothing(\dots) +do.nothing.else(\dots) +} +\arguments{ + \item{\dots}{Arguments avail not.} +} +\value{ + The softest thing on the universe overcomes the hardest thing in the universe. + That without substance can enter where there is no room. + Hence I know the value of non-action. + Teaching without words and work without doing are understood by very few. +} +\details{If nothing is done, then all will be well.} +\author{Aaron A. King (kingaa at umich dot edu)} +\references{} +\examples{ +do.nothing() +\dontrun{ +do.nothing.else() +} +} +\keyword{programming} + Added: pkg/tao/man/tao.Rd =================================================================== --- pkg/tao/man/tao.Rd (rev 0) +++ pkg/tao/man/tao.Rd 2014-03-22 23:09:40 UTC (rev 908) @@ -0,0 +1,16 @@ +\name{tao-package} +\docType{package} +\alias{tao-package} +\title{That which cannot be packaged.} +\description{The package that can be described is not the tao package.} +\details{ + Tao is the source of the ten thousand things. +} +\references{ + Lao Tsu, Tao Te Ching. + Adapted from the translation by Gia-Fu Feng and Jane English, Vintage Books (a division of Random House). + Online at http://elyxr.com/tao. +} +\author{Aaron A. King (kingaa at umich dot edu)} +\seealso{\code{\link{do.nothing}}, \code{\link{do.nothing.else}}} +\keyword{programming} From noreply at r-forge.r-project.org Sun Mar 23 14:18:58 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 23 Mar 2014 14:18:58 +0100 (CET) Subject: [Pomp-commits] r909 - in www: content vignettes Message-ID: <20140323131858.70CBF183A43@r-forge.r-project.org> Author: kingaa Date: 2014-03-23 14:18:58 +0100 (Sun, 23 Mar 2014) New Revision: 909 Modified: www/content/NEWS.html www/vignettes/pomp.pdf Log: - up to date Modified: www/content/NEWS.html =================================================================== --- www/content/NEWS.html 2014-03-22 23:09:40 UTC (rev 908) +++ www/content/NEWS.html 2014-03-23 13:18:58 UTC (rev 909) @@ -22,6 +22,12 @@
  • New inline C functions 'to_log_barycentric' and 'from_log_barycentric' are provided in 'pomp.h' to facilitate log-barycentric transformations. These have proven very useful in dealing with parameters constrained to sum to one (e.g., initial conditions of compartmental models).

    +
  • +
  • Bug fix in 'periodic.bspline.basis'. +

    +
  • +
  • Package vignettes are no longer available via 'vignette()' but can be reached from the help index. +

  • Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Sun Mar 23 14:34:02 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 23 Mar 2014 14:34:02 +0100 (CET) Subject: [Pomp-commits] r910 - pkg Message-ID: <20140323133402.9C0EA186E87@r-forge.r-project.org> Author: kingaa Date: 2014-03-23 14:34:01 +0100 (Sun, 23 Mar 2014) New Revision: 910 Removed: pkg/tao/ Log: From noreply at r-forge.r-project.org Tue Mar 25 14:02:04 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 25 Mar 2014 14:02:04 +0100 (CET) Subject: [Pomp-commits] r911 - in pkg/pomp: . R inst/doc src Message-ID: <20140325130205.10CC0187145@r-forge.r-project.org> Author: kingaa Date: 2014-03-25 14:02:03 +0100 (Tue, 25 Mar 2014) New Revision: 911 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/abc.R pkg/pomp/inst/doc/manual.pdf pkg/pomp/src/SSA_wrapper.c pkg/pomp/src/euler.c pkg/pomp/src/rmeasure.c pkg/pomp/src/simulate.c pkg/pomp/src/trajectory.c Log: - make 'abc' class definition compatible with older versions of R - remove unneeded duplication of 'gnsi' in some C codes - oldest version of R against which package checked is 2.15.1 Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-23 13:34:01 UTC (rev 910) +++ pkg/pomp/DESCRIPTION 2014-03-25 13:02:03 UTC (rev 911) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.49-1 -Date: 2014-03-22 +Version: 0.49-2 +Date: 2014-03-25 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), @@ -18,7 +18,7 @@ ) URL: http://pomp.r-forge.r-project.org Description: Inference methods for partially-observed Markov processes -Depends: R(>= 2.14.1), stats, graphics, methods, mvtnorm, subplex, nloptr, deSolve +Depends: R(>= 2.15.1), stats, graphics, methods, mvtnorm, subplex, nloptr, deSolve License: GPL(>= 2) LazyData: true BuildVignettes: true Modified: pkg/pomp/R/abc.R =================================================================== --- pkg/pomp/R/abc.R 2014-03-23 13:34:01 UTC (rev 910) +++ pkg/pomp/R/abc.R 2014-03-25 13:02:03 UTC (rev 911) @@ -2,7 +2,7 @@ setClass( 'abc', contains='pomp', - slots=c( + representation=representation( pars = 'character', transform = 'logical', Nabc = 'integer', Modified: pkg/pomp/inst/doc/manual.pdf =================================================================== (Binary files differ) Modified: pkg/pomp/src/SSA_wrapper.c =================================================================== --- pkg/pomp/src/SSA_wrapper.c 2014-03-23 13:34:01 UTC (rev 910) +++ pkg/pomp/src/SSA_wrapper.c 2014-03-25 13:02:03 UTC (rev 911) @@ -105,8 +105,6 @@ int *sidx, *pidx, *cidx, *zidx; SEXP fn, Snames, Pnames, Cnames; - PROTECT(gnsi = duplicate(gnsi)); nprotect++; - dim = INTEGER(GET_DIM(xstart)); nvar = dim[0]; nrep = dim[1]; dim = INTEGER(GET_DIM(params)); npar = dim[0]; dim = INTEGER(GET_DIM(covar)); covlen = dim[0]; covdim = dim[1]; @@ -118,7 +116,6 @@ PROTECT(Cnames = GET_COLNAMES(GET_DIMNAMES(covar))); nprotect++; PROTECT(fn = pomp_fun_handler(func,gnsi,&use_native)); nprotect++; - *(INTEGER(gnsi)) = 0; if (use_native) { RXR = (pomp_ssa_rate_fn *) R_ExternalPtrAddr(fn); Modified: pkg/pomp/src/euler.c =================================================================== --- pkg/pomp/src/euler.c 2014-03-23 13:34:01 UTC (rev 910) +++ pkg/pomp/src/euler.c 2014-03-25 13:02:03 UTC (rev 911) @@ -20,8 +20,6 @@ pomp_onestep_sim *ff = NULL; int meth = *(INTEGER(AS_INTEGER(method))); // 0 = Euler, 1 = one-step, 2 = fixed step - PROTECT(gnsi = duplicate(gnsi)); nprotect++; - { int *dim; dim = INTEGER(GET_DIM(xstart)); nvars = dim[0]; nreps = dim[1]; @@ -47,7 +45,6 @@ // extract user function PROTECT(fn = pomp_fun_handler(func,gnsi,&mode)); nprotect++; - *(INTEGER(gnsi)) = 0; // set up switch (mode) { @@ -263,8 +260,6 @@ SEXP F; int *pidx = 0, *sidx = 0, *cidx = 0; - PROTECT(gnsi = duplicate(gnsi)); nprotect++; - { int *dim; dim = INTEGER(GET_DIM(x)); nvars = dim[0]; nreps = dim[1]; Modified: pkg/pomp/src/rmeasure.c =================================================================== --- pkg/pomp/src/rmeasure.c 2014-03-23 13:34:01 UTC (rev 910) +++ pkg/pomp/src/rmeasure.c 2014-03-25 13:02:03 UTC (rev 911) @@ -22,7 +22,6 @@ struct lookup_table covariate_table; pomp_measure_model_simulator *ff = NULL; - PROTECT(gnsi = duplicate(gnsi)); nprotect++; PROTECT(times = AS_NUMERIC(times)); nprotect++; ntimes = length(times); if (ntimes < 1) @@ -67,7 +66,6 @@ // extract the user-defined function PROTECT(fn = pomp_fun_handler(GET_SLOT(object,install("rmeasure")),gnsi,&mode)); nprotect++; - *(INTEGER(gnsi)) = 0; // extract 'userdata' as pairlist PROTECT(fcall = VectorToPairList(GET_SLOT(object,install("userdata")))); nprotect++; Modified: pkg/pomp/src/simulate.c =================================================================== --- pkg/pomp/src/simulate.c 2014-03-23 13:34:01 UTC (rev 910) +++ pkg/pomp/src/simulate.c 2014-03-25 13:02:03 UTC (rev 911) @@ -5,9 +5,8 @@ #include "pomp_internal.h" -SEXP simulation_computations (SEXP object, SEXP params, SEXP times, SEXP t0, SEXP nsim, - SEXP obs, SEXP states, - SEXP gnsi) +SEXP simulation_computations (SEXP object, SEXP params, SEXP times, SEXP t0, + SEXP nsim, SEXP obs, SEXP states, SEXP gnsi) { int nprotect = 0; SEXP xstart, x, y, alltimes, coef, yy, offset; @@ -22,8 +21,6 @@ double *s, *t, *xs, *xt, *ys, *yt, *ps, *pt, tt; int i, j, k, np, nx; - PROTECT(gnsi = duplicate(gnsi)); nprotect++; - PROTECT(offset = NEW_INTEGER(1)); nprotect++; *(INTEGER(offset)) = 1; Modified: pkg/pomp/src/trajectory.c =================================================================== --- pkg/pomp/src/trajectory.c 2014-03-23 13:34:01 UTC (rev 910) +++ pkg/pomp/src/trajectory.c 2014-03-25 13:02:03 UTC (rev 911) @@ -108,8 +108,6 @@ lookup_table covariate_table; double deltat, t; - PROTECT(gnsi = duplicate(gnsi)); nprotect++; - deltat = *(REAL(GET_SLOT(object,install("skelmap.delta.t")))); t = *(REAL(AS_NUMERIC(t0))); @@ -136,7 +134,6 @@ // extract user-defined function PROTECT(fn = pomp_fun_handler(GET_SLOT(object,install("skeleton")),gnsi,&mode)); nprotect++; - *(INTEGER(gnsi)) = 0; // extract 'userdata' as pairlist PROTECT(args = VectorToPairList(GET_SLOT(object,install("userdata")))); nprotect++; @@ -257,11 +254,8 @@ int *dim; int nvars, npars, nreps, ncovars; - PROTECT(gnsi = duplicate(gnsi)); nprotect++; - // extract user-defined skeleton function PROTECT(fn = pomp_fun_handler(GET_SLOT(object,install("skeleton")),gnsi,&mode)); nprotect++; - *(INTEGER(gnsi)) = 0; // extract 'userdata' as pairlist PROTECT(args = VectorToPairList(GET_SLOT(object,install("userdata")))); nprotect++; From noreply at r-forge.r-project.org Thu Mar 27 13:31:18 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 27 Mar 2014 13:31:18 +0100 (CET) Subject: [Pomp-commits] r912 - www/vignettes Message-ID: <20140327123118.B9B5E1872D7@r-forge.r-project.org> Author: kingaa Date: 2014-03-27 13:31:13 +0100 (Thu, 27 Mar 2014) New Revision: 912 Modified: www/vignettes/pomp.pdf Log: - update manual Modified: www/vignettes/pomp.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Thu Mar 27 13:31:51 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 27 Mar 2014 13:31:51 +0100 (CET) Subject: [Pomp-commits] r913 - pkg/pomp/inst/doc Message-ID: <20140327123151.548BE1872D9@r-forge.r-project.org> Author: kingaa Date: 2014-03-27 13:31:51 +0100 (Thu, 27 Mar 2014) New Revision: 913 Modified: pkg/pomp/inst/doc/manual.pdf Log: - update manual Modified: pkg/pomp/inst/doc/manual.pdf =================================================================== (Binary files differ) From noreply at r-forge.r-project.org Mon Mar 31 13:58:41 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 31 Mar 2014 13:58:41 +0200 (CEST) Subject: [Pomp-commits] r914 - in pkg/pomp: . inst/doc tests Message-ID: <20140331115841.55D1A186F7D@r-forge.r-project.org> Author: kingaa Date: 2014-03-31 13:58:40 +0200 (Mon, 31 Mar 2014) New Revision: 914 Modified: pkg/pomp/DESCRIPTION pkg/pomp/inst/doc/manual.pdf pkg/pomp/tests/abc.Rout.save pkg/pomp/tests/bbs-trajmatch.Rout.save pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/blowflies.Rout.save pkg/pomp/tests/dacca.R pkg/pomp/tests/dacca.Rout.save pkg/pomp/tests/dimchecks.Rout.save pkg/pomp/tests/fhn.Rout.save pkg/pomp/tests/filtfail.Rout.save pkg/pomp/tests/gillespie.Rout.save pkg/pomp/tests/gompertz.Rout.save pkg/pomp/tests/logistic.Rout.save pkg/pomp/tests/ou2-bsmc.Rout.save pkg/pomp/tests/ou2-forecast.Rout.save pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/ou2-mif-fp.R pkg/pomp/tests/ou2-mif-fp.Rout.save pkg/pomp/tests/ou2-mif.R pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/ou2-mif2.R pkg/pomp/tests/ou2-mif2.Rout.save pkg/pomp/tests/ou2-nlf.Rout.save pkg/pomp/tests/ou2-pmcmc.R pkg/pomp/tests/ou2-pmcmc.Rout.save pkg/pomp/tests/ou2-probe.Rout.save pkg/pomp/tests/ou2-procmeas.Rout.save pkg/pomp/tests/ou2-simulate.Rout.save pkg/pomp/tests/ou2-trajmatch.Rout.save pkg/pomp/tests/partrans.Rout.save pkg/pomp/tests/pfilter.Rout.save pkg/pomp/tests/pomppomp.Rout.save pkg/pomp/tests/prior.Rout.save pkg/pomp/tests/ricker-bsmc.R pkg/pomp/tests/ricker-bsmc.Rout.save pkg/pomp/tests/ricker-probe.R pkg/pomp/tests/ricker-probe.Rout.save pkg/pomp/tests/ricker-spect.Rout.save pkg/pomp/tests/ricker.Rout.save pkg/pomp/tests/rw2.Rout.save pkg/pomp/tests/sir.Rout.save pkg/pomp/tests/skeleton.Rout.save pkg/pomp/tests/steps.Rout.save pkg/pomp/tests/synlik.Rout.save pkg/pomp/tests/verhulst.Rout.save Log: - put tests back in for R-Forge version Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/DESCRIPTION 2014-03-31 11:58:40 UTC (rev 914) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical inference for partially observed Markov processes -Version: 0.49-2 -Date: 2014-03-25 +Version: 0.49-3 +Date: 2014-03-31 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), person(given=c("Edward","L."),family="Ionides",role=c("aut")), Modified: pkg/pomp/inst/doc/manual.pdf =================================================================== (Binary files differ) Modified: pkg/pomp/tests/abc.Rout.save =================================================================== --- pkg/pomp/tests/abc.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/abc.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -124,4 +124,4 @@ > > proc.time() user system elapsed - 7.816 0.084 8.154 + 7.884 0.052 8.120 Modified: pkg/pomp/tests/bbs-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/bbs-trajmatch.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/bbs-trajmatch.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -82,4 +82,4 @@ > > proc.time() user system elapsed - 2.14 0.04 2.21 + 2.396 0.048 2.469 Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/bbs.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -65,4 +65,4 @@ > > proc.time() user system elapsed - 2.908 0.064 3.003 + 2.888 0.064 3.011 Modified: pkg/pomp/tests/blowflies.Rout.save =================================================================== --- pkg/pomp/tests/blowflies.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/blowflies.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > pompExample(blowflies) @@ -71,4 +72,4 @@ > > proc.time() user system elapsed - 1.196 0.032 1.249 + 1.216 0.036 1.283 Modified: pkg/pomp/tests/dacca.R =================================================================== --- pkg/pomp/tests/dacca.R 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/dacca.R 2014-03-31 11:58:40 UTC (rev 914) @@ -1,89 +1,85 @@ -if (Sys.getenv("POMP_FULL_TESTS")=="yes") { +library(pomp) - library(pomp) +set.seed(1420306530L) - set.seed(1420306530L) +pompExample(dacca) - pompExample(dacca) +x <- as.data.frame(dacca) +x <- simulate(dacca,nsim=3,as.data.frame=TRUE) - x <- as.data.frame(dacca) - x <- simulate(dacca,nsim=3,as.data.frame=TRUE) +pf <- pfilter(dacca,Np=1000,seed=5886855L) +pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) - pf <- pfilter(dacca,Np=1000,seed=5886855L) - pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) +## to investigate the rogue crash: - ## to investigate the rogue crash: +dacca.pars <- c("gamma","eps","deltaI","beta.trend", + "log.beta1","log.beta2","log.beta3", + "log.beta4","log.beta5","log.beta6", + "log.omega1","log.omega2","log.omega3", + "log.omega4","log.omega5","log.omega6", + "sd.beta","tau") +dacca.ivps <- c("S.0","I.0","R1.0","R2.0","R3.0") +dacca.rw.sd <- c( + rep(0.1,length(dacca.pars)), + rep(0.2,length(dacca.ivps)) + ) +names(dacca.rw.sd) <- c(dacca.pars,dacca.ivps) - dacca.pars <- c("gamma","eps","deltaI","beta.trend", - "log.beta1","log.beta2","log.beta3", - "log.beta4","log.beta5","log.beta6", - "log.omega1","log.omega2","log.omega3", - "log.omega4","log.omega5","log.omega6", - "sd.beta","tau") - dacca.ivps <- c("S.0","I.0","R1.0","R2.0","R3.0") - dacca.rw.sd <- c( - rep(0.1,length(dacca.pars)), - rep(0.2,length(dacca.ivps)) - ) - names(dacca.rw.sd) <- c(dacca.pars,dacca.ivps) - - param.tab <- read.csv2(text=' +param.tab <- read.csv2(text=' "";"gamma";"eps";"rho";"delta";"deltaI";"clin";"alpha";"beta.trend";"log.beta1";"log.beta2";"log.beta3";"log.beta4";"log.beta5";"log.beta6";"log.omega1";"log.omega2";"log.omega3";"log.omega4";"log.omega5";"log.omega6";"sd.beta";"tau";"S.0";"I.0";"Rs.0";"R1.0";"R2.0";"R3.0";"nbasis";"nrstage" "mle1";20,8;19,1;0;0,02;0,06;1;1;-0,00498;0,747;6,38;-3,44;4,23;3,33;4,55;-1,6928195214;-2,5433835795;-2,8404393891;-4,6918179927;-8,4779724783;-4,3900588064;3,13;0,23;0,621;0,378;0;0,000843;0,000972;1,16e-07;6;3 "box_min";10;0,2;0;0,02;0,03;1;1;-0,01;-4;0;-4;0;0;0;-10;-10;-10;-10;-10;-10;1;0,1;0;0;0;0;0;0;6;3 "box_max";40;30;0;0,02;0,6;1;1;0;4;8;4;8;8;8;0;0;0;0;0;0;5;0,5;1;1;0;1;1;1;6;3 ', - row.names=1 - ) + row.names=1 + ) - dacca.hyperparams <- list( - min=unlist(param.tab["box_min",]), - max=unlist(param.tab["box_max",]) - ) +dacca.hyperparams <- list( + min=unlist(param.tab["box_min",]), + max=unlist(param.tab["box_max",]) + ) - dacca.rprior <- function (hyperparams, ...) { - r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) - names(r) <- names(hyperparams$min) - r - } +dacca.rprior <- function (hyperparams, ...) { + r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) + names(r) <- names(hyperparams$min) + r +} - op <- options(warn=-1) - - set.seed(7777+7) - params.tricky <- dacca.rprior(dacca.hyperparams) - m7 <- mif( - dacca, - Nmif=2, - start=params.tricky, - pars=dacca.pars, - ivps=dacca.ivps, - Np=100, - method="mif2", - rw.sd=dacca.rw.sd, - cooling.type="geometric", - cooling.fraction=sqrt(0.1), - var.factor=2, - transform=TRUE - ) - m7 <- continue(m7) +op <- options(warn=-1) - set.seed(12350) - th.draw <- dacca.rprior(dacca.hyperparams) - m1 <- mif( - dacca, - Nmif=10, - Np=100, - start=th.draw, - pars=dacca.pars, - ivps=dacca.ivps, - method="mif2", - rw.sd=dacca.rw.sd, - cooling.type="geometric", - cooling.fraction=sqrt(0.1), - var.factor=2, - transform=TRUE - ) +set.seed(7777+7) +params.tricky <- dacca.rprior(dacca.hyperparams) +m7 <- mif( + dacca, + Nmif=2, + start=params.tricky, + pars=dacca.pars, + ivps=dacca.ivps, + Np=100, + method="mif2", + rw.sd=dacca.rw.sd, + cooling.type="geometric", + cooling.fraction=sqrt(0.1), + var.factor=2, + transform=TRUE + ) +m7 <- continue(m7) - options(op) +set.seed(12350) +th.draw <- dacca.rprior(dacca.hyperparams) +m1 <- mif( + dacca, + Nmif=10, + Np=100, + start=th.draw, + pars=dacca.pars, + ivps=dacca.ivps, + method="mif2", + rw.sd=dacca.rw.sd, + cooling.type="geometric", + cooling.fraction=sqrt(0.1), + var.factor=2, + transform=TRUE + ) -} +options(op) Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/dacca.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -15,102 +15,98 @@ 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. -> if (Sys.getenv("POMP_FULL_TESTS")=="yes") { -+ -+ library(pomp) -+ -+ set.seed(1420306530L) -+ -+ pompExample(dacca) -+ -+ x <- as.data.frame(dacca) -+ x <- simulate(dacca,nsim=3,as.data.frame=TRUE) -+ -+ pf <- pfilter(dacca,Np=1000,seed=5886855L) -+ pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) -+ -+ ## to investigate the rogue crash: -+ -+ dacca.pars <- c("gamma","eps","deltaI","beta.trend", -+ "log.beta1","log.beta2","log.beta3", -+ "log.beta4","log.beta5","log.beta6", -+ "log.omega1","log.omega2","log.omega3", -+ "log.omega4","log.omega5","log.omega6", -+ "sd.beta","tau") -+ dacca.ivps <- c("S.0","I.0","R1.0","R2.0","R3.0") -+ dacca.rw.sd <- c( -+ rep(0.1,length(dacca.pars)), -+ rep(0.2,length(dacca.ivps)) -+ ) -+ names(dacca.rw.sd) <- c(dacca.pars,dacca.ivps) -+ -+ param.tab <- read.csv2(text=' -+ "";"gamma";"eps";"rho";"delta";"deltaI";"clin";"alpha";"beta.trend";"log.beta1";"log.beta2";"log.beta3";"log.beta4";"log.beta5";"log.beta6";"log.omega1";"log.omega2";"log.omega3";"log.omega4";"log.omega5";"log.omega6";"sd.beta";"tau";"S.0";"I.0";"Rs.0";"R1.0";"R2.0";"R3.0";"nbasis";"nrstage" -+ "mle1";20,8;19,1;0;0,02;0,06;1;1;-0,00498;0,747;6,38;-3,44;4,23;3,33;4,55;-1,6928195214;-2,5433835795;-2,8404393891;-4,6918179927;-8,4779724783;-4,3900588064;3,13;0,23;0,621;0,378;0;0,000843;0,000972;1,16e-07;6;3 -+ "box_min";10;0,2;0;0,02;0,03;1;1;-0,01;-4;0;-4;0;0;0;-10;-10;-10;-10;-10;-10;1;0,1;0;0;0;0;0;0;6;3 -+ "box_max";40;30;0;0,02;0,6;1;1;0;4;8;4;8;8;8;0;0;0;0;0;0;5;0,5;1;1;0;1;1;1;6;3 -+ ', -+ row.names=1 -+ ) -+ -+ dacca.hyperparams <- list( -+ min=unlist(param.tab["box_min",]), -+ max=unlist(param.tab["box_max",]) -+ ) -+ -+ dacca.rprior <- function (hyperparams, ...) { -+ r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) -+ names(r) <- names(hyperparams$min) -+ r -+ } -+ -+ op <- options(warn=-1) -+ -+ set.seed(7777+7) -+ params.tricky <- dacca.rprior(dacca.hyperparams) -+ m7 <- mif( -+ dacca, -+ Nmif=2, -+ start=params.tricky, -+ pars=dacca.pars, -+ ivps=dacca.ivps, -+ Np=100, -+ method="mif2", -+ rw.sd=dacca.rw.sd, -+ cooling.type="geometric", -+ cooling.fraction=sqrt(0.1), -+ var.factor=2, -+ transform=TRUE -+ ) -+ m7 <- continue(m7) -+ -+ set.seed(12350) -+ th.draw <- dacca.rprior(dacca.hyperparams) -+ m1 <- mif( -+ dacca, -+ Nmif=10, -+ Np=100, -+ start=th.draw, -+ pars=dacca.pars, -+ ivps=dacca.ivps, -+ method="mif2", -+ rw.sd=dacca.rw.sd, -+ cooling.type="geometric", -+ cooling.fraction=sqrt(0.1), -+ var.factor=2, -+ transform=TRUE -+ ) -+ -+ options(op) -+ -+ } +> library(pomp) Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr Loading required package: deSolve +> +> set.seed(1420306530L) +> +> pompExample(dacca) newly created pomp object(s): dacca > +> x <- as.data.frame(dacca) +> x <- simulate(dacca,nsim=3,as.data.frame=TRUE) +> +> pf <- pfilter(dacca,Np=1000,seed=5886855L) +> pf1 <- pfilter(simulate(dacca),Np=1000,seed=5886855L) +> +> ## to investigate the rogue crash: +> +> dacca.pars <- c("gamma","eps","deltaI","beta.trend", ++ "log.beta1","log.beta2","log.beta3", ++ "log.beta4","log.beta5","log.beta6", ++ "log.omega1","log.omega2","log.omega3", ++ "log.omega4","log.omega5","log.omega6", ++ "sd.beta","tau") +> dacca.ivps <- c("S.0","I.0","R1.0","R2.0","R3.0") +> dacca.rw.sd <- c( ++ rep(0.1,length(dacca.pars)), ++ rep(0.2,length(dacca.ivps)) ++ ) +> names(dacca.rw.sd) <- c(dacca.pars,dacca.ivps) +> +> param.tab <- read.csv2(text=' ++ "";"gamma";"eps";"rho";"delta";"deltaI";"clin";"alpha";"beta.trend";"log.beta1";"log.beta2";"log.beta3";"log.beta4";"log.beta5";"log.beta6";"log.omega1";"log.omega2";"log.omega3";"log.omega4";"log.omega5";"log.omega6";"sd.beta";"tau";"S.0";"I.0";"Rs.0";"R1.0";"R2.0";"R3.0";"nbasis";"nrstage" ++ "mle1";20,8;19,1;0;0,02;0,06;1;1;-0,00498;0,747;6,38;-3,44;4,23;3,33;4,55;-1,6928195214;-2,5433835795;-2,8404393891;-4,6918179927;-8,4779724783;-4,3900588064;3,13;0,23;0,621;0,378;0;0,000843;0,000972;1,16e-07;6;3 ++ "box_min";10;0,2;0;0,02;0,03;1;1;-0,01;-4;0;-4;0;0;0;-10;-10;-10;-10;-10;-10;1;0,1;0;0;0;0;0;0;6;3 ++ "box_max";40;30;0;0,02;0,6;1;1;0;4;8;4;8;8;8;0;0;0;0;0;0;5;0,5;1;1;0;1;1;1;6;3 ++ ', ++ row.names=1 ++ ) +> +> dacca.hyperparams <- list( ++ min=unlist(param.tab["box_min",]), ++ max=unlist(param.tab["box_max",]) ++ ) +> +> dacca.rprior <- function (hyperparams, ...) { ++ r <- runif(length(hyperparams$min),min=hyperparams$min,max=hyperparams$max) ++ names(r) <- names(hyperparams$min) ++ r ++ } +> +> op <- options(warn=-1) +> +> set.seed(7777+7) +> params.tricky <- dacca.rprior(dacca.hyperparams) +> m7 <- mif( ++ dacca, ++ Nmif=2, ++ start=params.tricky, ++ pars=dacca.pars, ++ ivps=dacca.ivps, ++ Np=100, ++ method="mif2", ++ rw.sd=dacca.rw.sd, ++ cooling.type="geometric", ++ cooling.fraction=sqrt(0.1), ++ var.factor=2, ++ transform=TRUE ++ ) +> m7 <- continue(m7) +> +> set.seed(12350) +> th.draw <- dacca.rprior(dacca.hyperparams) +> m1 <- mif( ++ dacca, ++ Nmif=10, ++ Np=100, ++ start=th.draw, ++ pars=dacca.pars, ++ ivps=dacca.ivps, ++ method="mif2", ++ rw.sd=dacca.rw.sd, ++ cooling.type="geometric", ++ cooling.fraction=sqrt(0.1), ++ var.factor=2, ++ transform=TRUE ++ ) +> +> options(op) +> > proc.time() user system elapsed - 11.068 0.104 11.227 + 11.056 0.036 11.143 Modified: pkg/pomp/tests/dimchecks.Rout.save =================================================================== --- pkg/pomp/tests/dimchecks.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/dimchecks.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > set.seed(1420306530L) @@ -163,4 +164,4 @@ > > proc.time() user system elapsed - 0.520 0.036 0.574 + 0.504 0.064 0.591 Modified: pkg/pomp/tests/fhn.Rout.save =================================================================== --- pkg/pomp/tests/fhn.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/fhn.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > pdf.options(useDingbats=FALSE) @@ -92,4 +93,4 @@ > > proc.time() user system elapsed - 1.028 0.052 1.292 + 1.024 0.064 1.220 Modified: pkg/pomp/tests/filtfail.Rout.save =================================================================== --- pkg/pomp/tests/filtfail.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/filtfail.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > set.seed(834454394L) @@ -117,4 +118,4 @@ > > proc.time() user system elapsed - 0.520 0.052 0.582 + 0.552 0.036 0.605 Modified: pkg/pomp/tests/gillespie.Rout.save =================================================================== --- pkg/pomp/tests/gillespie.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/gillespie.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > params <- c( @@ -132,4 +133,4 @@ > > proc.time() user system elapsed - 2.436 0.048 2.503 + 2.664 0.068 2.758 Modified: pkg/pomp/tests/gompertz.Rout.save =================================================================== --- pkg/pomp/tests/gompertz.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/gompertz.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > options(digits=4) > @@ -134,4 +135,4 @@ > > proc.time() user system elapsed - 1.504 0.068 1.585 + 1.552 0.048 1.622 Modified: pkg/pomp/tests/logistic.Rout.save =================================================================== --- pkg/pomp/tests/logistic.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/logistic.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > po <- pomp( @@ -123,4 +124,4 @@ > > proc.time() user system elapsed - 0.896 0.048 1.087 + 0.916 0.044 1.078 Modified: pkg/pomp/tests/ou2-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/ou2-bsmc.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > set.seed(398585L) @@ -63,7 +64,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 2.921494 secs +Time difference of 2.999716 secs > > print( + cbind( @@ -105,4 +106,4 @@ > > proc.time() user system elapsed - 4.788 0.072 4.889 + 4.896 0.068 4.995 Modified: pkg/pomp/tests/ou2-forecast.Rout.save =================================================================== --- pkg/pomp/tests/ou2-forecast.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/ou2-forecast.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > set.seed(921625222L) @@ -62,4 +63,4 @@ > > proc.time() user system elapsed - 1.576 0.060 1.751 + 1.580 0.068 1.753 Modified: pkg/pomp/tests/ou2-kalman.Rout.save =================================================================== --- pkg/pomp/tests/ou2-kalman.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/ou2-kalman.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -18,6 +18,7 @@ > library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve > > set.seed(577639485L) @@ -165,7 +166,7 @@ 117 function evaluations used > toc <- Sys.time() > print(toc-tic) -Time difference of 3.442711 secs +Time difference of 3.437749 secs > tic <- Sys.time() > print(loglik.mle <- -kalm.fit1$value,digits=4) [1] -477.2 @@ -189,4 +190,4 @@ > > proc.time() user system elapsed - 3.960 0.056 4.038 + 4.004 0.056 4.089 Modified: pkg/pomp/tests/ou2-mif-fp.R =================================================================== --- pkg/pomp/tests/ou2-mif-fp.R 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/ou2-mif-fp.R 2014-03-31 11:58:40 UTC (rev 914) @@ -1,50 +1,46 @@ -if (Sys.getenv("POMP_FULL_TESTS")=="yes") { +library(pomp) - library(pomp) +pompExample(ou2) - pompExample(ou2) +set.seed(64857673L) - set.seed(64857673L) +pdf(file="ou2-mif-fp.pdf") - pdf(file="ou2-mif-fp.pdf") +p.truth <- coef(ou2) +guess2 <- guess1 <- p.truth +guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.25*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] +guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 4*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] - p.truth <- coef(ou2) - guess2 <- guess1 <- p.truth - guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.25*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] - guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 4*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] +mif1 <- mif(ou2,Nmif=100,start=guess1, + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=5,x2.0=5, + alpha.2=0.1,alpha.3=0.1 + ), + Np=1000, + var.factor=1, + ic.lag=10, + cooling.type="geometric", + cooling.fraction=0.95^50, + max.fail=100, + method="fp" + ) - mif1 <- mif(ou2,Nmif=100,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), - rw.sd=c( - x1.0=5,x2.0=5, - alpha.2=0.1,alpha.3=0.1 - ), - Np=1000, - var.factor=1, - ic.lag=10, - cooling.type="geometric", - cooling.fraction=0.95^50, - max.fail=100, - method="fp" - ) - - mif2 <- mif(ou2,Nmif=100,start=guess2, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), - rw.sd=c( - x1.0=5,x2.0=5, - alpha.2=0.1,alpha.3=0.1 - ), - Np=1000, - var.factor=1, - ic.lag=10, - cooling.type="geometric", - cooling.fraction=0.95^50, - max.fail=100, - method="fp" - ) - - compare.mif(list(mif1,mif2)) +mif2 <- mif(ou2,Nmif=100,start=guess2, + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=5,x2.0=5, + alpha.2=0.1,alpha.3=0.1 + ), + Np=1000, + var.factor=1, + ic.lag=10, + cooling.type="geometric", + cooling.fraction=0.95^50, + max.fail=100, + method="fp" + ) - dev.off() +compare.mif(list(mif1,mif2)) -} +dev.off() Modified: pkg/pomp/tests/ou2-mif-fp.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif-fp.Rout.save 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/ou2-mif-fp.Rout.save 2014-03-31 11:58:40 UTC (rev 914) @@ -15,64 +15,61 @@ 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. -> if (Sys.getenv("POMP_FULL_TESTS")=="yes") { -+ -+ library(pomp) -+ -+ pompExample(ou2) -+ -+ set.seed(64857673L) -+ -+ pdf(file="ou2-mif-fp.pdf") -+ -+ p.truth <- coef(ou2) -+ guess2 <- guess1 <- p.truth -+ guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.25*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] -+ guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 4*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] -+ -+ mif1 <- mif(ou2,Nmif=100,start=guess1, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), -+ rw.sd=c( -+ x1.0=5,x2.0=5, -+ alpha.2=0.1,alpha.3=0.1 -+ ), -+ Np=1000, -+ var.factor=1, -+ ic.lag=10, -+ cooling.type="geometric", -+ cooling.fraction=0.95^50, -+ max.fail=100, -+ method="fp" -+ ) -+ -+ mif2 <- mif(ou2,Nmif=100,start=guess2, -+ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), -+ rw.sd=c( -+ x1.0=5,x2.0=5, -+ alpha.2=0.1,alpha.3=0.1 -+ ), -+ Np=1000, -+ var.factor=1, -+ ic.lag=10, -+ cooling.type="geometric", -+ cooling.fraction=0.95^50, -+ max.fail=100, -+ method="fp" -+ ) -+ -+ compare.mif(list(mif1,mif2)) -+ -+ dev.off() -+ -+ } +> library(pomp) Loading required package: mvtnorm Loading required package: subplex +Loading required package: nloptr Loading required package: deSolve +> +> pompExample(ou2) newly created pomp object(s): ou2 +> +> set.seed(64857673L) +> +> pdf(file="ou2-mif-fp.pdf") +> +> p.truth <- coef(ou2) +> guess2 <- guess1 <- p.truth +> guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.25*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] +> guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 4*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] +> +> mif1 <- mif(ou2,Nmif=100,start=guess1, ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ rw.sd=c( ++ x1.0=5,x2.0=5, ++ alpha.2=0.1,alpha.3=0.1 ++ ), ++ Np=1000, ++ var.factor=1, ++ ic.lag=10, ++ cooling.type="geometric", ++ cooling.fraction=0.95^50, ++ max.fail=100, ++ method="fp" ++ ) +> +> mif2 <- mif(ou2,Nmif=100,start=guess2, ++ pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), ++ rw.sd=c( ++ x1.0=5,x2.0=5, ++ alpha.2=0.1,alpha.3=0.1 ++ ), ++ Np=1000, ++ var.factor=1, ++ ic.lag=10, ++ cooling.type="geometric", ++ cooling.fraction=0.95^50, ++ max.fail=100, ++ method="fp" ++ ) +> +> compare.mif(list(mif1,mif2)) +> +> dev.off() null device 1 > > proc.time() user system elapsed - 19.229 0.092 19.539 + 19.269 0.064 19.562 Modified: pkg/pomp/tests/ou2-mif.R =================================================================== --- pkg/pomp/tests/ou2-mif.R 2014-03-27 12:31:51 UTC (rev 913) +++ pkg/pomp/tests/ou2-mif.R 2014-03-31 11:58:40 UTC (rev 914) @@ -1,212 +1,209 @@ -if (Sys.getenv("POMP_FULL_TESTS")=="yes") { +library(pomp) - library(pomp) +pompExample(ou2) - pompExample(ou2) +set.seed(64857673L) - set.seed(64857673L) +obs(window(ou2,end=20,start=15)) +obs(window(ou2,end=5),"y1") - obs(window(ou2,end=20,start=15)) - obs(window(ou2,end=5),"y1") +fit1.pfilter <- pfilter(ou2,Np=1000) +cat("coefficients at `truth'\n") +print(coef(ou2,c('x1.0','x2.0','alpha.2','alpha.3')),digits=4) +cat("particle filter log likelihood at truth\n") +print(fit1.pfilter$loglik,digits=4) - fit1.pfilter <- pfilter(ou2,Np=1000) - cat("coefficients at `truth'\n") - print(coef(ou2,c('x1.0','x2.0','alpha.2','alpha.3')),digits=4) - cat("particle filter log likelihood at truth\n") - print(fit1.pfilter$loglik,digits=4) +p.truth <- coef(ou2) +guess2 <- guess1 <- p.truth +guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] +guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] - p.truth <- coef(ou2) - guess2 <- guess1 <- p.truth - guess1[c('x1.0','x2.0','alpha.2','alpha.3')] <- 0.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] - guess2[c('x1.0','x2.0','alpha.2','alpha.3')] <- 1.5*guess1[c('x1.0','x2.0','alpha.2','alpha.3')] +mif1 <- mif(ou2,Nmif=30,start=guess1, + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + rw.sd=c( + x1.0=5,x2.0=5, + alpha.2=0.1,alpha.3=0.1 + ), + Np=1000, + var.factor=1, + ic.lag=10, + cooling.type="geometric", + cooling.factor=0.95, + max.fail=100 + ) - mif1 <- mif(ou2,Nmif=30,start=guess1, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), - rw.sd=c( - x1.0=5,x2.0=5, - alpha.2=0.1,alpha.3=0.1 - ), - Np=1000, - var.factor=1, - ic.lag=10, - cooling.type="geometric", - cooling.factor=0.95, - max.fail=100 - ) +mif2 <- mif(ou2,Nmif=30,start=guess2, + pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), + transform=TRUE, + rw.sd=c( + x1.0=5,x2.0=5, + alpha.2=0.1,alpha.3=0.1 + ), + Np=1000, + var.factor=1, + ic.lag=10, + cooling.type="geometric", + cooling.fraction=0.95^50, + max.fail=100 + ) - mif2 <- mif(ou2,Nmif=30,start=guess2, - pars=c('alpha.2','alpha.3'),ivps=c('x1.0','x2.0'), - transform=TRUE, - rw.sd=c( - x1.0=5,x2.0=5, - alpha.2=0.1,alpha.3=0.1 - ), - Np=1000, - var.factor=1, - ic.lag=10, - cooling.type="geometric", - cooling.fraction=0.95^50, - max.fail=100 - ) +pdf(file="ou2-mif.pdf") +plot(mif1) +compare.mif(mif2) +try(compare.mif(mif1,mif2)) +compare.mif(list(mif1,mif2)) +dev.off() - pdf(file="ou2-mif.pdf") - plot(mif1) - compare.mif(mif2) - try(compare.mif(mif1,mif2)) - compare.mif(list(mif1,mif2)) - dev.off() +set.seed(33848585L) - set.seed(33848585L) +try( + mif( + ou2, + Nmif=1, + pars=c("alpha.1","alpha.4","x1.0"), + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), + Np=100,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) - try( - mif( - ou2, - Nmif=1, - pars=c("alpha.1","alpha.4","x1.0"), - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), - Np=100,cooling.type="geometric",cooling.fraction=0.95^50, - ic.lag=10,var.factor=1 - ) - ) +try( + mif( + ou2, + Nmif=1, + pars=c("alpha.1","alpha.4"), + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), + Np=100, + cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) - try( - mif( - ou2, - Nmif=1, - pars=c("alpha.1","alpha.4"), - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), - Np=100, - cooling.type="geometric",cooling.fraction=0.95^50, - ic.lag=10,var.factor=1 - ) - ) +try( + mif( + ou2, + Nmif=1, + ivps=c("x1.0","x2.0"), + rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), + Np=100,cooling.type="geometric",cooling.fraction=0.95^50, + cooling.factor=0.95,ic.lag=10,var.factor=1 + ) + ) - try( - mif( - ou2, - Nmif=1, - ivps=c("x1.0","x2.0"), - rw.sd=c(alpha.1=0.1,alpha.4=0.2,alpha.3=0), - Np=100,cooling.type="geometric",cooling.fraction=0.95^50, - cooling.factor=0.95,ic.lag=10,var.factor=1 - ) - ) +try( + mif( + ou2, + Nmif=1, + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), + Np=100,ic.lag=10,var.factor=1 + ) + ) - try( - mif( - ou2, - Nmif=1, - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0.1,alpha.4=0.2,alpha.3=0), - Np=100,ic.lag=10,var.factor=1 - ) - ) +try( + mif( + ou2, + Nmif=1, + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), + Np=-10,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) - try( - mif( - ou2, - Nmif=1, - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), - Np=-10,cooling.type="geometric",cooling.fraction=0.95^50, - ic.lag=10,var.factor=1 - ) - ) +try( + mif( + ou2, + Nmif=-3, + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), + Np=11.6,cooling.type="geometric",cooling.fraction=0.95^50, + ic.lag=10,var.factor=1 + ) + ) - try( - mif( - ou2, - Nmif=-3, - ivps=c("x1.0","x2.0"), - rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), - Np=11.6,cooling.type="geometric",cooling.fraction=0.95^50, - ic.lag=10,var.factor=1 - ) - ) +try( + mif( + ou2, + Nmif=2, + start=c(alpha.1=0.9,alpha.2=0,alpha.3=0,alpha.4=-Inf,sigma.1=1,sigma.2=0,sigma.3=2,tau=1,x1.0=50,x2.0=-50), + ivps=c("x1.0","x2.0"), + rw.sd=c(x1.0=5,x2.0=5,alpha.1=0,alpha.4=0.2,alpha.3=0), [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 914