From noreply at r-forge.r-project.org Thu Jan 1 22:20:25 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 1 Jan 2015 22:20:25 +0100 (CET) Subject: [Pomp-commits] r1038 - in pkg/pompExamples: . inst/examples src tests Message-ID: <20150101212025.7870F186952@r-forge.r-project.org> Author: kingaa Date: 2015-01-01 22:20:25 +0100 (Thu, 01 Jan 2015) New Revision: 1038 Added: pkg/pompExamples/inst/examples/ebola.R pkg/pompExamples/src/cholmodel.c pkg/pompExamples/src/ebola.c Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/tests/examples.R pkg/pompExamples/tests/pertussis.R pkg/pompExamples/tests/pertussis.Rout.save Log: - Ebola example - put Matteo Fasiolo's variant cholera model source code into the package Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2014-12-31 12:36:42 UTC (rev 1037) +++ pkg/pompExamples/DESCRIPTION 2015-01-01 21:20:25 UTC (rev 1038) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.24-1 -Date: 2014-12-31 +Version: 0.25-1 +Date: 2015-01-01 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), Added: pkg/pompExamples/inst/examples/ebola.R =================================================================== --- pkg/pompExamples/inst/examples/ebola.R (rev 0) +++ pkg/pompExamples/inst/examples/ebola.R 2015-01-01 21:20:25 UTC (rev 1038) @@ -0,0 +1,122 @@ +require(pomp) +require(plyr) +require(reshape2) + +WHO.situation.report.Oct.1 <- ' +Week,Guinea,Liberia,SierraLeone +1,2.244,, +2,2.244,, +3,0.073,, +4,5.717,, +5,3.954,, +6,5.444,, +7,3.274,, +8,5.762,, +9,7.615,, +10,7.615,, +11,27.392,, +12,17.387,, +13,27.115,, +14,29.29,, +15,27.84,, +16,16.345,, +17,10.917,, +18,11.959,, +19,11.959,, +20,8.657,, +21,26.537,, +22,47.764,3.517, +23,26.582,1.043,5.494 +24,32.967,18,57.048 +25,18.707,16.34,76.022 +26,24.322,13.742,36.768 +27,4.719,10.155,81.929 +28,7.081,24.856,102.632 +29,8.527,53.294,69.823 +30,92.227,70.146,81.783 +31,26.423,139.269,99.775 +32,16.549,65.66,88.17 +33,36.819,240.645,90.489 +34,92.08,274.826,161.54 +35,101.03,215.56,168.966 +36,102.113,388.553,186.144 +37,83.016,410.299,220.442 +38,106.674,300.989,258.693 +39,55.522,240.237,299.546 +' + +## Population sizes in Guinea, Liberia, and Sierra Leone (census 2014) +populations <- c(Guinea=10628972,Liberia=4092310,SierraLeone=6190280) +populations["WestAfrica"] <- sum(populations) + +dat <- read.csv(text=WHO.situation.report.Oct.1,stringsAsFactors=FALSE) +rename(dat,c(Week="week")) -> dat +dat <- melt(dat,id="week",variable.name="country",value.name="cases") +mutate(dat,deaths=NA) -> dat + +ebolaModel <- function (country=c("Guinea", "SierraLeone", "Liberia", "WestAfrica"), + timestep = 0.01, nstageE = 3L, + type = c("raw","cum"), na.rm = FALSE, least.sq = FALSE) { + + type <- match.arg(type) + ctry <- match.arg(country) + pop <- unname(populations[ctry]) + + ## Incubation period is supposed to be Gamma distributed with shape parameter 3 and mean 11.4 days + ## The discrete-time formula is used to calculate the corresponding alpha (cf He et al., Interface 2010) + ## Case-fatality ratio is fixed at 0.7 (cf WHO Ebola response team, NEJM 2014) + incubation_period <- 11.4/7 + infectious_period <- 7/7 + index_case <- 10/pop + dt <- timestep + + theta <- c(N=pop,R0=1.4, + alpha=-1/(nstageE*dt)*log(1-nstageE*dt/incubation_period), + gamma=-log(1-dt/infectious_period)/dt, + rho=0.2,cfr=0.7, + k=0, + S_0=1-index_case,E_0=index_case/2-5e-9, + I_0=index_case/2-5e-9,R_0=1e-8) + + dat <- subset(dat,country==ctry,select=-country) + if (na.rm) { + dat <- mutate(subset(dat,!is.na(cases)),week=week-min(week)+1) + } + if (type=="cum") { + dat <- mutate(dat,cases=cumsum(cases),deaths=cumsum(deaths)) + } + + print(dat) + + ## Create the pomp object + pomp( + data=dat, + times="week", + t0=0, + params=theta, + obsnames=c("cases","deaths"), + statenames=c("S","E1","I","R","N_EI","N_IR"), + zeronames=if (type=="raw") c("N_EI","N_IR") else character(0), + paramnames=c("N","R0","alpha","gamma","rho","k","cfr", + "S_0","E_0","I_0","R_0"), + nstageE=nstageE, + PACKAGE="pompExamples", + dmeasure=if (least.sq) "_ebola_dObsLS" else "_ebola_dObs", + rmeasure=if (least.sq) "_ebola_rObsLS" else "_ebola_rObs", + rprocess=discrete.time.sim(step.fun="_ebola_rSim",delta.t=timestep), + skeleton="_ebola_skel", + skeleton.type="vectorfield", + parameter.transform="_ebola_par_trans", + parameter.inv.transform="_ebola_par_untrans", + initializer=function (params, t0, nstageE, ...) { + all.state.names <- c("S",paste0("E",1:nstageE),"I","R","N_EI","N_IR") + comp.names <- c("S",paste0("E",1:nstageE),"I","R") + x0 <- setNames(numeric(length(all.state.names)),all.state.names) + frac <- c(params["S_0"],rep(params["E_0"]/nstageE,nstageE),params["I_0"],params["R_0"]) + x0[comp.names] <- round(params["N"]*frac/sum(frac)) + x0 + } + ) -> po +} + +c("ebolaModel") Added: pkg/pompExamples/src/cholmodel.c =================================================================== --- pkg/pompExamples/src/cholmodel.c (rev 0) +++ pkg/pompExamples/src/cholmodel.c 2015-01-01 21:20:25 UTC (rev 1038) @@ -0,0 +1,238 @@ +// -*- C++ -*- + +#include +#include +#include "pomp.h" + +#define TAU (p[parindex[0]]) +#define GAMMA (p[parindex[1]]) +#define EPS (p[parindex[2]]) +#define DELTA (p[parindex[3]]) +#define DELTA_I (p[parindex[4]]) +#define LOGOMEGA (p[parindex[5]]) +#define SD_BETA (p[parindex[6]]) +#define BETATREND (p[parindex[7]]) +#define LOGBETA (p[parindex[8]]) +#define ALPHA (p[parindex[9]]) +#define RHO (p[parindex[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]]) +#define RSHORT (x[stateindex[2]]) +#define RLONG (x[stateindex[3]]) +#define DEATHS (x[stateindex[4]]) +#define NOISE (x[stateindex[5]]) +#define COUNT (x[stateindex[6]]) + +#define POP (covar[covindex[0]]) +#define DPOPDT (covar[covindex[1]]) +#define SEASBASIS (covar[covindex[2]]) +#define TREND (covar[covindex[3]]) + +#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); + + to_log_barycentric(&pt[parindex[14]],&S0,3+nrstage); +} + +void _cholmodel_trans (double *pt, double *p, int *parindex) +{ + int k, nrstage = (int) NRSTAGE; + 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); + + 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 ncovars, double *covars, double t) +{ + double tol = 1.0e-18; + if ((COUNT > 0) || (!(R_FINITE(DEATHS)))) { + DATADEATHS = R_NaReal; + } else { + DATADEATHS = rnbinom_mu(1 / (TAU*TAU), DEATHS + tol); + } +} + +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 tol = 1.0e-18; + if ((COUNT>0.0) || (!(R_FINITE(DEATHS)))) { + *lik = tol; + } else { + *lik = dnbinom_mu(DATADEATHS+tol, 1 / (TAU*TAU), DEATHS + tol, 0) + tol; + } + if (give_log) *lik = log(*lik); +} + +#undef DATADEATHS + + +inline double out_flow(double init, double rate_by_dt) +{ + + return init * (1.0 - exp( - rate_by_dt )); + +} + +// two-path SIRS cholera model using SDEs +// exponent (alpha) on I/n +// only "severe" infections are infectious +// truncation is not used +// instead, particles with negative states are killed +void _cholmodel_two (double *x, const double *p, + const int *stateindex, const int *parindex, + const int *covindex, + int covdim, const double *covar, + double t, double dt) +{ // implementation of the SIRS cholera model + int nrstage = (int) NRSTAGE; + int nbasis = (int) NBASIS; + + double *pt_r, *pt_w; + int j; + + double k_eps = NRSTAGE * EPS; + + double gamma_delta_deltaI = GAMMA + DELTA + DELTA_I; + + double keps_div_keps_delta = k_eps / (k_eps + DELTA); + + /* + * Preliminaries + */ + + double beta = exp(dot_product(nbasis,&SEASBASIS,&LOGBETA)+BETATREND*TREND); + + double omega = exp(dot_product(nbasis,&SEASBASIS,&LOGOMEGA)); + + double dw = rgammawn(SD_BETA, dt); // gamma noise, mean=dt, variance=(beta_sd^2 dt) + + double lambda = omega + (beta * dw/dt) * INFECT/POP; // Time-dependent force of infection + + /* + * Out-flows from compartments using aboundances at previous time step + */ + + double S_o = out_flow(SUSCEP, (lambda + DELTA) * dt); + double I_o = out_flow(INFECT, gamma_delta_deltaI * dt); + double RSH_o = out_flow(RSHORT, (RHO + DELTA) * dt); + + double R_o[nrstage]; + for (pt_r = &RLONG, pt_w = R_o, j = 0; + j < nrstage; + j++, pt_r++, pt_w++) { + + *pt_w = out_flow(*pt_r, (k_eps + DELTA) * dt); + + } + + double new_infect = S_o * (lambda / (lambda + DELTA)); + + /* + * Cholera deaths = (I_o * DELTA_I) / gamma_delta_deltaI are not reborn in SUSCEPT. + * To offset this downward bias on total population, we add the average number of (observed) deaths: + * + * average_chol_death = tot_cholc_deaths / (n_months * n_step) <-----> 29.522 = 354275.0 / (600 * 200) + */ + double chol_deaths_dt = 29.523; + double births = DPOPDT * dt + chol_deaths_dt + S_o * (DELTA / (lambda + DELTA)) + I_o * DELTA / gamma_delta_deltaI + RSH_o * (DELTA / (DELTA + RHO)); + for (pt_r = R_o, j = 0; + j < nrstage; + j++, pt_r++) { + + births += *pt_r * (DELTA / (k_eps + DELTA)); + + } + + /* + * Updating all compartments + */ + + SUSCEP += - S_o + births + R_o[nrstage-1] * keps_div_keps_delta + RSH_o * (RHO / (RHO + DELTA)); + + INFECT += - I_o + CLIN * new_infect; + + RSHORT += - RSH_o + (1 - CLIN) * new_infect; + + for (pt_w = &RLONG, pt_r = R_o, j = 0; + j < nrstage; + j++, pt_r++, pt_w++) { + + if(j == 0) + { + + *pt_w += - *pt_r + I_o * (GAMMA / gamma_delta_deltaI); + + } else { + + *pt_w += - *pt_r + *(pt_r-1) * keps_div_keps_delta; + + } + + } + + DEATHS += I_o * (DELTA_I / gamma_delta_deltaI); // cumulative deaths due to disease + + NOISE += (dw-dt) / SD_BETA; + +} + +#undef GAMMA +#undef EPS +#undef DELTA +#undef DELTA_I +#undef LOGOMEGA +#undef SD_BETA +#undef BETATREND +#undef LOGBETA +#undef ALPHA +#undef RHO +#undef CLIN +#undef NBASIS +#undef NRSTAGE + +#undef SUSCEP +#undef INFECT +#undef RSHORT +#undef RLONG +#undef DEATHS +#undef NOISE +#undef COUNT + +#undef POP +#undef DPOPDT +#undef SEASBASIS Added: pkg/pompExamples/src/ebola.c =================================================================== --- pkg/pompExamples/src/ebola.c (rev 0) +++ pkg/pompExamples/src/ebola.c 2015-01-01 21:20:25 UTC (rev 1038) @@ -0,0 +1,187 @@ +// SEIR Ebola model + +#include +#include +#include +#include + +// State variables +#define S (x[stateindex[0]]) // Susceptible +#define E(J) (x[stateindex[1] + (J)]) // Exposed +#define I (x[stateindex[2]]) // Infected +#define R (x[stateindex[3]]) // Removed +#define N_EI (x[stateindex[4]]) // Number of transitions from E to I +#define N_IR (x[stateindex[5]]) // Number of transitions from I to R + +// Variations +#define DS (f[stateindex[0]]) // Susceptible +#define DE(J) (f[stateindex[1] + (J)]) // Exposed +#define DI (f[stateindex[2]]) // Infected +#define DR (f[stateindex[3]]) // Removed +#define DN_EI (f[stateindex[4]]) // Number of transitions from E to I +#define DN_IR (f[stateindex[5]]) // Number of transitions from I to R + +// Parameters on the natural scale (all rates are per day) +#define N (p[parindex[0]]) // Population size +#define R0 (p[parindex[1]]) // Basic reproduction number +#define alpha (p[parindex[2]]) // Inverse of latency period +#define gamma (p[parindex[3]]) // Inverse of duration of infection +#define rho (p[parindex[4]]) // Reporting probability +#define k (p[parindex[5]]) // Reporting overdispersion +#define cfr (p[parindex[6]]) // Case-fatality ratio +#define IC(J) (p[parindex[7] + (J)]) // Initial conditions + +// Parameters on the transformed scale (all rates are per day) +#define TN (pt[parindex[0]]) // Population size +#define TR0 (pt[parindex[1]]) // Basic reproduction number +#define Talpha (pt[parindex[2]]) // Inverse of latency period +#define Tgamma (pt[parindex[3]]) // Inverse of duration of infection +#define Trho (pt[parindex[4]]) // Reporting probability +#define Tk (pt[parindex[5]]) // Reporting overdispersion +#define Tcfr (pt[parindex[6]]) // Case-fatality ratio +#define TIC(J) (pt[parindex[7] + (J)]) // Initial conditions + +// Observations +#define cases (y[obsindex[0]]) // Number of reported cases +#define deaths (y[obsindex[1]]) // Number of reported deaths + +// Transforms the parameters to the transformed scale +void _ebola_par_untrans (double *pt, double *p, int *parindex){ + TN = log(N); + TR0 = log(R0); + Talpha = log(alpha); + Tgamma = log(gamma); + Trho = logit(rho); + Tk = log(k); + Tcfr = logit(cfr); + to_log_barycentric(&(TIC(0)),&(IC(0)),4); +} + +// Transforms the parameters to the natural scale +void _ebola_par_trans (double *pt, double *p, int *parindex){ + TN = exp(N); + TR0 = exp(R0); + Talpha = exp(alpha); + Tgamma = exp(gamma); + Trho = expit(rho); + Tk = exp(k); + Tcfr = expit(cfr); + from_log_barycentric(&(TIC(0)),&(IC(0)),4); +} + +// Observation model: hierarchical model for cases and deaths +// p(R_t, D_t| C_t) = p(R_t | C_t) * p(D_t | C_t, R_t) +// p(R_t | C_t): Negative binomial with mean rho * C_t and dispersion parameter 1 / k +// p(D_t | C_t, R_t): Binomial B(R_t, cfr) +void _ebola_dObs (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 f; + if (k > 0.0) + f = dnbinom_mu(nearbyint(cases),1.0/k,rho*N_EI,1); + // f += dnbinom_mu(nearbyint(deaths), 1.0 / k, rho * cfr * N_IR, 1); + else + f = dpois(nearbyint(cases),rho*N_EI,1); + *lik = (give_log) ? f : exp(f); +} + +// For least-squares trajectory-matching: +void _ebola_dObsLS (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 f; + f = dnorm(cases,rho*N_EI,k,1); + *lik = (give_log) ? f : exp(f); +} + +void _ebola_rObs (double *y, double *x, double *p, + int *obsindex, int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) +{ + if (k > 0) { + cases = rnbinom_mu(1.0/k,rho*N_EI); + deaths = rnbinom_mu(1.0/k,rho*cfr*N_IR); + } else { + cases = rpois(rho*N_EI); + deaths = rpois(rho*cfr*N_IR); + } +} + +// For least-squares trajectory-matching: +void _ebola_rObsLS (double *y, double *x, double *p, + int *obsindex, int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) +{ + cases = rnorm(rho*N_EI,k); + deaths = NA_REAL; +} + + +// Process model +void _ebola_rSim (double *x, const double *p, + const int *stateindex, const int *parindex, const int *covindex, + int covdim, const double *covars, + double t, double dt) { + + // Retrieve user data in the pomp object + int *(*get_pomp_userdata_int)(const char *); + get_pomp_userdata_int = (int *(*)(const char *)) R_GetCCallable("pomp","get_pomp_userdata_int"); + int nstageE = *(get_pomp_userdata_int("nstageE")); // Number of stages in the E class + + // Other parameters + double lambda, beta; + beta = R0 * gamma; // Transmission rate + lambda = beta * I / N; // Force of infection + int i; + + // Transitions + + // From class S + double transS = rbinom(S, 1.0 - exp(- lambda * dt)); // No of infections + + // From class E + double transE[nstageE]; // No of transitions between classes E + for(i = 0; i < nstageE; i++){ + transE[i] = rbinom(E(i), 1.0 - exp(- nstageE * alpha * dt)); + } + + // From class I + double transI = rbinom(I, 1.0 - exp(- gamma * dt)); // No of transitions I->R + + // Balance the equations + S -= transS; + E(0) += transS - transE[0]; + for(i=1; i < nstageE; i++) { + E(i) += transE[i-1] - transE[i]; + } + I += transE[nstageE - 1] - transI; + R += transI; + N_EI += transE[nstageE - 1]; // No of transitions from E to I + N_IR += transI; // No of transitions from I to R +} + +// Continuous-time deterministic skeleton +void _ebola_skel (double *f, double *x, double *p, + int *stateindex, int *parindex, int *covindex, + int ncovars, double *covars, double t) { + + // Retrieve user data in the pomp object + int *(*get_pomp_userdata_int)(const char *); + get_pomp_userdata_int = (int *(*)(const char *)) R_GetCCallable("pomp","get_pomp_userdata_int"); + int nstageE = *(get_pomp_userdata_int("nstageE")); // Number of stages in the E class + + // Other parameters + double lambda, beta; + beta = R0 * gamma; // Transmission rate + lambda = beta * I / N; // Force of infection + int i; + + // Balance the equations + DS = - lambda * S; + DE(0) = lambda * S - nstageE * alpha * E(0); + for(i=1; i < nstageE; i++) DE(i) = nstageE * alpha * (E(i - 1) - E(i)); + DI = nstageE * alpha * E(nstageE - 1) - gamma * I; + DR = gamma * I; + DN_EI = nstageE * alpha * E(nstageE - 1); + DN_IR = gamma * I; +} Modified: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R 2014-12-31 12:36:42 UTC (rev 1037) +++ pkg/pompExamples/tests/examples.R 2015-01-01 21:20:25 UTC (rev 1038) @@ -22,3 +22,12 @@ pompExample(bbp) pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) tj <- trajectory(bbp) + +pompExample(ebola) +ebolaModel(country="Guinea") -> po +pf <- pfilter(simulate(po),Np=100) +tj <- trajectory(po) + +ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po +pf <- pfilter(simulate(po),Np=100) +tj <- trajectory(po) Modified: pkg/pompExamples/tests/pertussis.R =================================================================== --- pkg/pompExamples/tests/pertussis.R 2014-12-31 12:36:42 UTC (rev 1037) +++ pkg/pompExamples/tests/pertussis.R 2015-01-01 21:20:25 UTC (rev 1038) @@ -15,7 +15,7 @@ y <- trajectory(pertussis.sim(SEIRS.small),as.data.frame=TRUE) tail(y) -system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) +pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000) logLik(pf) pttest <- function (po, digits = 15) { Modified: pkg/pompExamples/tests/pertussis.Rout.save =================================================================== --- pkg/pompExamples/tests/pertussis.Rout.save 2014-12-31 12:36:42 UTC (rev 1037) +++ pkg/pompExamples/tests/pertussis.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) @@ -1,5 +1,5 @@ -R Under development (unstable) (2014-12-14 r67168) -- "Unsuffered Consequences" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -144,9 +144,7 @@ 1040 19.98077 1 1041 20.00000 1 > -> system.time(pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000)) - user system elapsed - 17.801 0.004 17.861 +> pf <- pfilter(pertussis.sim(full.small),seed=3445886L,Np=1000) > logLik(pf) [1] -3829.33 > @@ -170,4 +168,4 @@ > > proc.time() user system elapsed - 18.657 0.060 18.801 + 23.494 0.034 23.544 From noreply at r-forge.r-project.org Thu Jan 1 22:20:29 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 1 Jan 2015 22:20:29 +0100 (CET) Subject: [Pomp-commits] r1039 - in pkg/pomp: . R tests Message-ID: <20150101212029.79F01186952@r-forge.r-project.org> Author: kingaa Date: 2015-01-01 22:20:29 +0100 (Thu, 01 Jan 2015) New Revision: 1039 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/example.R pkg/pomp/tests/bbs-trajmatch.Rout.save pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/blowflies.Rout.save 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-abc.Rout.save pkg/pomp/tests/ou2-bsmc.Rout.save pkg/pomp/tests/ou2-bsmc2.Rout.save pkg/pomp/tests/ou2-forecast.Rout.save pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/ou2-mif-fp.Rout.save pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/ou2-mif2.Rout.save pkg/pomp/tests/ou2-nlf.Rout.save 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.Rout.save 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: - minor cosmetic tweak - update all .Rout.save files Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/DESCRIPTION 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.56-1 -Date: 2014-12-16 +Version: 0.56-2 +Date: 2015-01-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/R/example.R =================================================================== --- pkg/pomp/R/example.R 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/R/example.R 2015-01-01 21:20:29 UTC (rev 1039) @@ -28,7 +28,7 @@ get(objs$value[i],envir=evalEnv), envir=envir) } - cat("newly created pomp object(s):\n",objs$value,"\n") + cat("newly created object(s):\n",objs$value,"\n") obj <- NULL } else { stop(sQuote("envir")," must be an environment or NULL") Modified: pkg/pomp/tests/bbs-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(bbs) -newly created pomp object(s): +newly created object(s): bbs > > guess <- c( @@ -72,8 +68,8 @@ > options(warn=2) > ofun <- traj.match.objfun(window(bbs,end=3),est=c("beta","gamma"),transform=TRUE,maxsteps=10,rtol=1e-6) > try(optim(fn=ofun,par=c(0,-1),method="Nelder-Mead",control=list(reltol=1e-10))) -DLSODA- At current T (=R1), MXSTEP (=I1) steps - taken on this call before reaching TOUT +DLSODA- At current T (=R1), MXSTEP (=I1) steps + taken on this call before reaching TOUT In above message, I1 = 10 In above message, R1 = 0.609738 @@ -84,4 +80,4 @@ > > proc.time() user system elapsed - 2.795 0.053 2.839 + 2.725 0.017 2.733 Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/bbs.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -20,7 +20,7 @@ Loading required package: nloptr > > pompExample(bbs) -newly created pomp object(s): +newly created object(s): bbs > > set.seed(48857734L) @@ -69,4 +69,4 @@ > > proc.time() user system elapsed - 6.716 0.076 6.831 + 7.769 0.051 7.832 Modified: pkg/pomp/tests/blowflies.Rout.save =================================================================== --- pkg/pomp/tests/blowflies.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/blowflies.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(blowflies) -newly created pomp object(s): +newly created object(s): blowflies1 blowflies2 > > init.state(blowflies1) @@ -74,4 +70,4 @@ > > proc.time() user system elapsed - 1.430 0.051 1.473 + 1.493 0.039 1.519 Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/dacca.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,17 +16,13 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(1420306530L) > > pompExample(dacca) -newly created pomp object(s): +newly created object(s): dacca > > x <- as.data.frame(dacca) @@ -111,4 +107,4 @@ > > proc.time() user system elapsed - 13.216 0.040 13.260 + 14.817 0.035 14.853 Modified: pkg/pomp/tests/dimchecks.Rout.save =================================================================== --- pkg/pomp/tests/dimchecks.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/dimchecks.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,17 +16,13 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(1420306530L) > > pompExample(ricker) -newly created pomp object(s): +newly created object(s): ricker > po <- ricker > @@ -156,7 +152,7 @@ > stopifnot(identical(g1,g3[,4:6,])) > > pompExample(gompertz) -newly created pomp object(s): +newly created object(s): gompertz > p <- parmat(coef(gompertz),5) > f1 <- partrans(gompertz,p,"inv") @@ -166,4 +162,4 @@ > > proc.time() user system elapsed - 0.532 0.037 0.555 + 0.489 0.041 0.517 Modified: pkg/pomp/tests/fhn.Rout.save =================================================================== --- pkg/pomp/tests/fhn.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/fhn.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,12 +16,8 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pdf.options(useDingbats=FALSE) > pdf(file="fhn.pdf") @@ -95,4 +91,4 @@ > > proc.time() user system elapsed - 0.99 0.04 1.02 + 0.927 0.060 0.950 Modified: pkg/pomp/tests/filtfail.Rout.save =================================================================== --- pkg/pomp/tests/filtfail.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/filtfail.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,12 +16,8 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(834454394L) > @@ -120,4 +116,4 @@ > > proc.time() user system elapsed - 0.572 0.031 0.581 + 0.489 0.053 0.529 Modified: pkg/pomp/tests/gillespie.Rout.save =================================================================== --- pkg/pomp/tests/gillespie.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/gillespie.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,12 +16,8 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > params <- c( + nu=1/70, @@ -121,7 +117,7 @@ 105 0.1666667 > > pompExample(gillespie.sir) -newly created pomp object(s): +newly created object(s): gillespie.sir > > tail(as.data.frame(simulate(gillespie.sir,times=time(gsir),t0=timezero(gsir),seed=1165270654L))) @@ -135,4 +131,4 @@ > > proc.time() user system elapsed - 2.637 0.064 2.693 + 2.565 0.041 2.592 Modified: pkg/pomp/tests/gompertz.Rout.save =================================================================== --- pkg/pomp/tests/gompertz.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/gompertz.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,16 +16,12 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > options(digits=4) > > pompExample(gompertz) -newly created pomp object(s): +newly created object(s): gompertz > > po <- gompertz @@ -137,4 +133,4 @@ > > proc.time() user system elapsed - 1.762 0.063 1.806 + 1.797 0.038 1.822 Modified: pkg/pomp/tests/logistic.Rout.save =================================================================== --- pkg/pomp/tests/logistic.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/logistic.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,12 +16,8 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > po <- pomp( + data=rbind(obs=rep(0,1000)), @@ -126,4 +122,4 @@ > > proc.time() user system elapsed - 0.911 0.033 0.933 + 0.874 0.030 0.887 Modified: pkg/pomp/tests/ou2-abc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-abc.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-abc.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -18,14 +18,10 @@ > ### OU2 test of abc for pomp > > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > pdf(file='ou2-abc.pdf') @@ -135,4 +131,4 @@ > > proc.time() user system elapsed - 11.588 0.056 11.647 + 11.085 0.055 11.138 Modified: pkg/pomp/tests/ou2-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-bsmc.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,16 +16,12 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(398585L) > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > time(ou2) <- 1:10 @@ -63,7 +59,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 3.021244 secs +Time difference of 3.430529 secs > > print( + cbind( @@ -105,4 +101,4 @@ > > proc.time() user system elapsed - 4.967 0.053 5.012 + 5.498 0.064 5.527 Modified: pkg/pomp/tests/ou2-bsmc2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -21,7 +21,7 @@ > > set.seed(398585L) > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > time(ou2) <- 1:10 @@ -56,7 +56,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 2.042303 secs +Time difference of 2.234756 secs > > print( + cbind( @@ -98,4 +98,4 @@ > > proc.time() user system elapsed - 3.576 0.104 3.707 + 3.846 0.045 3.881 Modified: pkg/pomp/tests/ou2-forecast.Rout.save =================================================================== --- pkg/pomp/tests/ou2-forecast.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-forecast.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,17 +16,13 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(921625222L) > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > tm <- time(ou2) > y <- obs(ou2) @@ -65,4 +61,4 @@ > > proc.time() user system elapsed - 1.456 0.016 1.463 + 1.376 0.042 1.402 Modified: pkg/pomp/tests/ou2-kalman.Rout.save =================================================================== --- pkg/pomp/tests/ou2-kalman.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-kalman.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,12 +16,8 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(577639485L) > @@ -72,7 +68,7 @@ + } > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > # true coefficients @@ -168,7 +164,7 @@ 117 function evaluations used > toc <- Sys.time() > print(toc-tic) -Time difference of 3.49406 secs +Time difference of 3.235065 secs > tic <- Sys.time() > print(loglik.mle <- -kalm.fit1$value,digits=4) [1] -477.2 @@ -192,4 +188,4 @@ > > proc.time() user system elapsed - 4.096 0.029 4.104 + 3.769 0.026 3.787 Modified: pkg/pomp/tests/ou2-mif-fp.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > set.seed(64857673L) @@ -74,4 +70,4 @@ > > proc.time() user system elapsed - 23.726 0.048 23.790 + 24.537 0.066 24.614 Modified: pkg/pomp/tests/ou2-mif.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-mif.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > set.seed(64857673L) @@ -285,4 +281,4 @@ > > proc.time() user system elapsed - 14.330 0.061 14.397 + 13.791 0.053 13.848 Modified: pkg/pomp/tests/ou2-mif2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif2.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-mif2.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > pdf(file="ou2-mif2.pdf") @@ -139,4 +135,4 @@ > > proc.time() user system elapsed - 63.315 0.042 63.432 + 62.157 0.075 62.274 Modified: pkg/pomp/tests/ou2-nlf.Rout.save =================================================================== --- pkg/pomp/tests/ou2-nlf.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-nlf.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,17 +16,13 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(583615606L) > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > estnames=c("alpha.2","alpha.3","tau") > theta.truth <- coef(ou2) @@ -89,4 +85,4 @@ > > proc.time() user system elapsed - 5.413 0.023 5.433 + 5.003 0.037 5.037 Modified: pkg/pomp/tests/ou2-pmcmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > dprior.ou2 <- function (params, log, ...) { @@ -118,4 +114,4 @@ > > proc.time() user system elapsed - 27.262 0.036 27.325 + 26.822 0.042 26.880 Modified: pkg/pomp/tests/ou2-probe.Rout.save =================================================================== --- pkg/pomp/tests/ou2-probe.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-probe.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,18 +16,14 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > set.seed(1066L) > > pdf(file="ou2-probe.pdf") > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > pm.ou2 <- probe( @@ -297,7 +293,7 @@ sim.5 0.5542739 0.6216561 -0.4089672 -0.7236761 0.06850115 > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > good <- probe( @@ -344,4 +340,4 @@ > > proc.time() user system elapsed - 8.873 0.076 8.949 + 8.501 0.048 8.545 Modified: pkg/pomp/tests/ou2-procmeas.Rout.save =================================================================== --- pkg/pomp/tests/ou2-procmeas.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-procmeas.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > po <- window(ou2,end=10) @@ -58,4 +54,4 @@ > > proc.time() user system elapsed - 0.526 0.044 0.560 + 0.493 0.037 0.495 Modified: pkg/pomp/tests/ou2-simulate.Rout.save =================================================================== --- pkg/pomp/tests/ou2-simulate.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-simulate.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > ## fix some parameters @@ -39,7 +35,7 @@ > ou2.sim <- simulate(ou2,params=p,nsim=100,seed=32043858) > toc <- Sys.time() > print(toc-tic) -Time difference of 0.006201267 secs +Time difference of 0.007747889 secs > > coef(ou2,c('x1.0','x2.0')) <- c(-50,50) > @@ -50,4 +46,4 @@ > > proc.time() user system elapsed - 0.523 0.016 0.530 + 0.501 0.022 0.507 Modified: pkg/pomp/tests/ou2-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,17 +16,13 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > set.seed(93885485L) > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > true.p <- coef(ou2) > simdata <- simulate(ou2,nsim=5,params=true.p,seed=394885) @@ -159,7 +155,7 @@ > stopifnot(fit$convergence==0) > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > p <- coef(ou2) > ou2 at params <- numeric(0) @@ -179,4 +175,4 @@ > > proc.time() user system elapsed - 1.771 0.065 1.824 + 1.740 0.048 1.765 Modified: pkg/pomp/tests/partrans.Rout.save =================================================================== --- pkg/pomp/tests/partrans.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/partrans.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(gompertz) -newly created pomp object(s): +newly created object(s): gompertz > > pars <- coef(gompertz) @@ -56,4 +52,4 @@ > > proc.time() user system elapsed - 0.500 0.053 0.522 + 0.492 0.020 0.494 Modified: pkg/pomp/tests/pfilter.Rout.save =================================================================== --- pkg/pomp/tests/pfilter.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/pfilter.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > > set.seed(9994847L) @@ -49,7 +45,7 @@ -479.61 0.46 > > pompExample(euler.sir) -newly created pomp object(s): +newly created object(s): euler.sir > pf <- pfilter(euler.sir,Np=100,seed=394343L) > print(coef(pf)) @@ -81,4 +77,4 @@ > > proc.time() user system elapsed - 10.454 0.035 10.489 + 9.887 0.037 9.924 Modified: pkg/pomp/tests/pomppomp.Rout.save =================================================================== --- pkg/pomp/tests/pomppomp.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/pomppomp.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ricker) -newly created pomp object(s): +newly created object(s): ricker > y1 <- obs(simulate(ricker,seed=1066L)) > r2 <- pomp(ricker,measurement.model=y~pois(lambda=N*phi)) @@ -59,4 +55,4 @@ > > proc.time() user system elapsed - 0.562 0.032 0.582 + 0.489 0.030 0.504 Modified: pkg/pomp/tests/prior.Rout.save =================================================================== --- pkg/pomp/tests/prior.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/prior.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ou2) -newly created pomp object(s): +newly created object(s): ou2 > coef(ou2,"alpha.sd") <- 5 Warning message: @@ -76,4 +72,4 @@ > > proc.time() user system elapsed - 0.697 0.016 0.703 + 0.683 0.025 0.694 Modified: pkg/pomp/tests/ricker-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ricker-bsmc.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ricker-bsmc.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ricker) -newly created pomp object(s): +newly created object(s): ricker > > pdf(file="ricker-bsmc.pdf") @@ -58,4 +54,4 @@ > > proc.time() user system elapsed - 3.035 0.057 3.068 + 2.571 0.057 2.614 Modified: pkg/pomp/tests/ricker-probe.Rout.save =================================================================== --- pkg/pomp/tests/ricker-probe.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ricker-probe.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,15 +16,11 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pompExample(ricker) -newly created pomp object(s): +newly created object(s): ricker > > pdf(file="ricker-probe.pdf") @@ -301,4 +297,4 @@ > > proc.time() user system elapsed - 14.323 0.079 14.418 + 13.643 0.070 13.713 Modified: pkg/pomp/tests/ricker-spect.Rout.save =================================================================== --- pkg/pomp/tests/ricker-spect.Rout.save 2015-01-01 21:20:25 UTC (rev 1038) +++ pkg/pomp/tests/ricker-spect.Rout.save 2015-01-01 21:20:29 UTC (rev 1039) @@ -1,5 +1,5 @@ -R version 3.1.1 (2014-07-10) -- "Sock it to Me" +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: x86_64-unknown-linux-gnu (64-bit) @@ -16,17 +16,13 @@ Type 'q()' to quit R. > library(pomp) -Loading required package: mvtnorm Loading required package: subplex Loading required package: nloptr -Loading required package: deSolve -Loading required package: coda -Loading required package: lattice > > pdf(file="ricker-spect.pdf") > > pompExample(ricker) -newly created pomp object(s): +newly created object(s): ricker > > set.seed(6457673L) @@ -74,4 +70,4 @@ > > proc.time() [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1039 From noreply at r-forge.r-project.org Fri Jan 2 00:13:41 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 2 Jan 2015 00:13:41 +0100 (CET) Subject: [Pomp-commits] r1040 - pkg/pompExamples Message-ID: <20150101231341.A9EA2185E0A@r-forge.r-project.org> Author: kingaa Date: 2015-01-02 00:13:41 +0100 (Fri, 02 Jan 2015) New Revision: 1040 Modified: pkg/pompExamples/DESCRIPTION Log: - add plyr and reshape2 to Suggests field Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-01 21:20:29 UTC (rev 1039) +++ pkg/pompExamples/DESCRIPTION 2015-01-01 23:13:41 UTC (rev 1040) @@ -17,6 +17,7 @@ URL: http://pomp.r-forge.r-project.org Description: More 'pomp' examples. Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.56-1) +Suggests: plyr, reshape2 License: GPL (>= 2) LazyData: false BuildVignettes: true From noreply at r-forge.r-project.org Fri Jan 2 03:39:52 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 2 Jan 2015 03:39:52 +0100 (CET) Subject: [Pomp-commits] r1041 - in pkg/pompExamples: . inst/examples Message-ID: <20150102023952.69117185183@r-forge.r-project.org> Author: kingaa Date: 2015-01-02 03:39:51 +0100 (Fri, 02 Jan 2015) New Revision: 1041 Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/inst/examples/ebola.R Log: - fix bug Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-01 23:13:41 UTC (rev 1040) +++ pkg/pompExamples/DESCRIPTION 2015-01-02 02:39:51 UTC (rev 1041) @@ -1,7 +1,7 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.25-1 +Version: 0.25-2 Date: 2015-01-01 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), Modified: pkg/pompExamples/inst/examples/ebola.R =================================================================== --- pkg/pompExamples/inst/examples/ebola.R 2015-01-01 23:13:41 UTC (rev 1040) +++ pkg/pompExamples/inst/examples/ebola.R 2015-01-02 02:39:51 UTC (rev 1041) @@ -3,7 +3,7 @@ require(reshape2) WHO.situation.report.Oct.1 <- ' -Week,Guinea,Liberia,SierraLeone +week,Guinea,Liberia,SierraLeone 1,2.244,, 2,2.244,, 3,0.073,, @@ -50,7 +50,6 @@ populations["WestAfrica"] <- sum(populations) dat <- read.csv(text=WHO.situation.report.Oct.1,stringsAsFactors=FALSE) -rename(dat,c(Week="week")) -> dat dat <- melt(dat,id="week",variable.name="country",value.name="cases") mutate(dat,deaths=NA) -> dat @@ -78,7 +77,14 @@ S_0=1-index_case,E_0=index_case/2-5e-9, I_0=index_case/2-5e-9,R_0=1e-8) - dat <- subset(dat,country==ctry,select=-country) + if (ctry=="WestAfrica") { + dat <- ddply(dat,~week,summarize, + cases=sum(cases,na.rm=TRUE), + deaths=sum(deaths,na.rm=TRUE)) + } else { + dat <- subset(dat,country==ctry,select=-country) + } + if (na.rm) { dat <- mutate(subset(dat,!is.na(cases)),week=week-min(week)+1) } @@ -86,8 +92,6 @@ dat <- mutate(dat,cases=cumsum(cases),deaths=cumsum(deaths)) } - print(dat) - ## Create the pomp object pomp( data=dat, @@ -99,7 +103,7 @@ zeronames=if (type=="raw") c("N_EI","N_IR") else character(0), paramnames=c("N","R0","alpha","gamma","rho","k","cfr", "S_0","E_0","I_0","R_0"), - nstageE=nstageE, + nstageE=as.integer(nstageE), PACKAGE="pompExamples", dmeasure=if (least.sq) "_ebola_dObsLS" else "_ebola_dObs", rmeasure=if (least.sq) "_ebola_rObsLS" else "_ebola_rObs", From noreply at r-forge.r-project.org Fri Jan 2 15:04:39 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 2 Jan 2015 15:04:39 +0100 (CET) Subject: [Pomp-commits] r1042 - in pkg/pompExamples: . inst/examples tests Message-ID: <20150102140439.2A0A018795C@r-forge.r-project.org> Author: kingaa Date: 2015-01-02 15:04:38 +0100 (Fri, 02 Jan 2015) New Revision: 1042 Added: pkg/pompExamples/tests/bbp.R pkg/pompExamples/tests/bbp.Rout.save pkg/pompExamples/tests/ebola.R pkg/pompExamples/tests/ebola.Rout.save pkg/pompExamples/tests/parus.R pkg/pompExamples/tests/parus.Rout.save Removed: pkg/pompExamples/tests/examples.R Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/inst/examples/ebola.R pkg/pompExamples/tests/budmoth.Rout.save pkg/pompExamples/tests/pertussis.Rout.save Log: - fix ebola example - rearrange tests directory Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-02 02:39:51 UTC (rev 1041) +++ pkg/pompExamples/DESCRIPTION 2015-01-02 14:04:38 UTC (rev 1042) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.25-2 -Date: 2015-01-01 +Version: 0.25-3 +Date: 2015-01-02 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), Modified: pkg/pompExamples/inst/examples/ebola.R =================================================================== --- pkg/pompExamples/inst/examples/ebola.R 2015-01-02 02:39:51 UTC (rev 1041) +++ pkg/pompExamples/inst/examples/ebola.R 2015-01-02 14:04:38 UTC (rev 1042) @@ -54,6 +54,7 @@ mutate(dat,deaths=NA) -> dat ebolaModel <- function (country=c("Guinea", "SierraLeone", "Liberia", "WestAfrica"), + data = NULL, timestep = 0.01, nstageE = 3L, type = c("raw","cum"), na.rm = FALSE, least.sq = FALSE) { @@ -77,14 +78,18 @@ S_0=1-index_case,E_0=index_case/2-5e-9, I_0=index_case/2-5e-9,R_0=1e-8) - if (ctry=="WestAfrica") { - dat <- ddply(dat,~week,summarize, - cases=sum(cases,na.rm=TRUE), - deaths=sum(deaths,na.rm=TRUE)) + if (is.null(data)) { + if (ctry=="WestAfrica") { + dat <- ddply(dat,~week,summarize, + cases=sum(cases,na.rm=TRUE), + deaths=sum(deaths,na.rm=TRUE)) + } else { + dat <- subset(dat,country==ctry,select=-country) + } } else { - dat <- subset(dat,country==ctry,select=-country) + dat <- data } - + if (na.rm) { dat <- mutate(subset(dat,!is.na(cases)),week=week-min(week)+1) } Added: pkg/pompExamples/tests/bbp.R =================================================================== --- pkg/pompExamples/tests/bbp.R (rev 0) +++ pkg/pompExamples/tests/bbp.R 2015-01-02 14:04:38 UTC (rev 1042) @@ -0,0 +1,7 @@ +library(pompExamples) + +set.seed(47575684L) + +pompExample(bbp) +pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) +tj <- trajectory(bbp) Added: pkg/pompExamples/tests/bbp.Rout.save =================================================================== --- pkg/pompExamples/tests/bbp.Rout.save (rev 0) +++ pkg/pompExamples/tests/bbp.Rout.save 2015-01-02 14:04:38 UTC (rev 1042) @@ -0,0 +1,33 @@ + +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" +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. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(pompExamples) +Loading required package: pomp +Loading required package: subplex +Loading required package: nloptr +> +> set.seed(47575684L) +> +> pompExample(bbp) +newly created pomp object(s): + bbp +> pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) +> tj <- trajectory(bbp) +> +> proc.time() + user system elapsed + 0.573 0.038 0.597 Modified: pkg/pompExamples/tests/budmoth.Rout.save =================================================================== --- pkg/pompExamples/tests/budmoth.Rout.save 2015-01-02 02:39:51 UTC (rev 1041) +++ pkg/pompExamples/tests/budmoth.Rout.save 2015-01-02 14:04:38 UTC (rev 1042) @@ -127,4 +127,4 @@ > > proc.time() user system elapsed - 0.649 0.033 0.670 + 0.614 0.056 0.652 Added: pkg/pompExamples/tests/ebola.R =================================================================== --- pkg/pompExamples/tests/ebola.R (rev 0) +++ pkg/pompExamples/tests/ebola.R 2015-01-02 14:04:38 UTC (rev 1042) @@ -0,0 +1,15 @@ +library(pompExamples) + +set.seed(47575684L) + +pompExample(ebola) +ebolaModel(country="Guinea") -> po +pf <- pfilter(simulate(po),Np=100) +tj <- trajectory(po) + +ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po +pf <- pfilter(simulate(po),Np=100) +tj <- trajectory(po) +dd <- simulate(po,as.data.frame=TRUE,obs=TRUE) +dd$week <- dd$time +po <- ebolaModel(data=subset(dd,select=c(week,cases,deaths))) Added: pkg/pompExamples/tests/ebola.Rout.save =================================================================== --- pkg/pompExamples/tests/ebola.Rout.save (rev 0) +++ pkg/pompExamples/tests/ebola.Rout.save 2015-01-02 14:04:38 UTC (rev 1042) @@ -0,0 +1,43 @@ + +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" +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. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(pompExamples) +Loading required package: pomp +Loading required package: subplex +Loading required package: nloptr +> +> set.seed(47575684L) +> +> pompExample(ebola) +Loading required package: plyr +Loading required package: reshape2 +newly created pomp object(s): + ebolaModel +> ebolaModel(country="Guinea") -> po +> pf <- pfilter(simulate(po),Np=100) +> tj <- trajectory(po) +> +> ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po +> pf <- pfilter(simulate(po),Np=100) +> tj <- trajectory(po) +> dd <- simulate(po,as.data.frame=TRUE,obs=TRUE) +> dd$week <- dd$time +> po <- ebolaModel(data=subset(dd,select=c(week,cases,deaths))) +> +> proc.time() + user system elapsed + 1.100 0.034 1.119 Deleted: pkg/pompExamples/tests/examples.R =================================================================== --- pkg/pompExamples/tests/examples.R 2015-01-02 02:39:51 UTC (rev 1041) +++ pkg/pompExamples/tests/examples.R 2015-01-02 14:04:38 UTC (rev 1042) @@ -1,33 +0,0 @@ -library(pompExamples) - -set.seed(47575684L) - -po <- pompExample(parus,proc="Ricker",meas="lognormal",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) -tj <- trajectory(po$parus) - -po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) - -po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) - -po <- pompExample(parus,proc="Gompertz",meas="Poisson",envir=NULL) -pf <- pfilter(simulate(po[[1]]),Np=100,max.fail=Inf) -tj <- trajectory(po[[1]]) - -po <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) -pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) - -pompExample(bbp) -pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) -tj <- trajectory(bbp) - -pompExample(ebola) -ebolaModel(country="Guinea") -> po -pf <- pfilter(simulate(po),Np=100) -tj <- trajectory(po) - -ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po -pf <- pfilter(simulate(po),Np=100) -tj <- trajectory(po) Copied: pkg/pompExamples/tests/parus.R (from rev 1041, pkg/pompExamples/tests/examples.R) =================================================================== --- pkg/pompExamples/tests/parus.R (rev 0) +++ pkg/pompExamples/tests/parus.R 2015-01-02 14:04:38 UTC (rev 1042) @@ -0,0 +1,20 @@ +library(pompExamples) + +set.seed(47575684L) + +po <- pompExample(parus,proc="Ricker",meas="lognormal",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +tj <- trajectory(po$parus) + +po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) + +po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) + +po <- pompExample(parus,proc="Gompertz",meas="Poisson",envir=NULL) +pf <- pfilter(simulate(po[[1]]),Np=100,max.fail=Inf) +tj <- trajectory(po[[1]]) + +po <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) +pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) Added: pkg/pompExamples/tests/parus.Rout.save =================================================================== --- pkg/pompExamples/tests/parus.Rout.save (rev 0) +++ pkg/pompExamples/tests/parus.Rout.save 2015-01-02 14:04:38 UTC (rev 1042) @@ -0,0 +1,44 @@ + +R version 3.1.2 (2014-10-31) -- "Pumpkin Helmet" +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. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(pompExamples) +Loading required package: pomp +Loading required package: subplex +Loading required package: nloptr +> +> set.seed(47575684L) +> +> po <- pompExample(parus,proc="Ricker",meas="lognormal",envir=NULL) +> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +> tj <- trajectory(po$parus) +> +> po <- pompExample(parus,proc="Ricker",meas="negbin",envir=NULL) +> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +> +> po <- pompExample(parus,proc="Ricker",meas="Poisson",envir=NULL) +> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +> +> po <- pompExample(parus,proc="Gompertz",meas="Poisson",envir=NULL) +> pf <- pfilter(simulate(po[[1]]),Np=100,max.fail=Inf) +> tj <- trajectory(po[[1]]) +> +> po <- pompExample(parus,proc="Gompertz",meas="lognormal",envir=NULL) +> pf <- pfilter(simulate(po$parus),Np=100,max.fail=Inf) +> +> proc.time() + user system elapsed + 0.572 0.037 0.596 Modified: pkg/pompExamples/tests/pertussis.Rout.save =================================================================== --- pkg/pompExamples/tests/pertussis.Rout.save 2015-01-02 02:39:51 UTC (rev 1041) +++ pkg/pompExamples/tests/pertussis.Rout.save 2015-01-02 14:04:38 UTC (rev 1042) @@ -168,4 +168,4 @@ > > proc.time() user system elapsed - 23.494 0.034 23.544 + 23.697 0.033 23.738 From noreply at r-forge.r-project.org Fri Jan 2 15:04:49 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 2 Jan 2015 15:04:49 +0100 (CET) Subject: [Pomp-commits] r1043 - in pkg/pomp: . R inst man Message-ID: <20150102140449.712F918795C@r-forge.r-project.org> Author: kingaa Date: 2015-01-02 15:04:49 +0100 (Fri, 02 Jan 2015) New Revision: 1043 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/simulate-pomp.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/simulate-pomp.Rd Log: - new 'include.data' argument to 'simulate' Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-02 14:04:38 UTC (rev 1042) +++ pkg/pomp/DESCRIPTION 2015-01-02 14:04:49 UTC (rev 1043) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.56-2 -Date: 2015-01-01 +Version: 0.57-1 +Date: 2015-01-02 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/simulate-pomp.R =================================================================== --- pkg/pomp/R/simulate-pomp.R 2015-01-02 14:04:38 UTC (rev 1042) +++ pkg/pomp/R/simulate-pomp.R 2015-01-02 14:04:49 UTC (rev 1043) @@ -3,6 +3,7 @@ simulate.internal <- function (object, nsim = 1, seed = NULL, params, states = FALSE, obs = FALSE, times, t0, as.data.frame = FALSE, + include.data = FALSE, .getnativesymbolinfo = TRUE, ...) { if (missing(times)) @@ -18,6 +19,7 @@ obs <- as.logical(obs) states <- as.logical(states) as.data.frame <- as.logical(as.data.frame) + include.data <- as.logical(include.data) if (missing(params)) params <- coef(object) @@ -109,6 +111,11 @@ retval$sim <- factor(1) } } + + if (include.data) { + od <- as.data.frame(object) + retval <- merge(od,retval,sort=FALSE) + } } @@ -119,8 +126,9 @@ "simulate", signature=signature(object="pomp"), definition=function (object, nsim = 1, seed = NULL, params, - states = FALSE, obs = FALSE, - times, t0, as.data.frame = FALSE, ...) + states = FALSE, obs = FALSE, + times, t0, as.data.frame = FALSE, include.data = FALSE, + ...) simulate.internal( object=object, nsim=nsim, @@ -131,6 +139,7 @@ times=times, t0=t0, as.data.frame=as.data.frame, + include.data=include.data, ... ) ) Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-01-02 14:04:38 UTC (rev 1042) +++ pkg/pomp/inst/NEWS 2015-01-02 14:04:49 UTC (rev 1043) @@ -1,5 +1,12 @@ _N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p' +_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_7-_1: + + ? ?simulate? has a new argument, ?include.data?, that when used + in conjuncion with ?as.data.frame=TRUE? will include the + actual data in the resulting data frame along with the + simulations. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_6-_1: ? Revamped the ?pompExample? function. A search path for Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-01-02 14:04:38 UTC (rev 1042) +++ pkg/pomp/inst/NEWS.Rd 2015-01-02 14:04:49 UTC (rev 1043) @@ -1,5 +1,10 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.57-1}{ + \itemize{ + \item \code{simulate} has a new argument, \code{include.data}, that when used in conjuncion with \code{as.data.frame=TRUE} will include the actual data in the resulting data frame along with the simulations. + } +} \section{Changes in \pkg{pomp} version 0.56-1}{ \itemize{ \item Revamped the \code{pompExample} function. Modified: pkg/pomp/man/simulate-pomp.Rd =================================================================== --- pkg/pomp/man/simulate-pomp.Rd 2015-01-02 14:04:38 UTC (rev 1042) +++ pkg/pomp/man/simulate-pomp.Rd 2015-01-02 14:04:49 UTC (rev 1043) @@ -9,7 +9,7 @@ \usage{ \S4method{simulate}{pomp}(object, nsim = 1, seed = NULL, params, states = FALSE, obs = FALSE, times, t0, - as.data.frame = FALSE, \dots) + as.data.frame = FALSE, include.data = FALSE, \dots) } \arguments{ \item{object}{An object of class \code{pomp}.} @@ -34,8 +34,11 @@ \code{t0} specifies the start time (the time at which the initial conditions hold). The default for \code{times} is is \code{times=time(object,t0=FALSE)} and \code{t0=timezero(object)}, respectively. } - \item{as.data.frame}{ - logical; if \code{TRUE}, return the result as a data-frame. + \item{as.data.frame, include.data}{ + logical; if \code{as.data.frame=TRUE}, the results are returned as a data-frame. + A factor variable, \sQuote{sim}, distinguishes one simulation from another. + If, in addition, \code{include.data=TRUE}, the original data are included as an additional \sQuote{simulation}. + If \code{as.data.frame=FALSE}, \code{include.data} is ignored. } \item{\dots}{further arguments that are currently ignored.} } @@ -64,6 +67,8 @@ pompExample(ou2) x <- simulate(ou2,seed=3495485,nsim=10) x <- simulate(ou2,seed=3495485,nsim=10,states=TRUE,obs=TRUE) +x <- simulate(ou2,seed=3495485,nsim=10,obs=TRUE, + as.data.frame=TRUE,include.data=TRUE) } \author{Aaron A. King \email{kingaa at umich dot edu}} \seealso{\link{pomp}} From noreply at r-forge.r-project.org Wed Jan 7 00:07:54 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Jan 2015 00:07:54 +0100 (CET) Subject: [Pomp-commits] r1044 - in pkg/pompExamples: . inst/examples src tests Message-ID: <20150106230754.53D4C18431B@r-forge.r-project.org> Author: kingaa Date: 2015-01-07 00:07:54 +0100 (Wed, 07 Jan 2015) New Revision: 1044 Removed: pkg/pompExamples/src/ebola.c Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/inst/examples/ebola.R pkg/pompExamples/tests/bbp.Rout.save pkg/pompExamples/tests/budmoth.Rout.save pkg/pompExamples/tests/ebola.Rout.save pkg/pompExamples/tests/parus.Rout.save pkg/pompExamples/tests/pertussis.Rout.save Log: - pull Ebola example back to using on-the-fly compiled codes Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/DESCRIPTION 2015-01-06 23:07:54 UTC (rev 1044) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.25-3 -Date: 2015-01-02 +Version: 0.25-4 +Date: 2015-01-05 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), Modified: pkg/pompExamples/inst/examples/ebola.R =================================================================== --- pkg/pompExamples/inst/examples/ebola.R 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/inst/examples/ebola.R 2015-01-06 23:07:54 UTC (rev 1044) @@ -53,6 +53,117 @@ dat <- melt(dat,id="week",variable.name="country",value.name="cases") mutate(dat,deaths=NA) -> dat + +paruntrans <- Csnippet(' + double *IC = &S_0; + double *TIC = &TS_0; + TN = log(N); + TR0 = log(R0); + Talpha = log(alpha); + Tgamma = log(gamma); + Trho = logit(rho); + Tk = log(k); + Tcfr = logit(cfr); + to_log_barycentric(TIC,IC,4); +') + +partrans <- Csnippet(' + double *IC = &S_0; + double *TIC = &TS_0; + TN = exp(N); + TR0 = exp(R0); + Talpha = exp(alpha); + Tgamma = exp(gamma); + Trho = expit(rho); + Tk = exp(k); + Tcfr = expit(cfr); + from_log_barycentric(TIC,IC,4); +') + +## Observation model: hierarchical model for cases and deaths +## p(R_t, D_t| C_t) = p(R_t | C_t) * p(D_t | C_t, R_t) +## p(R_t | C_t): Negative binomial with mean rho * C_t and dispersion parameter 1 / k +## p(D_t | C_t, R_t): Binomial B(R_t, cfr) + +dObs <- Csnippet(' + double f; + if (k > 0.0) + f = dnbinom_mu(nearbyint(cases),1.0/k,rho*N_EI,1); + else + f = dpois(nearbyint(cases),rho*N_EI,1); + lik = (give_log) ? f : exp(f); +') + +dObsLS <- Csnippet(' + double f; + f = dnorm(cases,rho*N_EI,k,1); + lik = (give_log) ? f : exp(f); +') + +rObs <- Csnippet(' + if (k > 0) { + cases = rnbinom_mu(1.0/k,rho*N_EI); + deaths = rnbinom_mu(1.0/k,rho*cfr*N_IR); + } else { + cases = rpois(rho*N_EI); + deaths = rpois(rho*cfr*N_IR); + }') + +rObsLS <- Csnippet(' + cases = rnorm(rho*N_EI,k); + deaths = NA_REAL; +') + +rSim <- Csnippet(' + double lambda, beta; + double *E = &E1; + beta = R0 * gamma; // Transmission rate + lambda = beta * I / N; // Force of infection + int i; + + // Transitions + // From class S + double transS = rbinom(S, 1.0 - exp(- lambda * dt)); // No of infections + // From class E + double transE[nstageE]; // No of transitions between classes E + for(i = 0; i < nstageE; i++){ + transE[i] = rbinom(E[i], 1.0 - exp(- nstageE * alpha * dt)); + } + // From class I + double transI = rbinom(I, 1.0 - exp(- gamma * dt)); // No of transitions I->R + + // Balance the equations + S -= transS; + E[0] += transS - transE[0]; + for(i=1; i < nstageE; i++) { + E[i] += transE[i-1] - transE[i]; + } + I += transE[nstageE - 1] - transI; + R += transI; + N_EI += transE[nstageE - 1]; // No of transitions from E to I + N_IR += transI; // No of transitions from I to R +') + +skel <- Csnippet(' + double lambda, beta; + double *E = &E1; + double *DE = &DE1; + beta = R0 * gamma; // Transmission rate + lambda = beta * I / N; // Force of infection + int i; + + // Balance the equations + DS = - lambda * S; + DE[0] = lambda * S - nstageE * alpha * E[0]; + for (i=1; i < nstageE; i++) + DE[i] = nstageE * alpha * (E[i-1]-E[i]); + DI = nstageE * alpha * E[nstageE-1] - gamma * I; + DR = gamma * I; + DN_EI = nstageE * alpha * E[nstageE-1]; + DN_IR = gamma * I; +') + + ebolaModel <- function (country=c("Guinea", "SierraLeone", "Liberia", "WestAfrica"), data = NULL, timestep = 0.01, nstageE = 3L, @@ -69,7 +180,10 @@ infectious_period <- 7/7 index_case <- 10/pop dt <- timestep + nstageE <- as.integer(nstageE) + globs <- paste0("static int nstageE = ",nstageE,";"); + theta <- c(N=pop,R0=1.4, alpha=-1/(nstageE*dt)*log(1-nstageE*dt/incubation_period), gamma=-log(1-dt/infectious_period)/dt, @@ -89,7 +203,7 @@ } else { dat <- data } - + if (na.rm) { dat <- mutate(subset(dat,!is.na(cases)),week=week-min(week)+1) } @@ -103,20 +217,20 @@ times="week", t0=0, params=theta, + globals=globs, obsnames=c("cases","deaths"), statenames=c("S","E1","I","R","N_EI","N_IR"), zeronames=if (type=="raw") c("N_EI","N_IR") else character(0), paramnames=c("N","R0","alpha","gamma","rho","k","cfr", "S_0","E_0","I_0","R_0"), - nstageE=as.integer(nstageE), - PACKAGE="pompExamples", - dmeasure=if (least.sq) "_ebola_dObsLS" else "_ebola_dObs", - rmeasure=if (least.sq) "_ebola_rObsLS" else "_ebola_rObs", - rprocess=discrete.time.sim(step.fun="_ebola_rSim",delta.t=timestep), - skeleton="_ebola_skel", + nstageE=nstageE, + dmeasure=if (least.sq) dObsLS else dObs, + rmeasure=if (least.sq) rObsLS else rObs, + rprocess=discrete.time.sim(step.fun=rSim,delta.t=timestep), + skeleton=skel, skeleton.type="vectorfield", - parameter.transform="_ebola_par_trans", - parameter.inv.transform="_ebola_par_untrans", + parameter.transform=partrans, + parameter.inv.transform=paruntrans, initializer=function (params, t0, nstageE, ...) { all.state.names <- c("S",paste0("E",1:nstageE),"I","R","N_EI","N_IR") comp.names <- c("S",paste0("E",1:nstageE),"I","R") Deleted: pkg/pompExamples/src/ebola.c =================================================================== --- pkg/pompExamples/src/ebola.c 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/src/ebola.c 2015-01-06 23:07:54 UTC (rev 1044) @@ -1,187 +0,0 @@ -// SEIR Ebola model - -#include -#include -#include -#include - -// State variables -#define S (x[stateindex[0]]) // Susceptible -#define E(J) (x[stateindex[1] + (J)]) // Exposed -#define I (x[stateindex[2]]) // Infected -#define R (x[stateindex[3]]) // Removed -#define N_EI (x[stateindex[4]]) // Number of transitions from E to I -#define N_IR (x[stateindex[5]]) // Number of transitions from I to R - -// Variations -#define DS (f[stateindex[0]]) // Susceptible -#define DE(J) (f[stateindex[1] + (J)]) // Exposed -#define DI (f[stateindex[2]]) // Infected -#define DR (f[stateindex[3]]) // Removed -#define DN_EI (f[stateindex[4]]) // Number of transitions from E to I -#define DN_IR (f[stateindex[5]]) // Number of transitions from I to R - -// Parameters on the natural scale (all rates are per day) -#define N (p[parindex[0]]) // Population size -#define R0 (p[parindex[1]]) // Basic reproduction number -#define alpha (p[parindex[2]]) // Inverse of latency period -#define gamma (p[parindex[3]]) // Inverse of duration of infection -#define rho (p[parindex[4]]) // Reporting probability -#define k (p[parindex[5]]) // Reporting overdispersion -#define cfr (p[parindex[6]]) // Case-fatality ratio -#define IC(J) (p[parindex[7] + (J)]) // Initial conditions - -// Parameters on the transformed scale (all rates are per day) -#define TN (pt[parindex[0]]) // Population size -#define TR0 (pt[parindex[1]]) // Basic reproduction number -#define Talpha (pt[parindex[2]]) // Inverse of latency period -#define Tgamma (pt[parindex[3]]) // Inverse of duration of infection -#define Trho (pt[parindex[4]]) // Reporting probability -#define Tk (pt[parindex[5]]) // Reporting overdispersion -#define Tcfr (pt[parindex[6]]) // Case-fatality ratio -#define TIC(J) (pt[parindex[7] + (J)]) // Initial conditions - -// Observations -#define cases (y[obsindex[0]]) // Number of reported cases -#define deaths (y[obsindex[1]]) // Number of reported deaths - -// Transforms the parameters to the transformed scale -void _ebola_par_untrans (double *pt, double *p, int *parindex){ - TN = log(N); - TR0 = log(R0); - Talpha = log(alpha); - Tgamma = log(gamma); - Trho = logit(rho); - Tk = log(k); - Tcfr = logit(cfr); - to_log_barycentric(&(TIC(0)),&(IC(0)),4); -} - -// Transforms the parameters to the natural scale -void _ebola_par_trans (double *pt, double *p, int *parindex){ - TN = exp(N); - TR0 = exp(R0); - Talpha = exp(alpha); - Tgamma = exp(gamma); - Trho = expit(rho); - Tk = exp(k); - Tcfr = expit(cfr); - from_log_barycentric(&(TIC(0)),&(IC(0)),4); -} - -// Observation model: hierarchical model for cases and deaths -// p(R_t, D_t| C_t) = p(R_t | C_t) * p(D_t | C_t, R_t) -// p(R_t | C_t): Negative binomial with mean rho * C_t and dispersion parameter 1 / k -// p(D_t | C_t, R_t): Binomial B(R_t, cfr) -void _ebola_dObs (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 f; - if (k > 0.0) - f = dnbinom_mu(nearbyint(cases),1.0/k,rho*N_EI,1); - // f += dnbinom_mu(nearbyint(deaths), 1.0 / k, rho * cfr * N_IR, 1); - else - f = dpois(nearbyint(cases),rho*N_EI,1); - *lik = (give_log) ? f : exp(f); -} - -// For least-squares trajectory-matching: -void _ebola_dObsLS (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 f; - f = dnorm(cases,rho*N_EI,k,1); - *lik = (give_log) ? f : exp(f); -} - -void _ebola_rObs (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovars, double *covars, double t) -{ - if (k > 0) { - cases = rnbinom_mu(1.0/k,rho*N_EI); - deaths = rnbinom_mu(1.0/k,rho*cfr*N_IR); - } else { - cases = rpois(rho*N_EI); - deaths = rpois(rho*cfr*N_IR); - } -} - -// For least-squares trajectory-matching: -void _ebola_rObsLS (double *y, double *x, double *p, - int *obsindex, int *stateindex, int *parindex, int *covindex, - int ncovars, double *covars, double t) -{ - cases = rnorm(rho*N_EI,k); - deaths = NA_REAL; -} - - -// Process model -void _ebola_rSim (double *x, const double *p, - const int *stateindex, const int *parindex, const int *covindex, - int covdim, const double *covars, - double t, double dt) { - - // Retrieve user data in the pomp object - int *(*get_pomp_userdata_int)(const char *); - get_pomp_userdata_int = (int *(*)(const char *)) R_GetCCallable("pomp","get_pomp_userdata_int"); - int nstageE = *(get_pomp_userdata_int("nstageE")); // Number of stages in the E class - - // Other parameters - double lambda, beta; - beta = R0 * gamma; // Transmission rate - lambda = beta * I / N; // Force of infection - int i; - - // Transitions - - // From class S - double transS = rbinom(S, 1.0 - exp(- lambda * dt)); // No of infections - - // From class E - double transE[nstageE]; // No of transitions between classes E - for(i = 0; i < nstageE; i++){ - transE[i] = rbinom(E(i), 1.0 - exp(- nstageE * alpha * dt)); - } - - // From class I - double transI = rbinom(I, 1.0 - exp(- gamma * dt)); // No of transitions I->R - - // Balance the equations - S -= transS; - E(0) += transS - transE[0]; - for(i=1; i < nstageE; i++) { - E(i) += transE[i-1] - transE[i]; - } - I += transE[nstageE - 1] - transI; - R += transI; - N_EI += transE[nstageE - 1]; // No of transitions from E to I - N_IR += transI; // No of transitions from I to R -} - -// Continuous-time deterministic skeleton -void _ebola_skel (double *f, double *x, double *p, - int *stateindex, int *parindex, int *covindex, - int ncovars, double *covars, double t) { - - // Retrieve user data in the pomp object - int *(*get_pomp_userdata_int)(const char *); - get_pomp_userdata_int = (int *(*)(const char *)) R_GetCCallable("pomp","get_pomp_userdata_int"); - int nstageE = *(get_pomp_userdata_int("nstageE")); // Number of stages in the E class - - // Other parameters - double lambda, beta; - beta = R0 * gamma; // Transmission rate - lambda = beta * I / N; // Force of infection - int i; - - // Balance the equations - DS = - lambda * S; - DE(0) = lambda * S - nstageE * alpha * E(0); - for(i=1; i < nstageE; i++) DE(i) = nstageE * alpha * (E(i - 1) - E(i)); - DI = nstageE * alpha * E(nstageE - 1) - gamma * I; - DR = gamma * I; - DN_EI = nstageE * alpha * E(nstageE - 1); - DN_IR = gamma * I; -} Modified: pkg/pompExamples/tests/bbp.Rout.save =================================================================== --- pkg/pompExamples/tests/bbp.Rout.save 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/tests/bbp.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) @@ -23,11 +23,11 @@ > set.seed(47575684L) > > pompExample(bbp) -newly created pomp object(s): +newly created object(s): bbp > pf <- pfilter(simulate(bbp),Np=100,max.fail=Inf) > tj <- trajectory(bbp) > > proc.time() user system elapsed - 0.573 0.038 0.597 + 0.728 0.028 0.786 Modified: pkg/pompExamples/tests/budmoth.Rout.save =================================================================== --- pkg/pompExamples/tests/budmoth.Rout.save 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/tests/budmoth.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) @@ -127,4 +127,4 @@ > > proc.time() user system elapsed - 0.614 0.056 0.652 + 0.732 0.060 0.818 Modified: pkg/pompExamples/tests/ebola.Rout.save =================================================================== --- pkg/pompExamples/tests/ebola.Rout.save 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/tests/ebola.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) @@ -25,19 +25,43 @@ > pompExample(ebola) Loading required package: plyr Loading required package: reshape2 -newly created pomp object(s): +newly created object(s): ebolaModel > ebolaModel(country="Guinea") -> po +make[1]: Entering directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +gcc -std=gnu99 -I/usr/local/apps/R/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -I/usr/local/apps/R/R-3.1.2/lib64/R/library/pomp/include -fpic -g -O2 -c /tmp/RtmpU0NeMt/pomp2583FF7C2A2A.c -o /tmp/RtmpU0NeMt/pomp2583FF7C2A2A.o +gcc -std=gnu99 -shared -L/usr/local/apps/R/R-3.1.2/lib64/R/lib -L/usr/local/lib64 -o /tmp/RtmpU0NeMt/pomp2583FF7C2A2A.so /tmp/RtmpU0NeMt/pomp2583FF7C2A2A.o -L/usr/local/apps/R/R-3.1.2/lib64/R/lib -lR +make[1]: Leaving directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +make[1]: Entering directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +make[1]: Leaving directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +model codes written to '/tmp/RtmpU0NeMt/pomp2583FF7C2A2A.c' +link to shared-object library '/tmp/RtmpU0NeMt/pomp2583FF7C2A2A.so' > pf <- pfilter(simulate(po),Np=100) > tj <- trajectory(po) > > ebolaModel(country="SierraLeone",na.rm=TRUE,type='cum') -> po +make[1]: Entering directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +gcc -std=gnu99 -I/usr/local/apps/R/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -I/usr/local/apps/R/R-3.1.2/lib64/R/library/pomp/include -fpic -g -O2 -c /tmp/RtmpU0NeMt/pompDA1B7D4C88B1.c -o /tmp/RtmpU0NeMt/pompDA1B7D4C88B1.o +gcc -std=gnu99 -shared -L/usr/local/apps/R/R-3.1.2/lib64/R/lib -L/usr/local/lib64 -o /tmp/RtmpU0NeMt/pompDA1B7D4C88B1.so /tmp/RtmpU0NeMt/pompDA1B7D4C88B1.o -L/usr/local/apps/R/R-3.1.2/lib64/R/lib -lR +make[1]: Leaving directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +make[1]: Entering directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +make[1]: Leaving directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +model codes written to '/tmp/RtmpU0NeMt/pompDA1B7D4C88B1.c' +link to shared-object library '/tmp/RtmpU0NeMt/pompDA1B7D4C88B1.so' > pf <- pfilter(simulate(po),Np=100) > tj <- trajectory(po) > dd <- simulate(po,as.data.frame=TRUE,obs=TRUE) > dd$week <- dd$time > po <- ebolaModel(data=subset(dd,select=c(week,cases,deaths))) +make[1]: Entering directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +gcc -std=gnu99 -I/usr/local/apps/R/R-3.1.2/lib64/R/include -DNDEBUG -I/usr/local/include -I/usr/local/apps/R/R-3.1.2/lib64/R/library/pomp/include -fpic -g -O2 -c /tmp/RtmpU0NeMt/pompBF9800D29D72.c -o /tmp/RtmpU0NeMt/pompBF9800D29D72.o +gcc -std=gnu99 -shared -L/usr/local/apps/R/R-3.1.2/lib64/R/lib -L/usr/local/lib64 -o /tmp/RtmpU0NeMt/pompBF9800D29D72.so /tmp/RtmpU0NeMt/pompBF9800D29D72.o -L/usr/local/apps/R/R-3.1.2/lib64/R/lib -lR +make[1]: Leaving directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +make[1]: Entering directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +make[1]: Leaving directory `/userdata/kingaa/projects/pomp/pkg/pompExamples.Rcheck/tests' +model codes written to '/tmp/RtmpU0NeMt/pompBF9800D29D72.c' +link to shared-object library '/tmp/RtmpU0NeMt/pompBF9800D29D72.so' > > proc.time() user system elapsed - 1.100 0.034 1.119 + 2.032 0.228 3.798 Modified: pkg/pompExamples/tests/parus.Rout.save =================================================================== --- pkg/pompExamples/tests/parus.Rout.save 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/tests/parus.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) @@ -41,4 +41,4 @@ > > proc.time() user system elapsed - 0.572 0.037 0.596 + 0.716 0.060 0.806 Modified: pkg/pompExamples/tests/pertussis.Rout.save =================================================================== --- pkg/pompExamples/tests/pertussis.Rout.save 2015-01-02 14:04:49 UTC (rev 1043) +++ pkg/pompExamples/tests/pertussis.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) @@ -168,4 +168,4 @@ > > proc.time() user system elapsed - 23.697 0.033 23.738 + 18.417 0.068 18.567 From noreply at r-forge.r-project.org Wed Jan 7 00:08:16 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Jan 2015 00:08:16 +0100 (CET) Subject: [Pomp-commits] r1045 - in pkg/pomp: . R src tests Message-ID: <20150106230816.1AC1D18431B@r-forge.r-project.org> Author: kingaa Date: 2015-01-07 00:08:15 +0100 (Wed, 07 Jan 2015) New Revision: 1045 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/trajectory-pomp.R pkg/pomp/src/dmeasure.c pkg/pomp/src/dprocess.c pkg/pomp/src/initstate.c pkg/pomp/src/pomp_internal.h pkg/pomp/src/rmeasure.c pkg/pomp/src/rprior.c pkg/pomp/src/rprocess.c pkg/pomp/src/skeleton.c pkg/pomp/tests/bbs-trajmatch.Rout.save pkg/pomp/tests/bbs.Rout.save pkg/pomp/tests/blowflies.Rout.save 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-abc.Rout.save pkg/pomp/tests/ou2-bsmc.Rout.save pkg/pomp/tests/ou2-bsmc2.Rout.save pkg/pomp/tests/ou2-forecast.Rout.save pkg/pomp/tests/ou2-kalman.Rout.save pkg/pomp/tests/ou2-mif-fp.Rout.save pkg/pomp/tests/ou2-mif.Rout.save pkg/pomp/tests/ou2-mif2.Rout.save pkg/pomp/tests/ou2-nlf.Rout.save pkg/pomp/tests/ou2-pmcmc.Rout.save pkg/pomp/tests/ou2-probe.Rout.save pkg/pomp/tests/ou2-procmeas.R 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.Rout.save 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: - use names on dimnames of arrays returned by basic pomp methods Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/DESCRIPTION 2015-01-06 23:08:15 UTC (rev 1045) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.57-1 -Date: 2015-01-02 +Version: 0.57-2 +Date: 2015-01-06 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/trajectory-pomp.R =================================================================== --- pkg/pomp/R/trajectory-pomp.R 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/R/trajectory-pomp.R 2015-01-06 23:08:15 UTC (rev 1045) @@ -91,6 +91,8 @@ } + dimnames(x) <- setNames(dimnames(x),c("variable","rep","time")) + if (as.data.frame) { x <- lapply( seq_len(ncol(x)), Modified: pkg/pomp/src/dmeasure.c =================================================================== --- pkg/pomp/src/dmeasure.c 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/dmeasure.c 2015-01-06 23:08:15 UTC (rev 1045) @@ -129,7 +129,9 @@ // create array to store results { int dim[2] = {nreps, ntimes}; + const char *dimnm[2] = {"rep","time"}; PROTECT(F = makearray(2,dim)); nprotect++; + fixdimnames(F,dimnm,2); } // now do computations Modified: pkg/pomp/src/dprocess.c =================================================================== --- pkg/pomp/src/dprocess.c 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/dprocess.c 2015-01-06 23:08:15 UTC (rev 1045) @@ -109,7 +109,10 @@ UNPROTECT(nprotect); error("dprocess error: user 'dprocess' must return a %d x %d array",nreps,ntimes-1); } - + { + const char *dimnms[2] = {"rep","time"}; + fixdimnames(X,dimnms,2); + } UNPROTECT(nprotect); return X; } Modified: pkg/pomp/src/initstate.c =================================================================== --- pkg/pomp/src/initstate.c 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/initstate.c 2015-01-06 23:08:15 UTC (rev 1045) @@ -18,6 +18,7 @@ int npar, nrep, nvar; int xdim[2], j, k; double *p, *pp, *xp, *xpp; + const char *dimnms[2] = {"variable","rep"}; PROTECT(params = as_matrix(params)); nprotect++; dim = INTEGER(GET_DIM(params)); @@ -76,6 +77,7 @@ xdim[0] = nvar; xdim[1] = nrep; PROTECT(x = makearray(2,xdim)); nprotect++; setrownames(x,statenames,2); + fixdimnames(x,dimnms,2); xpp = REAL(x); for (k = 0; k < nvar; k++) xpp[k] = xp[k]; Modified: pkg/pomp/src/pomp_internal.h =================================================================== --- pkg/pomp/src/pomp_internal.h 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/pomp_internal.h 2015-01-06 23:08:15 UTC (rev 1045) @@ -13,7 +13,6 @@ # define MATCHNAMES(X,N,W) (matchnames(GET_NAMES(X),(N),(W))) # define MATCHROWNAMES(X,N,W) (matchnames(GET_ROWNAMES(GET_DIMNAMES(X)),(N),(W))) # define MATCHCOLNAMES(X,N,W) (matchnames(GET_COLNAMES(GET_DIMNAMES(X)),(N),(W))) -# define MATCH_CHAR_TO_ROWNAMES(X,N,A) (match_char_to_names(GET_ROWNAMES(GET_DIMNAMES(X)),(N),(A))) // lookup-table structure, as used internally typedef struct lookup_table { @@ -77,27 +76,25 @@ void unset_pomp_userdata (void); static R_INLINE SEXP makearray (int rank, int *dim) { - int nprotect = 0; int *dimp, k; double *xp; SEXP dimx, x; - PROTECT(dimx = NEW_INTEGER(rank)); nprotect++; + PROTECT(dimx = NEW_INTEGER(rank)); dimp = INTEGER(dimx); for (k = 0; k < rank; k++) dimp[k] = dim[k]; - PROTECT(x = allocArray(REALSXP,dimx)); nprotect++; + PROTECT(x = allocArray(REALSXP,dimx)); xp = REAL(x); for (k = 0; k < length(x); k++) xp[k] = NA_REAL; - UNPROTECT(nprotect); + UNPROTECT(2); return x; } static R_INLINE SEXP matchnames (SEXP x, SEXP names, const char *where) { - int nprotect = 0; int n = length(names); int *idx, k; SEXP index, nm; - PROTECT(nm = AS_CHARACTER(names)); nprotect++; - PROTECT(index = match(x,names,0)); nprotect++; + PROTECT(nm = AS_CHARACTER(names)); + PROTECT(index = match(x,names,0)); idx = INTEGER(index); for (k = 0; k < n; k++) { if (idx[k]==0) @@ -106,31 +103,10 @@ where); idx[k] -= 1; } - UNPROTECT(nprotect); + UNPROTECT(2); return index; } -static R_INLINE SEXP match_char_to_names (SEXP x, int n, char **names) { - int nprotect = 0; - int *idx, k; - SEXP index, nm; - PROTECT(nm = NEW_CHARACTER(n)); nprotect++; - for (k = 0; k < n; k++) { - SET_STRING_ELT(nm,k,mkChar(names[k])); - } - PROTECT(index = match(x,nm,0)); nprotect++; - idx = INTEGER(index); - for (k = 0; k < n; k++) { - if (idx[k]==0) { - UNPROTECT(nprotect); - error("variable %s not specified",names[k]); - } - idx[k] -= 1; - } - UNPROTECT(nprotect); - return index; -} - static R_INLINE SEXP name_index (SEXP names, SEXP object, const char *slot) { SEXP slotnames, index; PROTECT(slotnames = GET_SLOT(object,install(slot))); @@ -144,12 +120,27 @@ } static R_INLINE void setrownames (SEXP x, SEXP names, int n) { - int nprotect = 0; SEXP dimnms, nm; - PROTECT(nm = AS_CHARACTER(names)); nprotect++; - PROTECT(dimnms = allocVector(VECSXP,n)); nprotect++; + PROTECT(nm = AS_CHARACTER(names)); + PROTECT(dimnms = allocVector(VECSXP,n)); SET_ELEMENT(dimnms,0,nm); // set row names SET_DIMNAMES(x,dimnms); + UNPROTECT(2); +} + +static R_INLINE void fixdimnames (SEXP x, const char **names, int n) { + int nprotect = 0; + int i; + SEXP dimnames, nm; + PROTECT(dimnames = GET_DIMNAMES(x)); nprotect++; + if (isNull(dimnames)) { + PROTECT(dimnames = allocVector(VECSXP,n)); nprotect++; + } + PROTECT(nm = allocVector(VECSXP,n)); nprotect++; + for (i = 0; i < n; i++) + SET_ELEMENT(nm,i,mkChar(names[i])); + SET_NAMES(dimnames,nm); + SET_DIMNAMES(x,dimnames); UNPROTECT(nprotect); } Modified: pkg/pomp/src/rmeasure.c =================================================================== --- pkg/pomp/src/rmeasure.c 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/rmeasure.c 2015-01-06 23:08:15 UTC (rev 1045) @@ -61,8 +61,10 @@ { int dim[3] = {nobs, nreps, ntimes}; + const char *dimnm[3] = {"variable","rep","time"}; PROTECT(Y = makearray(3,dim)); nprotect++; setrownames(Y,Onames,3); + fixdimnames(Y,dimnm,3); } // extract the user-defined function Modified: pkg/pomp/src/rprior.c =================================================================== --- pkg/pomp/src/rprior.c 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/rprior.c 2015-01-06 23:08:15 UTC (rev 1045) @@ -20,6 +20,7 @@ SEXP Pnames, P, fn, fcall; SEXP pompfun; int *dim; + const char *dimnms[2] = {"variable","rep"}; PROTECT(params = as_matrix(params)); nprotect++; dim = INTEGER(GET_DIM(params)); @@ -144,5 +145,6 @@ } UNPROTECT(nprotect); + fixdimnames(P,dimnms,2); return P; } Modified: pkg/pomp/src/rprocess.c =================================================================== --- pkg/pomp/src/rprocess.c 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/rprocess.c 2015-01-06 23:08:15 UTC (rev 1045) @@ -14,6 +14,7 @@ int *xdim, nvars, npars, nreps, nrepsx, ntimes, off; SEXP X, Xoff, copy, fn, fcall, rho; SEXP dimXstart, dimP, dimX; + const char *dimnm[3] = {"variable","rep","time"}; PROTECT(gnsi = duplicate(gnsi)); nprotect++; @@ -113,10 +114,12 @@ xdim[2] -= off; PROTECT(Xoff = makearray(3,xdim)); nprotect++; setrownames(Xoff,GET_ROWNAMES(GET_DIMNAMES(X)),3); + fixdimnames(Xoff,dimnm,3); memcpy(REAL(Xoff),REAL(X)+off*nvars*nreps,(ntimes-off)*nvars*nreps*sizeof(double)); UNPROTECT(nprotect); return Xoff; } else { + fixdimnames(X,dimnm,3); UNPROTECT(nprotect); return X; } Modified: pkg/pomp/src/skeleton.c =================================================================== --- pkg/pomp/src/skeleton.c 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/src/skeleton.c 2015-01-06 23:08:15 UTC (rev 1045) @@ -131,8 +131,10 @@ // set up the array to hold results { int dim[3] = {nvars, nreps, ntimes}; + const char *dimnms[3] = {"variable","rep","time"}; PROTECT(F = makearray(3,dim)); nprotect++; setrownames(F,Snames,3); + fixdimnames(F,dimnms,3); } // first do setup Modified: pkg/pomp/tests/bbs-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/bbs-trajmatch.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -80,4 +80,4 @@ > > proc.time() user system elapsed - 2.725 0.017 2.733 + 2.480 0.052 2.555 Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/bbs.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -69,4 +69,4 @@ > > proc.time() user system elapsed - 7.769 0.051 7.832 + 7.008 0.076 7.124 Modified: pkg/pomp/tests/blowflies.Rout.save =================================================================== --- pkg/pomp/tests/blowflies.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/blowflies.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -24,45 +24,47 @@ blowflies1 blowflies2 > > init.state(blowflies1) - [,1] -N1 397.0 -N2 450.5 -N3 504.0 -N4 590.0 -N5 676.0 -N6 738.5 -N7 801.0 -N8 829.5 -N9 858.0 -N10 884.5 -N11 911.0 -N12 926.5 -N13 942.0 -N14 945.0 -N15 948.0 -R 0.0 -S 0.0 -e 0.0 -eps 0.0 + rep +variable [,1] + N1 397.0 + N2 450.5 + N3 504.0 + N4 590.0 + N5 676.0 + N6 738.5 + N7 801.0 + N8 829.5 + N9 858.0 + N10 884.5 + N11 911.0 + N12 926.5 + N13 942.0 + N14 945.0 + N15 948.0 + R 0.0 + S 0.0 + e 0.0 + eps 0.0 > x1 <- simulate(blowflies1) > f1 <- pfilter(blowflies1,Np=1000,seed=599688L) > logLik(f1) [1] -1466.694 > > init.state(blowflies2) - [,1] -N1 397 -N2 504 -N3 676 -N4 801 -N5 858 -N6 911 -N7 942 -N8 948 -R 0 -S 0 -e 0 -eps 0 + rep +variable [,1] + N1 397 + N2 504 + N3 676 + N4 801 + N5 858 + N6 911 + N7 942 + N8 948 + R 0 + S 0 + e 0 + eps 0 > x2 <- simulate(blowflies2) > f2 <- pfilter(blowflies2,Np=1000,seed=599688L) > logLik(f2) @@ -70,4 +72,4 @@ > > proc.time() user system elapsed - 1.493 0.039 1.519 + 1.304 0.044 1.380 Modified: pkg/pomp/tests/dacca.Rout.save =================================================================== --- pkg/pomp/tests/dacca.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/dacca.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -107,4 +107,4 @@ > > proc.time() user system elapsed - 14.817 0.035 14.853 + 10.852 0.064 10.968 Modified: pkg/pomp/tests/dimchecks.Rout.save =================================================================== --- pkg/pomp/tests/dimchecks.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/dimchecks.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -29,19 +29,22 @@ > pars <- coef(po) > xstart <- init.state(po,params=pars) > rprocess(po,xstart,times=0:5,params=pars)[,1,] - [,1] [,2] [,3] [,4] [,5] [,6] -N 7 0.4578051 11.78599703 0.004766933 0.2732487 14.6301023 -e 0 0.4727782 -0.09397106 0.173032749 0.2534460 0.4537029 + time +variable [,1] [,2] [,3] [,4] [,5] [,6] + N 7 0.4578051 11.78599703 0.004766933 0.2732487 14.6301023 + e 0 0.4727782 -0.09397106 0.173032749 0.2534460 0.4537029 > > rprocess(po,xstart=parmat(xstart,5),times=0:5,params=pars)[,3,] - [,1] [,2] [,3] [,4] [,5] [,6] -N 7 0.1788532 8.0265735 0.11906954 4.1101032 4.7809853 -e 0 -0.4671001 0.1828009 0.01576817 -0.1394347 0.4613017 + time +variable [,1] [,2] [,3] [,4] [,5] [,6] + N 7 0.1788532 8.0265735 0.11906954 4.1101032 4.7809853 + e 0 -0.4671001 0.1828009 0.01576817 -0.1394347 0.4613017 > > rprocess(po,xstart=xstart,times=0:5,params=parmat(pars,3))[,3,] - [,1] [,2] [,3] [,4] [,5] [,6] -N 7 0.3200483 7.9793435 0.1061246 6.3880659 0.5943893 -e 0 0.1148066 -0.2638123 -0.1406537 0.4036972 0.2134135 + time +variable [,1] [,2] [,3] [,4] [,5] [,6] + N 7 0.3200483 7.9793435 0.1061246 6.3880659 0.5943893 + e 0 0.1148066 -0.2638123 -0.1406537 0.4036972 0.2134135 > > try( + rprocess(po,xstart=parmat(xstart,2),times=0:5,params=parmat(pars,3))[,,3] @@ -50,9 +53,10 @@ rprocess error: larger number of replicates is not a multiple of smaller > > rprocess(po,xstart=parmat(xstart,2),times=0:5,params=parmat(pars,6))[,,3] - [,1] [,2] [,3] [,4] [,5] [,6] -N 11.4232929 11.3881039 4.8636396 7.1427117 9.4874566 9.65359657 -e 0.1987878 0.2241485 -0.5425199 -0.1655866 0.2008968 -0.09235699 + rep +variable [,1] [,2] [,3] [,4] [,5] [,6] + N 11.4232929 11.3881039 4.8636396 7.1427117 9.4874566 9.65359657 + e 0.1987878 0.2241485 -0.5425199 -0.1655866 0.2008968 -0.09235699 > > x <- rprocess(po,xstart=parmat(xstart,2),times=0:5,params=parmat(pars,8)) > @@ -68,72 +72,85 @@ > rmeasure(po,x=x,params=parmat(pars,4),times=0:5) , , 1 - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] -y 95 77 70 84 75 65 55 73 + rep +variable [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] + y 95 77 70 84 75 65 55 73 , , 2 - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] -y 6 2 4 9 3 1 2 1 + rep +variable [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] + y 6 2 4 9 3 1 2 1 , , 3 - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] -y 107 67 95 99 74 54 36 74 + rep +variable [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] + y 107 67 95 99 74 54 36 74 , , 4 - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] -y 0 7 0 0 1 4 10 5 + rep +variable [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] + y 0 7 0 0 1 4 10 5 , , 5 - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] -y 7 178 14 1 82 190 200 88 + rep +variable [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] + y 7 178 14 1 82 190 200 88 , , 6 - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] -y 216 0 190 106 1 0 0 0 + rep +variable [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] + y 216 0 190 106 1 0 0 0 > > x <- rprocess(po,xstart=xstart,times=0:5,params=pars) > rmeasure(po,x=x,params=parmat(pars,2),times=0:5) , , 1 - [,1] [,2] -y 79 73 + rep +variable [,1] [,2] + y 79 73 , , 2 - [,1] [,2] -y 1 1 + rep +variable [,1] [,2] + y 1 1 , , 3 - [,1] [,2] -y 73 51 + rep +variable [,1] [,2] + y 73 51 , , 4 - [,1] [,2] -y 10 12 + rep +variable [,1] [,2] + y 10 12 , , 5 - [,1] [,2] -y 193 186 + rep +variable [,1] [,2] + y 193 186 , , 6 - [,1] [,2] -y 0 0 + rep +variable [,1] [,2] + y 0 0 > > y <- rmeasure(po,x=x,params=parmat(pars,4),times=0:5) > dmeasure(po,x=x,y=y[,2,,drop=F],params=pars,times=0:5) - [,1] [,2] [,3] [,4] [,5] [,6] -[1,] 0.002350788 0.268881 0.04825714 0.1309304 0.02090266 0.9998435 + time +rep [,1] [,2] [,3] [,4] [,5] [,6] + [1,] 0.002350788 0.268881 0.04825714 0.1309304 0.02090266 0.9998435 > > x <- rprocess(po,xstart=parmat(xstart,3),times=0:5,params=pars) > y <- rmeasure(po,x=x,params=pars,times=0:5) @@ -162,4 +179,4 @@ > > proc.time() user system elapsed - 0.489 0.041 0.517 + 0.560 0.092 0.677 Modified: pkg/pomp/tests/fhn.Rout.save =================================================================== --- pkg/pomp/tests/fhn.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/fhn.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -44,15 +44,17 @@ > skeleton(fhn,x,t=c(0,3),params=params) , , 1 - [,1] [,2] -V -0.40 -6.666667 -R -0.05 0.100000 + rep +variable [,1] [,2] + V -0.40 -6.666667 + R -0.05 0.100000 , , 2 - [,1] [,2] -V 0.9333333 5.0 -R 0.4500000 0.2 + rep +variable [,1] [,2] + V 0.9333333 5.0 + R 0.4500000 0.2 > y <- trajectory(fhn,params=params,hmax=0.1) > invisible(y[,,599:601]) @@ -91,4 +93,4 @@ > > proc.time() user system elapsed - 0.927 0.060 0.950 + 1.084 0.064 1.285 Modified: pkg/pomp/tests/filtfail.Rout.save =================================================================== --- pkg/pomp/tests/filtfail.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/filtfail.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -116,4 +116,4 @@ > > proc.time() user system elapsed - 0.489 0.053 0.529 + 0.576 0.068 0.660 Modified: pkg/pomp/tests/gillespie.Rout.save =================================================================== --- pkg/pomp/tests/gillespie.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/gillespie.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -131,4 +131,4 @@ > > proc.time() user system elapsed - 2.565 0.041 2.592 + 2.564 0.048 2.635 Modified: pkg/pomp/tests/gompertz.Rout.save =================================================================== --- pkg/pomp/tests/gompertz.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/gompertz.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -133,4 +133,4 @@ > > proc.time() user system elapsed - 1.797 0.038 1.822 + 1.576 0.052 1.652 Modified: pkg/pomp/tests/logistic.Rout.save =================================================================== --- pkg/pomp/tests/logistic.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/logistic.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -76,8 +76,9 @@ + ), + digits=4 + ) - [,1] [,2] [,3] [,4] [,5] -[1,] 0.001204 0.0005132 0.0005411 0.0007547 0.0005974 + time +rep [,1] [,2] [,3] [,4] [,5] + [1,] 0.001204 0.0005132 0.0005411 0.0007547 0.0005974 > > print( + dmeasure( @@ -90,8 +91,9 @@ + ), + digits=4 + ) - [,1] [,2] [,3] [,4] [,5] [,6] -[1,] -7.915 -8.896 -7.992 -8.196 -11.12 -7.946 + time +rep [,1] [,2] [,3] [,4] [,5] [,6] + [1,] -7.915 -8.896 -7.992 -8.196 -11.12 -7.946 > > print( + drop( @@ -122,4 +124,4 @@ > > proc.time() user system elapsed - 0.874 0.030 0.887 + 0.976 0.052 1.175 Modified: pkg/pomp/tests/ou2-abc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-abc.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-abc.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -131,4 +131,4 @@ > > proc.time() user system elapsed - 11.085 0.055 11.138 + 9.612 0.100 9.906 Modified: pkg/pomp/tests/ou2-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-bsmc.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -59,7 +59,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 3.430529 secs +Time difference of 2.789886 secs > > print( + cbind( @@ -101,4 +101,4 @@ > > proc.time() user system elapsed - 5.498 0.064 5.527 + 4.688 0.064 4.785 Modified: pkg/pomp/tests/ou2-bsmc2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-bsmc2.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -56,7 +56,7 @@ > post <- smc$post > > print(etime <- toc-tic) -Time difference of 2.234756 secs +Time difference of 2.022153 secs > > print( + cbind( @@ -98,4 +98,4 @@ > > proc.time() user system elapsed - 3.846 0.045 3.881 + 3.588 0.084 3.697 Modified: pkg/pomp/tests/ou2-forecast.Rout.save =================================================================== --- pkg/pomp/tests/ou2-forecast.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-forecast.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -61,4 +61,4 @@ > > proc.time() user system elapsed - 1.376 0.042 1.402 + 1.420 0.036 1.559 Modified: pkg/pomp/tests/ou2-kalman.Rout.save =================================================================== --- pkg/pomp/tests/ou2-kalman.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-kalman.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -164,7 +164,7 @@ 117 function evaluations used > toc <- Sys.time() > print(toc-tic) -Time difference of 3.235065 secs +Time difference of 3.309699 secs > tic <- Sys.time() > print(loglik.mle <- -kalm.fit1$value,digits=4) [1] -477.2 @@ -188,4 +188,4 @@ > > proc.time() user system elapsed - 3.769 0.026 3.787 + 3.960 0.044 4.036 Modified: pkg/pomp/tests/ou2-mif-fp.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-mif-fp.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -70,4 +70,4 @@ > > proc.time() user system elapsed - 24.537 0.066 24.614 + 19.413 0.056 19.690 Modified: pkg/pomp/tests/ou2-mif.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-mif.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -281,4 +281,4 @@ > > proc.time() user system elapsed - 13.791 0.053 13.848 + 11.452 0.064 11.704 Modified: pkg/pomp/tests/ou2-mif2.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif2.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-mif2.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -135,4 +135,4 @@ > > proc.time() user system elapsed - 62.157 0.075 62.274 + 49.355 0.040 49.763 Modified: pkg/pomp/tests/ou2-nlf.Rout.save =================================================================== --- pkg/pomp/tests/ou2-nlf.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-nlf.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -85,4 +85,4 @@ > > proc.time() user system elapsed - 5.003 0.037 5.037 + 4.380 0.092 6.425 Modified: pkg/pomp/tests/ou2-pmcmc.Rout.save =================================================================== --- pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-pmcmc.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -114,4 +114,4 @@ > > proc.time() user system elapsed - 26.822 0.042 26.880 + 24.125 0.068 24.493 Modified: pkg/pomp/tests/ou2-probe.Rout.save =================================================================== --- pkg/pomp/tests/ou2-probe.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-probe.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -340,4 +340,4 @@ > > proc.time() user system elapsed - 8.501 0.048 8.545 + 7.892 0.092 8.187 Modified: pkg/pomp/tests/ou2-procmeas.R =================================================================== --- pkg/pomp/tests/ou2-procmeas.R 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-procmeas.R 2015-01-06 23:08:15 UTC (rev 1045) @@ -23,8 +23,8 @@ x <- simulate(po,states=T,params=coef(po)) dp2 <- dprocess(po,x=x,times=time(po),params=coef(po),log=T) dp3 <- dprocess(po,x=x,times=time(po),params=pmat,log=T) -stopifnot(identical(rbind(dp2,dp2,dp2),dp3)) +stopifnot(identical(rbind(dp2,dp2,dp2),unname(dp3))) dm2 <- dmeasure(po,x=x,y=obs(po),times=time(po),params=coef(po),log=T) dm3 <- dmeasure(po,x=x,y=obs(po),times=time(po),params=pmat,log=T) -stopifnot(identical(rbind(dm2,dm2,dm2),dm3)) +stopifnot(identical(rbind(dm2,dm2,dm2),unname(dm3))) Modified: pkg/pomp/tests/ou2-procmeas.Rout.save =================================================================== --- pkg/pomp/tests/ou2-procmeas.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-procmeas.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -46,12 +46,12 @@ > x <- simulate(po,states=T,params=coef(po)) > dp2 <- dprocess(po,x=x,times=time(po),params=coef(po),log=T) > dp3 <- dprocess(po,x=x,times=time(po),params=pmat,log=T) -> stopifnot(identical(rbind(dp2,dp2,dp2),dp3)) +> stopifnot(identical(rbind(dp2,dp2,dp2),unname(dp3))) > > dm2 <- dmeasure(po,x=x,y=obs(po),times=time(po),params=coef(po),log=T) > dm3 <- dmeasure(po,x=x,y=obs(po),times=time(po),params=pmat,log=T) -> stopifnot(identical(rbind(dm2,dm2,dm2),dm3)) +> stopifnot(identical(rbind(dm2,dm2,dm2),unname(dm3))) > > proc.time() user system elapsed - 0.493 0.037 0.495 + 0.408 0.048 0.479 Modified: pkg/pomp/tests/ou2-simulate.Rout.save =================================================================== --- pkg/pomp/tests/ou2-simulate.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-simulate.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -35,7 +35,7 @@ > ou2.sim <- simulate(ou2,params=p,nsim=100,seed=32043858) > toc <- Sys.time() > print(toc-tic) -Time difference of 0.007747889 secs +Time difference of 0.006910086 secs > > coef(ou2,c('x1.0','x2.0')) <- c(-50,50) > @@ -46,4 +46,4 @@ > > proc.time() user system elapsed - 0.501 0.022 0.507 + 0.508 0.040 0.572 Modified: pkg/pomp/tests/ou2-trajmatch.Rout.save =================================================================== --- pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ou2-trajmatch.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -175,4 +175,4 @@ > > proc.time() user system elapsed - 1.740 0.048 1.765 + 1.712 0.060 1.801 Modified: pkg/pomp/tests/partrans.Rout.save =================================================================== --- pkg/pomp/tests/partrans.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/partrans.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -52,4 +52,4 @@ > > proc.time() user system elapsed - 0.492 0.020 0.494 + 0.600 0.060 0.678 Modified: pkg/pomp/tests/pfilter.Rout.save =================================================================== --- pkg/pomp/tests/pfilter.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/pfilter.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -77,4 +77,4 @@ > > proc.time() user system elapsed - 9.887 0.037 9.924 + 8.448 0.080 8.699 Modified: pkg/pomp/tests/pomppomp.Rout.save =================================================================== --- pkg/pomp/tests/pomppomp.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/pomppomp.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -55,4 +55,4 @@ > > proc.time() user system elapsed - 0.489 0.030 0.504 + 0.580 0.064 0.663 Modified: pkg/pomp/tests/prior.Rout.save =================================================================== --- pkg/pomp/tests/prior.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/prior.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -53,18 +53,19 @@ > > stopifnot(all.equal(mean(dprior(po,params=parmat(coef(po),3))),dnorm(x=0,mean=0,sd=5)^4)) > rprior(po,params=coef(po)) - [,1] -alpha.1 -2.2417803 -alpha.2 0.7708391 -alpha.3 -3.2398829 -alpha.4 9.9993334 -sigma.1 3.0000000 -sigma.2 -0.5000000 -sigma.3 2.0000000 -tau 1.0000000 -x1.0 -3.0000000 -x2.0 4.0000000 -alpha.sd 5.0000000 + rep +variable [,1] + alpha.1 -2.2417803 + alpha.2 0.7708391 + alpha.3 -3.2398829 + alpha.4 9.9993334 + sigma.1 3.0000000 + sigma.2 -0.5000000 + sigma.3 2.0000000 + tau 1.0000000 + x1.0 -3.0000000 + x2.0 4.0000000 + alpha.sd 5.0000000 > > coef(po,"alpha.sd") <- 1 > mean(dprior(po,params=rprior(po,params=parmat(coef(po),10000)),log=TRUE))+0.5*(1+log(2*pi))*4 @@ -72,4 +73,4 @@ > > proc.time() user system elapsed - 0.683 0.025 0.694 + 0.736 0.056 0.809 Modified: pkg/pomp/tests/ricker-bsmc.Rout.save =================================================================== --- pkg/pomp/tests/ricker-bsmc.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ricker-bsmc.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -54,4 +54,4 @@ > > proc.time() user system elapsed - 2.571 0.057 2.614 + 2.604 0.072 2.860 Modified: pkg/pomp/tests/ricker-probe.Rout.save =================================================================== --- pkg/pomp/tests/ricker-probe.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ricker-probe.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -297,4 +297,4 @@ > > proc.time() user system elapsed - 13.643 0.070 13.713 + 11.976 0.072 12.278 Modified: pkg/pomp/tests/ricker-spect.Rout.save =================================================================== --- pkg/pomp/tests/ricker-spect.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ricker-spect.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -70,4 +70,4 @@ > > proc.time() user system elapsed - 2.504 0.018 2.511 + 2.284 0.084 3.241 Modified: pkg/pomp/tests/ricker.Rout.save =================================================================== --- pkg/pomp/tests/ricker.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/ricker.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -83,4 +83,4 @@ > > proc.time() user system elapsed - 0.554 0.038 0.579 + 0.704 0.048 0.884 Modified: pkg/pomp/tests/rw2.Rout.save =================================================================== --- pkg/pomp/tests/rw2.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/rw2.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -164,7 +164,7 @@ } y } - + measurement model density, dmeasure = function (y, x, t, params, log, covars, ...) { @@ -177,7 +177,7 @@ f else exp(f) } - + prior simulator, rprior = function not specified prior density, dprior = @@ -342,4 +342,4 @@ > > proc.time() user system elapsed - 0.879 0.041 0.908 + 0.992 0.040 1.052 Modified: pkg/pomp/tests/sir.Rout.save =================================================================== --- pkg/pomp/tests/sir.Rout.save 2015-01-06 23:07:54 UTC (rev 1044) +++ pkg/pomp/tests/sir.Rout.save 2015-01-06 23:08:15 UTC (rev 1045) @@ -192,7 +192,7 @@ method = 0L, zeronames = zeronames, tcovar = tcovar, covar = covar, args = pairlist(...), gnsi = .getnativesymbolinfo) } - + process model density, dprocess = function (x, times, params, ..., tcovar, covar, log = FALSE, .getnativesymbolinfo = TRUE) @@ -201,7 +201,7 @@ params = params, tcovar = tcovar, covar = covar, log = log, args = pairlist(...), gnsi = .getnativesymbolinfo) } - + measurement model simulator, rmeasure = function (x, t, params, covars, ...) { @@ -274,7 +274,7 @@ > x <- simulate(po,nsim=3) > toc <- Sys.time() > print(toc-tic) -Time difference of 0.9468338 secs +Time difference of 0.8555272 secs > > pdf(file='sir.pdf') > @@ -291,7 +291,7 @@ > X3 <- trajectory(po,times=t3,hmax=1/52) > toc <- Sys.time() > print(toc-tic) -Time difference of 0.560688 secs +Time difference of 0.5343869 secs > plot(t3,X3['I',1,],type='l') > > f1 <- dprocess( @@ -322,14 +322,16 @@ + params=params + ) > print(h1[c("S","I","R"),,],digits=4) - [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] -S 32161.6 31582.4 32142.21 31758.36 31639.0 32006 31953.5 31666 -I -318.4 -218.9 -88.93 21.52 128.7 218 309.2 403 -R -31855.2 -31375.0 -32064.98 -31792.40 -31780.0 -32236 -32276.8 -32083 - [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] -S 31017.5 29782.5 29443.9 28916.7 27997.1 27494 26434 25448 -I 518.5 675.3 768.6 868.8 996.8 1074 1187 1278 -R -31549.7 -30472.3 -30226.0 -29798.8 -29007.2 -28580 -27634 -26740 + time +variable [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] + S 32161.6 31582.4 32142.21 31758.36 31639.0 32006 31953.5 31666 + I -318.4 -218.9 -88.93 21.52 128.7 218 309.2 403 + R -31855.2 -31375.0 -32064.98 -31792.40 -31780.0 -32236 -32276.8 -32083 + time +variable [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] + S 31017.5 29782.5 29443.9 28916.7 27997.1 27494 26434 25448 + I 518.5 675.3 768.6 868.8 996.8 1074 1187 1278 [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1045 From noreply at r-forge.r-project.org Wed Jan 7 04:26:44 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Jan 2015 04:26:44 +0100 (CET) Subject: [Pomp-commits] r1046 - in pkg/pomp: . R inst man Message-ID: <20150107032644.8F026187270@r-forge.r-project.org> Author: kingaa Date: 2015-01-07 04:26:44 +0100 (Wed, 07 Jan 2015) New Revision: 1046 Modified: pkg/pomp/DESCRIPTION pkg/pomp/NAMESPACE pkg/pomp/R/builder.R pkg/pomp/R/generics.R pkg/pomp/R/pomp-class.R pkg/pomp/R/pomp.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/pomp.Rd Log: - new 'pompLoad' and 'pompUnload' convenience functions for working with shared-object files associated with pomps Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/DESCRIPTION 2015-01-07 03:26:44 UTC (rev 1046) @@ -1,7 +1,7 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.57-2 +Version: 0.58-1 Date: 2015-01-06 Authors at R: c(person(given=c("Aaron","A."),family="King", role=c("aut","cre"),email="kingaa at umich.edu"), Modified: pkg/pomp/NAMESPACE =================================================================== --- pkg/pomp/NAMESPACE 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/NAMESPACE 2015-01-07 03:26:44 UTC (rev 1046) @@ -56,6 +56,7 @@ exportMethods( pomp, plot,show,print,coerce,summary,logLik,window,"$", + pompLoad,pompUnload, dprocess,rprocess,rmeasure,dmeasure,init.state,skeleton, dprior,rprior, data.array,obs,partrans,coef,"coef<-", Modified: pkg/pomp/R/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/R/builder.R 2015-01-07 03:26:44 UTC (rev 1046) @@ -46,8 +46,11 @@ globals=globals, link=link, save=save - ) -> name + ) -> bret + name <- bret[1] + solib <- bret[2] + pomp( data=data, times=times, @@ -71,19 +74,26 @@ paramnames=paramnames, tcovar=tcovar, covar=covar, - ... + ..., + .solibfile=solib ) } -pompLink <- function (name) { - solib <- paste0(name,.Platform$dynlib.ext) - dyn.load(solib) -} +setMethod("pompLoad", + signature=signature(object='pomp'), + definition = function (object) { + for (lib in object at solibfile) + dyn.load(lib) + invisible(NULL) + }) -pompUnlink <- function (name) { - solib <- paste0(name,.Platform$dynlib.ext) - dyn.unload(solib) -} +setMethod("pompUnload", + signature=signature(object='pomp'), + definition = function (object) { + for (lib in object at solibfile) + dyn.unload(lib) + invisible(NULL) + }) define <- list( var="#define {%variable%}\t({%ptr%}[{%ilist%}[{%index%}]])\n", @@ -295,15 +305,9 @@ cat("model codes written to",sQuote(modelfile), "\nlink to shared-object library",sQuote(solib),"\n") - if (link) { - if (save) { - pompLink(name) - } else { - pompLink(file.path(tempdir(),name)) - } - } + if (link) dyn.load(solib) - invisible(name) + invisible(c(name,solib)) } cleanForC <- function (text) { @@ -333,3 +337,4 @@ } do.call(paste0,retval) } + Modified: pkg/pomp/R/generics.R =================================================================== --- pkg/pomp/R/generics.R 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/R/generics.R 2015-01-07 03:26:44 UTC (rev 1046) @@ -88,3 +88,7 @@ ## continue an iteration setGeneric("continue",function(object,...)standardGeneric("continue")) + +## dynamic loading and unloading +setGeneric("pompLoad",function(object,...)standardGeneric("pompLoad")) +setGeneric("pompUnload",function(object,...)standardGeneric("pompUnload")) Modified: pkg/pomp/R/pomp-class.R =================================================================== --- pkg/pomp/R/pomp-class.R 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/R/pomp-class.R 2015-01-07 03:26:44 UTC (rev 1046) @@ -34,6 +34,7 @@ has.trans = 'logical', par.trans = 'pomp.fun', par.untrans = 'pomp.fun', + solibfile = 'character', userdata = 'list' ), prototype=prototype( @@ -58,6 +59,7 @@ has.trans=FALSE, par.trans=pomp.fun(), par.untrans=pomp.fun(), + solibfile=character(0), userdata=list() ), validity=function (object) { Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/R/pomp.R 2015-01-07 03:26:44 UTC (rev 1046) @@ -9,14 +9,18 @@ obsnames, statenames, paramnames, covarnames, zeronames, PACKAGE, parameter.transform, parameter.inv.transform, - globals, - userdata) { + globals, userdata, ..., .solibfile) { ## preliminary error checking if (missing(data)) stop(sQuote("data")," is a required argument") if (missing(times)) stop(sQuote("times")," is a required argument") if (missing(t0)) stop(sQuote("t0")," is a required argument") if (missing(params)) params <- numeric(0) + if (missing(.solibfile)) .solibfile <- character(0) + + if (missing(userdata)) userdata <- list() + added.userdata <- list(...) + userdata[names(added.userdata)] <- added.userdata ## name of shared object library if (missing(PACKAGE)) PACKAGE <- NULL @@ -147,10 +151,14 @@ ), silent=FALSE ) - if (inherits(PACKAGE,"try-error")) + if (inherits(PACKAGE,"try-error")) { stop("error in building shared-object library from Csnippets") + } else { + .solibfile <- c(.solibfile,libname[2L]) + libname <- libname[1L] + } } else { - libname <- "" + libname <- '' } ## handle rprocess @@ -363,6 +371,7 @@ has.trans = has.trans, par.trans = par.trans, par.untrans = par.untrans, + solibfile = .solibfile, userdata = userdata ) } @@ -483,8 +492,8 @@ rmeasure=rmeasure, dmeasure=dmeasure, measurement.model=measurement.model, - dprior = dprior, - rprior = rprior, + dprior=dprior, + rprior=rprior, skeleton=skeleton, skeleton.type=skeleton.type, skelmap.delta.t=skelmap.delta.t, @@ -501,7 +510,7 @@ parameter.transform=parameter.transform, parameter.inv.transform=parameter.inv.transform, globals=globals, - userdata=list(...) + ... ) } ) @@ -527,8 +536,8 @@ rmeasure=rmeasure, dmeasure=dmeasure, measurement.model=measurement.model, - dprior = dprior, - rprior = rprior, + dprior=dprior, + rprior=rprior, skeleton=skeleton, skeleton.type=skeleton.type, skelmap.delta.t=skelmap.delta.t, @@ -545,7 +554,7 @@ parameter.transform=parameter.transform, parameter.inv.transform=parameter.inv.transform, globals=globals, - userdata=list(...) + ... ) } ) @@ -572,8 +581,8 @@ rmeasure=rmeasure, dmeasure=dmeasure, measurement.model=measurement.model, - dprior = dprior, - rprior = rprior, + dprior=dprior, + rprior=rprior, skeleton=skeleton, skeleton.type=skeleton.type, skelmap.delta.t=skelmap.delta.t, @@ -590,7 +599,7 @@ parameter.transform=parameter.transform, parameter.inv.transform=parameter.inv.transform, globals=globals, - userdata=list(...) + ... ) } ) @@ -659,10 +668,6 @@ } } - userdata <- data at userdata - added.userdata <- list(...) - userdata[names(added.userdata)] <- added.userdata - if (missing(obsnames)) obsnames <- character(0) if (missing(statenames)) statenames <- character(0) if (missing(paramnames)) paramnames <- character(0) @@ -677,8 +682,8 @@ dprocess=dprocess, rmeasure=rmeasure, dmeasure=dmeasure, - dprior = dprior, - rprior = rprior, + dprior=dprior, + rprior=rprior, skeleton=skeleton, skeleton.type=skeleton.type, skelmap.delta.t=skelmap.delta.t, @@ -695,7 +700,8 @@ parameter.inv.transform=par.untrans, params=params, globals=globals, - userdata=userdata + userdata=data at userdata, + ... ) } ) Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/inst/NEWS 2015-01-07 03:26:44 UTC (rev 1046) @@ -1,5 +1,12 @@ _N_e_w_s _f_o_r _p_a_c_k_a_g_e '_p_o_m_p' +_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_8-_1: + + ? A ?pomp? object created with ?Csnippet?s or ?pompBuilder? + will now remember its associated shared-object file, which + can be unloaded and reloaded using the new ?pompUnload? and + ?pompLoad? methods. + _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_7-_1: ? ?simulate? has a new argument, ?include.data?, that when used Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/inst/NEWS.Rd 2015-01-07 03:26:44 UTC (rev 1046) @@ -1,5 +1,10 @@ \name{NEWS} \title{News for package `pomp'} +\section{Changes in \pkg{pomp} version 0.58-1}{ + \itemize{ + \item A \code{pomp} object created with \code{Csnippet}s or \code{pompBuilder} will now remember its associated shared-object file, which can be unloaded and reloaded using the new \code{pompUnload} and \code{pompLoad} methods. + } +} \section{Changes in \pkg{pomp} version 0.57-1}{ \itemize{ \item \code{simulate} has a new argument, \code{include.data}, that when used in conjuncion with \code{as.data.frame=TRUE} will include the actual data in the resulting data frame along with the simulations. Modified: pkg/pomp/man/pomp.Rd =================================================================== --- pkg/pomp/man/pomp.Rd 2015-01-06 23:08:15 UTC (rev 1045) +++ pkg/pomp/man/pomp.Rd 2015-01-07 03:26:44 UTC (rev 1046) @@ -9,6 +9,12 @@ \alias{pomp,pomp-method} \alias{pomp-pomp} \alias{pomp-class} +\alias{pompLoad} +\alias{pompLoad-pomp} +\alias{pompLoad,pomp-method} +\alias{pompUnload} +\alias{pompUnload-pomp} +\alias{pompUnload,pomp-method} \title{Partially-observed Markov process object.} \description{ This function creates a \code{pomp} object, @@ -38,6 +44,8 @@ initializer, rprior, dprior, params, covar, tcovar, obsnames, statenames, paramnames, covarnames, zeronames, PACKAGE, parameter.transform, parameter.inv.transform, globals) +\S4method{pompLoad}{pomp}(object) +\S4method{pompUnload}{pomp}(object) } \arguments{ \item{data, times}{ @@ -185,8 +193,11 @@ \item{globals}{ optional character; C code that will be included in the source for (and therefore hard-coded into) the shared-object library created when the call to \code{pomp} uses \code{Csnippets}. - If no \code{Csnippets} are used, \code{globals} has no effect. + If no \code{Csnippet}s are used, \code{globals} has no effect. } + \item{object}{ + a \code{pomp} object. + } \item{\dots}{ Any additional arguments given to \code{pomp} will be stored in the \code{\link[=pomp-class]{pomp}} object and passed as arguments to each of the basic functions whenever they are evaluated. } @@ -313,6 +324,13 @@ ) } } +\section{Dynamically linked codes}{ + \code{pompLoad} and \code{pompUnload} cause any compiled codes associated with \code{object} to be dynamically linked or unlinked, respectively. + When + \code{Csnippet}s are used in the construction of a \code{pomp} object, the resulting shared-object library is dynamically loaded (linked) at the time of its construction. + A subsequent call to \code{pompUnload} will unload the shared object library; + it can afterward be reloaded via a call to \code{pompLoad}. +} \section{Warning}{ Some error checking is done by \code{pomp}, but complete error checking is impossible. If the user-specified functions do not conform to the above specifications (see Details), then the results may be invalid. From noreply at r-forge.r-project.org Wed Jan 7 11:54:30 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 7 Jan 2015 11:54:30 +0100 (CET) Subject: [Pomp-commits] r1047 - in pkg/pomp: . R inst man Message-ID: <20150107105430.12A54184950@r-forge.r-project.org> Author: kingaa Date: 2015-01-07 11:54:29 +0100 (Wed, 07 Jan 2015) New Revision: 1047 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/builder.R pkg/pomp/R/pomp.R pkg/pomp/inst/NEWS pkg/pomp/inst/NEWS.Rd pkg/pomp/man/pomp.Rd Log: - compiler messages are now suppressed by default - pomp, pompCBuilder, pompLoad, and pompUnload all have new 'verbose' option Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-07 03:26:44 UTC (rev 1046) +++ pkg/pomp/DESCRIPTION 2015-01-07 10:54:29 UTC (rev 1047) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-1 -Date: 2015-01-06 +Version: 0.58-2 +Date: 2015-01-07 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/builder.R =================================================================== --- pkg/pomp/R/builder.R 2015-01-07 03:26:44 UTC (rev 1046) +++ pkg/pomp/R/builder.R 2015-01-07 10:54:29 UTC (rev 1047) @@ -79,20 +79,34 @@ ) } +pompLoad.internal <- function (object, ..., + verbose = getOption("verbose",FALSE)) { + for (lib in object at solibfile) { + if (verbose) cat("loading",sQuote(lib),"\n") + dyn.load(lib) + } + invisible(NULL) +} + +pompUnload.internal <- function (object, ..., + verbose = getOption("verbose",FALSE)) { + for (lib in object at solibfile) { + if (verbose) cat("unloading",sQuote(lib),"\n") + dyn.unload(lib) + } + invisible(NULL) +} + setMethod("pompLoad", signature=signature(object='pomp'), - definition = function (object) { - for (lib in object at solibfile) - dyn.load(lib) - invisible(NULL) + definition = function (object, ...) { + pompLoad.internal(object,...) }) setMethod("pompUnload", signature=signature(object='pomp'), - definition = function (object) { - for (lib in object at solibfile) - dyn.unload(lib) - invisible(NULL) + definition = function (object, ...) { + pompUnload.internal(object,...) }) define <- list( @@ -161,7 +175,8 @@ pompCBuilder <- function (name, statenames, paramnames, covarnames, obsnames, rmeasure, dmeasure, step.fn, skeleton, parameter.transform, parameter.inv.transform, - rprior, dprior, globals, save = FALSE, link = TRUE) + rprior, dprior, globals, save = FALSE, link = TRUE, + verbose = getOption("verbose",FALSE)) { if (missing(name)) @@ -297,11 +312,12 @@ rv <- system2( command=R.home("bin/R"), args=c("CMD","SHLIB","-o",solib,modelfile), - env=cflags + env=cflags, + stdout=if (verbose) "" else NULL ) if (rv!=0) stop("cannot compile shared-object library ",sQuote(solib)) - else + else if (verbose) cat("model codes written to",sQuote(modelfile), "\nlink to shared-object library",sQuote(solib),"\n") Modified: pkg/pomp/R/pomp.R =================================================================== --- pkg/pomp/R/pomp.R 2015-01-07 03:26:44 UTC (rev 1046) +++ pkg/pomp/R/pomp.R 2015-01-07 10:54:29 UTC (rev 1047) @@ -9,7 +9,8 @@ obsnames, statenames, paramnames, covarnames, zeronames, PACKAGE, parameter.transform, parameter.inv.transform, - globals, userdata, ..., .solibfile) { + globals, userdata, ..., .solibfile, + verbose = getOption("verbose",FALSE)) { ## preliminary error checking if (missing(data)) stop(sQuote("data")," is a required argument") @@ -144,7 +145,8 @@ covarnames=covarnames, globals=globals, link=TRUE, - save=FALSE + save=FALSE, + verbose=verbose ), snips ) Modified: pkg/pomp/inst/NEWS =================================================================== --- pkg/pomp/inst/NEWS 2015-01-07 03:26:44 UTC (rev 1046) +++ pkg/pomp/inst/NEWS 2015-01-07 10:54:29 UTC (rev 1047) @@ -2,6 +2,12 @@ _C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_8-_1: + ? Compiler messages are now suppressed by default when + ?Csnippet?s are used in construction of a ?pomp? object. + These can be enabled by setting ?options(verbose=TRUE)?. + +_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._5_8-_1: + ? A ?pomp? object created with ?Csnippet?s or ?pompBuilder? will now remember its associated shared-object file, which can be unloaded and reloaded using the new ?pompUnload? and Modified: pkg/pomp/inst/NEWS.Rd =================================================================== --- pkg/pomp/inst/NEWS.Rd 2015-01-07 03:26:44 UTC (rev 1046) +++ pkg/pomp/inst/NEWS.Rd 2015-01-07 10:54:29 UTC (rev 1047) @@ -2,6 +2,12 @@ \title{News for package `pomp'} \section{Changes in \pkg{pomp} version 0.58-1}{ \itemize{ + \item Compiler messages are now suppressed by default when \code{Csnippet}s are used in construction of a \code{pomp} object. + These can be enabled by setting \code{options(verbose=TRUE)}. + } +} +\section{Changes in \pkg{pomp} version 0.58-1}{ + \itemize{ \item A \code{pomp} object created with \code{Csnippet}s or \code{pompBuilder} will now remember its associated shared-object file, which can be unloaded and reloaded using the new \code{pompUnload} and \code{pompLoad} methods. } } Modified: pkg/pomp/man/pomp.Rd =================================================================== --- pkg/pomp/man/pomp.Rd 2015-01-07 03:26:44 UTC (rev 1046) +++ pkg/pomp/man/pomp.Rd 2015-01-07 10:54:29 UTC (rev 1047) @@ -44,8 +44,8 @@ initializer, rprior, dprior, params, covar, tcovar, obsnames, statenames, paramnames, covarnames, zeronames, PACKAGE, parameter.transform, parameter.inv.transform, globals) -\S4method{pompLoad}{pomp}(object) -\S4method{pompUnload}{pomp}(object) +\S4method{pompLoad}{pomp}(object, \dots) +\S4method{pompUnload}{pomp}(object, \dots) } \arguments{ \item{data, times}{ From noreply at r-forge.r-project.org Fri Jan 9 14:03:04 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 9 Jan 2015 14:03:04 +0100 (CET) Subject: [Pomp-commits] r1048 - in pkg/pomp: . R Message-ID: <20150109130304.1D671187819@r-forge.r-project.org> Author: kingaa Date: 2015-01-09 14:03:03 +0100 (Fri, 09 Jan 2015) New Revision: 1048 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/simulate-pomp.R Log: - fix bug with 'simulate' when 'include.data=TRUE' Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-07 10:54:29 UTC (rev 1047) +++ pkg/pomp/DESCRIPTION 2015-01-09 13:03:03 UTC (rev 1048) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-2 -Date: 2015-01-07 +Version: 0.58-3 +Date: 2015-01-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/R/simulate-pomp.R =================================================================== --- pkg/pomp/R/simulate-pomp.R 2015-01-07 10:54:29 UTC (rev 1047) +++ pkg/pomp/R/simulate-pomp.R 2015-01-09 13:03:03 UTC (rev 1048) @@ -79,7 +79,7 @@ as.data.frame(t(retval$obs)), as.data.frame(t(retval$states)) ) - retval$sim <- factor(seq_len(nsim)) + retval$sim <- as.character(seq_len(nsim)) retval$time <- rep(times,each=nsim) retval <- retval[order(retval$sim,retval$time),] } else if (obs || states) { @@ -90,7 +90,7 @@ dim(retval) <- c(dm[1L],prod(dm[-1L])) rownames(retval) <- nm retval <- as.data.frame(t(retval)) - retval$sim <- factor(seq_len(nsim)) + retval$sim <- as.character(seq_len(nsim)) retval$time <- rep(times,each=nsim) retval <- retval[order(retval$sim,retval$time),] } else { @@ -105,18 +105,22 @@ } ) retval <- do.call(rbind,retval) - retval$sim <- factor(retval$sim) + retval$sim <- as.character(retval$sim) } else { retval <- as.data.frame(retval) - retval$sim <- factor(1) + retval$sim <- "1" } } if (include.data) { od <- as.data.frame(object) - retval <- merge(od,retval,sort=FALSE) + od$sim <- "data" + od <- od[names(retval)] + retval <- rbind(od,retval) } - + + retval$sim <- factor(retval$sim) + } retval From noreply at r-forge.r-project.org Sat Jan 10 13:36:12 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 10 Jan 2015 13:36:12 +0100 (CET) Subject: [Pomp-commits] r1049 - in pkg/pomp: . R src Message-ID: <20150110123612.759C2187896@r-forge.r-project.org> Author: kingaa Date: 2015-01-10 13:36:12 +0100 (Sat, 10 Jan 2015) New Revision: 1049 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/pfilter.R pkg/pomp/src/pfilter.c Log: - attach names to dimnames of states and parameter arrays in pfilter computations Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-09 13:03:03 UTC (rev 1048) +++ pkg/pomp/DESCRIPTION 2015-01-10 12:36:12 UTC (rev 1049) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-3 -Date: 2015-01-09 +Version: 0.58-4 +Date: 2015-01-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/R/pfilter.R =================================================================== --- pkg/pomp/R/pfilter.R 2015-01-09 13:03:03 UTC (rev 1048) +++ pkg/pomp/R/pfilter.R 2015-01-10 12:36:12 UTC (rev 1049) @@ -301,10 +301,12 @@ if (save.states) { xparticles[[nt]] <- x + dimnames(xparticles[[nt]]) <- setNames(dimnames(xparticles[[nt]]),c("variable","rep")) } if (save.params) { pparticles[[nt]] <- params + dimnames(pparticles[[nt]]) <- setNames(dimnames(pparticles[[nt]]),c("variable","rep")) } if (verbose && (nt%%5==0)) Modified: pkg/pomp/src/pfilter.c =================================================================== --- pkg/pomp/src/pfilter.c 2015-01-09 13:03:03 UTC (rev 1048) +++ pkg/pomp/src/pfilter.c 2015-01-10 12:36:12 UTC (rev 1049) @@ -59,6 +59,7 @@ SEXP rw_names, ess, fail, loglik; SEXP newstates = R_NilValue, newparams = R_NilValue; SEXP retval, retvalnames; + const char *dimnm[2] = {"variable","rep"}; double *xpm = 0, *xpv = 0, *xfm = 0, *xw = 0, *xx = 0, *xp = 0; SEXP dimX, dimP, newdim, Xnames, Pnames, pindex; int *dim, *pidx, lv, np; @@ -225,6 +226,7 @@ xdim[0] = nvars; xdim[1] = np; PROTECT(newstates = makearray(2,xdim)); nprotect++; setrownames(newstates,Xnames,2); + fixdimnames(newstates,dimnm,2); ss = REAL(x); st = REAL(newstates); @@ -233,6 +235,7 @@ xdim[0] = npars; xdim[1] = np; PROTECT(newparams = makearray(2,xdim)); nprotect++; setrownames(newparams,Pnames,2); + fixdimnames(newparams,dimnm,2); ps = REAL(params); pt = REAL(newparams); } @@ -255,6 +258,7 @@ dim[0] = nvars; dim[1] = nreps; SET_DIM(x,newdim); setrownames(x,Xnames,2); + fixdimnames(x,dimnm,2); } From noreply at r-forge.r-project.org Thu Jan 22 17:10:29 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 22 Jan 2015 17:10:29 +0100 (CET) Subject: [Pomp-commits] r1050 - in pkg/pomp: . R tests Message-ID: <20150122161029.988C218596C@r-forge.r-project.org> Author: kingaa Date: 2015-01-22 17:10:29 +0100 (Thu, 22 Jan 2015) New Revision: 1050 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/simulate-pomp.R pkg/pomp/tests/bbs.R pkg/pomp/tests/bbs.Rout.save Log: - fix bug in 'simulate' that shows up when 'include.dir=TRUE' Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-10 12:36:12 UTC (rev 1049) +++ pkg/pomp/DESCRIPTION 2015-01-22 16:10:29 UTC (rev 1050) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-4 -Date: 2015-01-10 +Version: 0.58-5 +Date: 2015-01-15 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/simulate-pomp.R =================================================================== --- pkg/pomp/R/simulate-pomp.R 2015-01-10 12:36:12 UTC (rev 1049) +++ pkg/pomp/R/simulate-pomp.R 2015-01-22 16:10:29 UTC (rev 1050) @@ -115,8 +115,7 @@ if (include.data) { od <- as.data.frame(object) od$sim <- "data" - od <- od[names(retval)] - retval <- rbind(od,retval) + retval <- merge(od,retval,all=TRUE) } retval$sim <- factor(retval$sim) Modified: pkg/pomp/tests/bbs.R =================================================================== --- pkg/pomp/tests/bbs.R 2015-01-10 12:36:12 UTC (rev 1049) +++ pkg/pomp/tests/bbs.R 2015-01-22 16:10:29 UTC (rev 1050) @@ -25,3 +25,7 @@ fit3 <- traj.match(bbs,est=c("beta","sigma"),transform=TRUE) signif(coef(fit3),3) + +sim1 <- simulate(bbs,nsim=20,as.data.frame=TRUE,include.data=TRUE) +sim2 <- simulate(bbs,nsim=20,as.data.frame=TRUE,obs=TRUE,include.data=TRUE) +sim3 <- simulate(bbs,nsim=20,as.data.frame=TRUE,states=TRUE,include.data=TRUE) Modified: pkg/pomp/tests/bbs.Rout.save =================================================================== --- pkg/pomp/tests/bbs.Rout.save 2015-01-10 12:36:12 UTC (rev 1049) +++ pkg/pomp/tests/bbs.Rout.save 2015-01-22 16:10:29 UTC (rev 1050) @@ -67,6 +67,10 @@ S.0 I.0 R.0 0.999 0.001 0.000 > +> sim1 <- simulate(bbs,nsim=20,as.data.frame=TRUE,include.data=TRUE) +> sim2 <- simulate(bbs,nsim=20,as.data.frame=TRUE,obs=TRUE,include.data=TRUE) +> sim3 <- simulate(bbs,nsim=20,as.data.frame=TRUE,states=TRUE,include.data=TRUE) +> > proc.time() user system elapsed - 7.008 0.076 7.124 + 7.153 0.049 7.193 From noreply at r-forge.r-project.org Thu Jan 22 17:10:34 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 22 Jan 2015 17:10:34 +0100 (CET) Subject: [Pomp-commits] r1051 - pkg/pomp Message-ID: <20150122161034.8876618596C@r-forge.r-project.org> Author: kingaa Date: 2015-01-22 17:10:34 +0100 (Thu, 22 Jan 2015) New Revision: 1051 Modified: pkg/pomp/DESCRIPTION Log: - the recent changes to pompExample are not compatible with R <=3.1.1 Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-22 16:10:29 UTC (rev 1050) +++ pkg/pomp/DESCRIPTION 2015-01-22 16:10:34 UTC (rev 1051) @@ -2,7 +2,7 @@ Type: Package Title: Statistical Inference for Partially Observed Markov Processes Version: 0.58-5 -Date: 2015-01-15 +Date: 2015-01-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")), @@ -18,7 +18,7 @@ ) URL: http://pomp.r-forge.r-project.org Description: Inference methods for partially observed Markov processes (AKA stochastic dynamical systems, state-space models) -Depends: R(>= 3.0.0), methods, subplex, nloptr +Depends: R(>= 3.1.2), methods, subplex, nloptr Imports: stats, graphics, mvtnorm, deSolve, coda License: GPL(>= 2) LazyData: true From noreply at r-forge.r-project.org Thu Jan 22 17:10:39 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 22 Jan 2015 17:10:39 +0100 (CET) Subject: [Pomp-commits] r1052 - in pkg/pomp: . R Message-ID: <20150122161039.2D9EC18596C@r-forge.r-project.org> Author: kingaa Date: 2015-01-22 17:10:38 +0100 (Thu, 22 Jan 2015) New Revision: 1052 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/example.R Log: - restore compatibility with R>=3.0.0 Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-22 16:10:34 UTC (rev 1051) +++ pkg/pomp/DESCRIPTION 2015-01-22 16:10:38 UTC (rev 1052) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-5 -Date: 2015-01-16 +Version: 0.58-6 +Date: 2015-01-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")), @@ -18,7 +18,7 @@ ) URL: http://pomp.r-forge.r-project.org Description: Inference methods for partially observed Markov processes (AKA stochastic dynamical systems, state-space models) -Depends: R(>= 3.1.2), methods, subplex, nloptr +Depends: R(>= 3.0.0), methods, subplex, nloptr Imports: stats, graphics, mvtnorm, deSolve, coda License: GPL(>= 2) LazyData: true Modified: pkg/pomp/R/example.R =================================================================== --- pkg/pomp/R/example.R 2015-01-22 16:10:34 UTC (rev 1051) +++ pkg/pomp/R/example.R 2015-01-22 16:10:38 UTC (rev 1052) @@ -11,7 +11,11 @@ print(avlbl[[dir]]) } } else { - evalEnv <- list2env(list(...)) +## the following needed from R/3.0.0 to R/3.1.1: + dots <- list(...) + evalEnv <- if (length(dots)>0) list2env(list(...)) else new.env() +## the following will work from R/3.1.2 +## evalEnv <- list2env(list(...)) file <- c(lapply(exampleDirs,list.files, pattern=paste0(example,".R"), full.names=TRUE), From noreply at r-forge.r-project.org Fri Jan 23 15:50:30 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 23 Jan 2015 15:50:30 +0100 (CET) Subject: [Pomp-commits] r1053 - in pkg: . pompExamples pompExamples/inst/examples pompExamples/vignettes Message-ID: <20150123145030.3A82F187946@r-forge.r-project.org> Author: kingaa Date: 2015-01-23 15:50:29 +0100 (Fri, 23 Jan 2015) New Revision: 1053 Added: pkg/pompExamples/inst/examples/bsflu.R pkg/pompExamples/inst/examples/bsflu3.R pkg/pompExamples/vignettes/Makefile pkg/pompExamples/vignettes/bsflu-mf1.rds pkg/pompExamples/vignettes/bsflu-mf3.rds pkg/pompExamples/vignettes/bsflu-tm1.rds pkg/pompExamples/vignettes/bsflu-tm3.rds pkg/pompExamples/vignettes/bsflu.Rmd pkg/pompExamples/vignettes/bsflu.html Modified: pkg/Makefile pkg/pompExamples/DESCRIPTION Log: - add boarding-school flu vignette to the pompExamples package Modified: pkg/Makefile =================================================================== --- pkg/Makefile 2015-01-22 16:10:38 UTC (rev 1052) +++ pkg/Makefile 2015-01-23 14:50:29 UTC (rev 1053) @@ -45,6 +45,9 @@ cp pomp.pdf ../www/vignettes $(RCMD) Rdconv -t html pomp/inst/NEWS.Rd -o ../www/content/NEWS.html +pompExamples.vignettes: pompExamples.install + (cd pompExamples/vignettes; make) + %.data: %.install cd $*/inst/data-R; make Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-22 16:10:38 UTC (rev 1052) +++ pkg/pompExamples/DESCRIPTION 2015-01-23 14:50:29 UTC (rev 1053) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.25-4 -Date: 2015-01-05 +Version: 0.26-1 +Date: 2015-01-23 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), @@ -16,9 +16,10 @@ person(given=c("Helen"),family="Wearing",role=c("ctb"))) URL: http://pomp.r-forge.r-project.org Description: More 'pomp' examples. -Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.56-1) -Suggests: plyr, reshape2 +Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.58-6) +Suggests: plyr, reshape2, knitr, ggplot2 License: GPL (>= 2) LazyData: false BuildVignettes: true +VignetteBuilder: knitr Collate: aaa.R pertussis.R Added: pkg/pompExamples/inst/examples/bsflu.R =================================================================== --- pkg/pompExamples/inst/examples/bsflu.R (rev 0) +++ pkg/pompExamples/inst/examples/bsflu.R 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1,109 @@ +## data read from graph in Anonymous (1978) 'Influenza in a boarding school' Brit. Med. J. 1:578. +## cases are recorded with error of +/- 1 case +## 763 boys were at risk, 512 boys spent time away from class +flu <- read.csv(text=" +date,confined,convalescent +1978-01-22,1,0 +1978-01-23,6,0 +1978-01-24,26,0 +1978-01-25,73,1 +1978-01-26,222,8 +1978-01-27,293,16 +1978-01-28,258,99 +1978-01-29,236,160 +1978-01-30,191,173 +1978-01-31,124,162 +1978-02-01,69,150 +1978-02-02,26,89 +1978-02-03,11,44 +1978-02-04,4,22 +",colClasses=c(date='Date')) +flu$day <- flu$date-min(flu$date)+1 +units(flu$day) <- "days" +flu$day <- as.numeric(flu$day) + +partrans <- " + TBeta = exp(Beta); + Tinf_pd = exp(inf_pd); + Trho = expit(rho); + Tsfrac = expit(sfrac); +" + +paruntrans <- " + TBeta = log(Beta); + Tinf_pd = log(inf_pd); + Trho = logit(rho); + Tsfrac = logit(sfrac); +" + +dmeas <- " + lik = dpois(confined,rho*R+1e-6,give_log); +" + +rmeas <- " + confined = rpois(rho*R+1e-6); + convalescent = rpois(rho*C); +" + +stochsim <- " + double t1 = rbinom(S,1-exp(-Beta*I*dt)); + double t2 = rbinom(I,1-exp(-dt/inf_pd)); + double t3 = rbinom(R,1-exp(-dt/conf_pd)); + double t4 = rbinom(C,1-exp(-dt/conv_pd)); + S -= t1; + I += t1 - t2; + R += t2 - t3; + C += t3 - t4; +" + +skel <- " + double dt = 1.0/24.0; + double t1 = S*(1-exp(-Beta*I*dt)); + double t2 = I*(1-exp(-dt/inf_pd)); + double t3 = R*(1-exp(-dt/conf_pd)); + double t4 = C*(1-exp(-dt/conv_pd)); + DS = S - t1; + DI = I + t1 - t2; + DR = R + t2 - t3; + DC = C + t3 - t4; +" + +pomp( + data=flu[c("day","confined","convalescent")], + times="day", + t0=0, + params=c( + Beta=0.004, + inf.pd=0.7, + conf.pd=sum(flu$confined)/512, + conv.pd=sum(flu$convalescent)/512, + rho=0.9, + sfrac=762/763 + ), + rprocess=euler.sim( + step.fun=Csnippet(stochsim), + delta.t=1/24 + ), + skeleton=Csnippet(skel), + skelmap.delta.t=1/24, + skeleton.type="map", + rmeasure=Csnippet(rmeas), + dmeasure=Csnippet(dmeas), + parameter.transform=Csnippet(partrans), + parameter.inv.transform=Csnippet(paruntrans), + obsnames = c("confined","convalescent"), + statenames=c("S","I","R","C"), + paramnames=c( + "Beta", + "inf.pd","conf.pd","conv.pd", + "rho","sfrac" + ), + initializer=function(params, t0, ...) { + x0 <- setNames(numeric(4),c("S","I","R","C")) + S.0 <- round(763*params["sfrac"]) + x0[c("S","I")] <- c(S.0,763-S.0) + x0 + } + ) -> bsflu + +c("bsflu") Added: pkg/pompExamples/inst/examples/bsflu3.R =================================================================== --- pkg/pompExamples/inst/examples/bsflu3.R (rev 0) +++ pkg/pompExamples/inst/examples/bsflu3.R 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1,117 @@ +## data read from graph in Anonymous (1978) 'Influenza in a boarding school' Brit. Med. J. 1:578. +## cases are recorded with error of +/- 1 case +## 763 boys were at risk, 512 boys spent time away from class +flu <- read.csv(text=" +date,confined,convalescent +1978-01-22,1,0 +1978-01-23,6,0 +1978-01-24,26,0 +1978-01-25,73,1 +1978-01-26,222,8 +1978-01-27,293,16 +1978-01-28,258,99 +1978-01-29,236,160 +1978-01-30,191,173 +1978-01-31,124,162 +1978-02-01,69,150 +1978-02-02,26,89 +1978-02-03,11,44 +1978-02-04,4,22 +",colClasses=c(date='Date')) +flu$day <- flu$date-min(flu$date)+1 +units(flu$day) <- "days" +flu$day <- as.numeric(flu$day) + +partrans <- " + TBeta = exp(Beta); + Tinf_pd = exp(inf_pd); + Trho = expit(rho); + Tsfrac = expit(sfrac); +" + +paruntrans <- " + TBeta = log(Beta); + Tinf_pd = log(inf_pd); + Trho = logit(rho); + Tsfrac = logit(sfrac); +" + +dmeas <- " + lik = dpois(confined,rho*(R1+R2+R3)+1e-6,give_log); +" + +rmeas <- " + confined = rpois(rho*(R1+R2+R3)+1e-6); + convalescent = rpois(rho*C); +" + +stochsim <- " + double t1 = rbinom(S,1-exp(-Beta*I*dt)); + double t2 = rbinom(I,1-exp(-dt/inf_pd)); + double t3a = rbinom(R1,1-exp(-3*dt/conf_pd)); + double t3b = rbinom(R2,1-exp(-3*dt/conf_pd)); + double t3c = rbinom(R3,1-exp(-3*dt/conf_pd)); + double t4 = rbinom(C,1-exp(-dt/conv_pd)); + S -= t1; + I += t1 - t2; + R1 += t2 - t3a; + R2 += t3a - t3b; + R3 += t3b - t3c; + C += t3c - t4; +" + +skel <- " + double dt = 1.0/24.0; + double t1 = S*(1-exp(-Beta*I*dt)); + double t2 = I*(1-exp(-dt/inf_pd)); + double t3a = R1*(1-exp(-3*dt/conf_pd)); + double t3b = R2*(1-exp(-3*dt/conf_pd)); + double t3c = R3*(1-exp(-3*dt/conf_pd)); + double t4 = C*(1-exp(-dt/conv_pd)); + DS = S - t1; + DI = I + t1 - t2; + DR1 = R1 + t2 - t3a; + DR2 = R2 + t3a - t3b; + DR3 = R3 + t3b - t3c; + DC = C + t3c - t4; +" + +pomp( + data=flu[c("day","confined","convalescent")], + times="day", + t0=0, + params=c( + Beta=0.004, + inf.pd=0.7, + conf.pd=sum(flu$confined)/512, + conv.pd=sum(flu$convalescent)/512, + rho=0.9, + sfrac=762/763 + ), + rprocess=euler.sim( + step.fun=Csnippet(stochsim), + delta.t=1/24 + ), + skeleton=Csnippet(skel), + skelmap.delta.t=1/24, + skeleton.type="map", + rmeasure=Csnippet(rmeas), + dmeasure=Csnippet(dmeas), + parameter.transform=Csnippet(partrans), + parameter.inv.transform=Csnippet(paruntrans), + obsnames = c("confined","convalescent"), + statenames=c("S","I","R1","R2","R3","C"), + paramnames=c( + "Beta", + "inf.pd","conf.pd","conv.pd", + "rho","sfrac" + ), + initializer=function(params, t0, ...) { + x0 <- setNames(numeric(6),c("S","I","R1","R2","R3","C")) + S.0 <- round(763*params["sfrac"]) + x0[c("S","I")] <- c(S.0,763-S.0) + x0 + } + ) -> bsflu3 + +c("bsflu3") Added: pkg/pompExamples/vignettes/Makefile =================================================================== --- pkg/pompExamples/vignettes/Makefile (rev 0) +++ pkg/pompExamples/vignettes/Makefile 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1,10 @@ +RSCRIPT = Rscript --vanilla +RM = rm -f + +vignettes: bsflu.html + $(RM) -r figure + +%.html: %.Rmd + $(RSCRIPT) -e 'knitr::knit("$*.Rmd")' + $(RSCRIPT) -e 'markdown::markdownToHTML("$*.md","$*.html")' + $(RM) $*.md Added: pkg/pompExamples/vignettes/bsflu-mf1.rds =================================================================== --- pkg/pompExamples/vignettes/bsflu-mf1.rds (rev 0) +++ pkg/pompExamples/vignettes/bsflu-mf1.rds 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1 @@ +???b```b`fdb`b2????1???m[Y{`|?o?n??M?? ??nJ??????5?w?`???????!???Fy????:??e``a?X8?4k^bnj1?!vD?-'?='3??????S?,N?%?0??yiz)P{r>:? ?e.???Y[?V???????r=?{xA??$????s?a?? r?$?$???M?????&~ \ No newline at end of file Added: pkg/pompExamples/vignettes/bsflu-mf3.rds =================================================================== --- pkg/pompExamples/vignettes/bsflu-mf3.rds (rev 0) +++ pkg/pompExamples/vignettes/bsflu-mf3.rds 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1,4 @@ +???b```b`fdb`b2????1???|??c?`|?]_??V??????|>?????1???>??C? + ????O????P???? ?( ????? ?Y?sS?? ?? ?l9??9??P'??W? +`qJ-I?)??K?+H???????e.sQF>??????d4?p?????? +? ?????X s4L?+%?$Qhln*??????~ \ No newline at end of file Added: pkg/pompExamples/vignettes/bsflu-tm1.rds =================================================================== --- pkg/pompExamples/vignettes/bsflu-tm1.rds (rev 0) +++ pkg/pompExamples/vignettes/bsflu-tm1.rds 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1 @@ +???b```b`fdb`b2????1????U?F?7`|???ds?'Mu????K?`mm??8P??y??]?,???M8??W????? ,L`?X8?4k^bnj1?!vD?-'?='3??????S?,N?%?0??yiz)P{r>:? ?e.???Y[?V???????r=?{xA??$????s?a?? r?$?$???M??????~ \ No newline at end of file Added: pkg/pompExamples/vignettes/bsflu-tm3.rds =================================================================== --- pkg/pompExamples/vignettes/bsflu-tm3.rds (rev 0) +++ pkg/pompExamples/vignettes/bsflu-tm3.rds 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1,4 @@ +???b```b`fdb`b2????1????*S,Ua|????+?v7???_??x?T? ???!????T?K?F??2p??????CX????0pi?????b C?8? [N~zNf6?? ???BX?RKaJ3??? +R? tm + traj.match(tm,method='subplex') -> tm + data.frame(loglik=logLik(tm),loglik.se=0,as.list(coef(tm))) +}) -> tm1 +``` +```{r tm1-simplot} +simdat <- simulate(bsflu,params=unlist(tm1),nsim=10, + obs=TRUE,as.data.frame=TRUE,include.data=TRUE) +ggplot(data=melt(simdat,id=c("sim","time")), + mapping=aes(x=time,y=value,group=interaction(variable,sim), + color=variable,size=sim=="data",alpha=sim=="data"))+ + geom_line()+ + scale_alpha_manual(values=c(`TRUE`=1,`FALSE`=0.5))+ + scale_size_manual(values=c(`TRUE`=2,`FALSE`=1)) +``` + +### Iterated filtering + +```{r mf1} +juliaChild("bsflu-mf1.rds",{ + mif(bsflu,rw.sd=c(Beta=0.05,inf.pd=0.05,rho=0.05), + cooling.fraction=0.9,var.factor=2, + Nmif=50,Np=1000,method='mif2',transform=TRUE) -> mf + mif(mf,Nmif=50,cooling.fraction=0.5) -> mf + mif(mf,Nmif=50,cooling.fraction=0.1) -> mf + ll <- unname(logmeanexp(raply(5,logLik(pfilter(mf))),se=TRUE)) + data.frame(loglik=ll[1],loglik.se=ll[2],as.list(coef(mf))) +}) -> mf1 +``` +```{r mf1-simplot} +simdat <- simulate(bsflu,params=unlist(mf1),nsim=10, + obs=TRUE,as.data.frame=TRUE,include.data=TRUE) +ggplot(data=melt(simdat,id=c("sim","time")), + mapping=aes(x=time,y=value,group=interaction(variable,sim), + color=variable,size=sim=="data",alpha=sim=="data"))+ + geom_line()+ + scale_alpha_manual(values=c(`TRUE`=1,`FALSE`=0.5))+ + scale_size_manual(values=c(`TRUE`=2,`FALSE`=1)) +``` + +## Model with Erlang(3) confinement period + +```{r bsflu3,cache=FALSE} +pompExample(bsflu3) +coef(bsflu3) +``` +```{r plot3} +simdat <- simulate(bsflu3,nsim=10,obs=TRUE,as.data.frame=TRUE,include.data=TRUE) +ggplot(data=melt(simdat,id=c("sim","time")), + mapping=aes(x=time,y=value,group=interaction(variable,sim), + color=variable,size=sim=="data",alpha=sim=="data"))+ + geom_line()+ + scale_alpha_manual(values=c(`TRUE`=1,`FALSE`=0.5))+ + scale_size_manual(values=c(`TRUE`=2,`FALSE`=1)) +``` + +### Trajectory matching + +```{r tm3} +juliaChild("bsflu-tm3.rds",{ + traj.match(bsflu3,est=c("Beta","inf.pd","rho"),transform=TRUE) -> tm + traj.match(tm,method='subplex') -> tm + data.frame(loglik=logLik(tm),loglik.se=0,as.list(coef(tm))) +}) -> tm3 +``` +```{r tm3-simplot} +simdat <- simulate(bsflu3,params=unlist(tm3),nsim=10, + obs=TRUE,as.data.frame=TRUE,include.data=TRUE) +ggplot(data=melt(simdat,id=c("sim","time")), + mapping=aes(x=time,y=value,group=interaction(variable,sim), + color=variable,size=sim=="data",alpha=sim=="data"))+ + geom_line()+ + scale_alpha_manual(values=c(`TRUE`=1,`FALSE`=0.5))+ + scale_size_manual(values=c(`TRUE`=2,`FALSE`=1)) +``` + +### Iterated filtering + +```{r mf3} +juliaChild("bsflu-mf3.rds",{ + mif(bsflu3,rw.sd=c(Beta=0.05,inf.pd=0.05,rho=0.05), + cooling.fraction=0.9,var.factor=2, + Nmif=50,Np=1000,method='mif2',transform=TRUE) -> mf + mif(mf,Nmif=50,cooling.fraction=0.5) -> mf + mif(mf,Nmif=50,cooling.fraction=0.1) -> mf + ll <- unname(logmeanexp(raply(5,logLik(pfilter(mf))),se=TRUE)) + data.frame(loglik=ll[1],loglik.se=ll[2],as.list(coef(mf))) +}) -> mf3 +``` +```{r mf3-simplot} +simdat <- simulate(bsflu3,params=unlist(mf3),nsim=10, + obs=TRUE,as.data.frame=TRUE,include.data=TRUE) +ggplot(data=melt(simdat,id=c("sim","time")), + mapping=aes(x=time,y=value,group=interaction(variable,sim), + color=variable,size=sim=="data",alpha=sim=="data"))+ + geom_line()+ + scale_alpha_manual(values=c(`TRUE`=1,`FALSE`=0.5))+ + scale_size_manual(values=c(`TRUE`=2,`FALSE`=1)) +``` + +## Model comparison + +```{r comp} +tb <- ldply(list(det1=tm1,stoch1=mf1,det3=tm3,stoch3=mf3),.id="model") +kable(tb) +``` + +```{r probes,fig.height=6,fig.width=6} +plist <- list(probe.acf("confined",lags=c(2),type="cov",transform=sqrt), + probe.ccf(c("confined","convalescent"),lags=c(0,3),transform=sqrt), + tot=function (x) apply(x,1,sum)) +plot(probe(bsflu,params=unlist(tm1),nsim=500,probes=plist)) +plot(probe(bsflu,params=unlist(mf1),nsim=500,probes=plist)) +plot(probe(bsflu3,params=unlist(tm3),nsim=500,probes=plist)) +plot(probe(bsflu3,params=unlist(mf3),nsim=500,probes=plist)) +``` Added: pkg/pompExamples/vignettes/bsflu.html =================================================================== --- pkg/pompExamples/vignettes/bsflu.html (rev 0) +++ pkg/pompExamples/vignettes/bsflu.html 2015-01-23 14:50:29 UTC (rev 1053) @@ -0,0 +1,460 @@ + + + + + +Boarding-School Flu Outbreak Analysis + + + + + + + + + + + + + + + + + + +

Boarding-School Flu Outbreak Analysis

+ +

Aaron A. King

+ +

First, a little function to cache the results of expensive computations.

+ +
juliaChild <- function (file, expr) {
+  if (file.exists(file)) {
+    readRDS(file)
+    } else {
+      val <- eval(expr)
+      saveRDS(val,file=file)
+      val
+      }
+  }
+
+ +

Flu model with exponentially-distributed waiting times

+ +
pompExample(bsflu)
+
+ +
## newly created object(s):
+##  bsflu
+
+ +
coef(bsflu)
+
+ +
##      Beta    inf.pd   conf.pd   conv.pd       rho     sfrac 
+## 0.0040000 0.7000000 3.0078125 1.8046875 0.9000000 0.9986894
+
+ +
simdat <- simulate(bsflu,nsim=10,obs=TRUE,as.data.frame=TRUE,include.data=TRUE)
+ggplot(data=melt(simdat,id=c("sim","time")),
+       mapping=aes(x=time,y=value,group=interaction(variable,sim),
+                   color=variable,size=sim=="data",alpha=sim=="data"))+
+  geom_line()+
+  scale_alpha_manual(values=c(`TRUE`=1,`FALSE`=0.5))+
+  scale_size_manual(values=c(`TRUE`=2,`FALSE`=1))
+
+ [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1053 From noreply at r-forge.r-project.org Fri Jan 23 15:50:34 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 23 Jan 2015 15:50:34 +0100 (CET) Subject: [Pomp-commits] r1054 - pkg/pompExamples Message-ID: <20150123145034.3F02B187946@r-forge.r-project.org> Author: kingaa Date: 2015-01-23 15:50:34 +0100 (Fri, 23 Jan 2015) New Revision: 1054 Modified: pkg/pompExamples/DESCRIPTION Log: - add markdown to Suggests Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-23 14:50:29 UTC (rev 1053) +++ pkg/pompExamples/DESCRIPTION 2015-01-23 14:50:34 UTC (rev 1054) @@ -17,7 +17,7 @@ URL: http://pomp.r-forge.r-project.org Description: More 'pomp' examples. Depends: R(>= 3.0.0), stats, graphics, pomp(>= 0.58-6) -Suggests: plyr, reshape2, knitr, ggplot2 +Suggests: plyr, reshape2, ggplot2, knitr, markdown License: GPL (>= 2) LazyData: false BuildVignettes: true From noreply at r-forge.r-project.org Sat Jan 24 16:19:48 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 24 Jan 2015 16:19:48 +0100 (CET) Subject: [Pomp-commits] r1055 - pkg/pompExamples/vignettes Message-ID: <20150124151948.99447187924@r-forge.r-project.org> Author: kingaa Date: 2015-01-24 16:19:48 +0100 (Sat, 24 Jan 2015) New Revision: 1055 Added: pkg/pompExamples/vignettes/parus-mf.rds pkg/pompExamples/vignettes/parus-tm1.rds pkg/pompExamples/vignettes/parus.Rmd pkg/pompExamples/vignettes/parus.html Log: - vignette on Parus major example Added: pkg/pompExamples/vignettes/parus-mf.rds =================================================================== --- pkg/pompExamples/vignettes/parus-mf.rds (rev 0) +++ pkg/pompExamples/vignettes/parus-mf.rds 2015-01-24 15:19:48 UTC (rev 1055) @@ -0,0 +1,3 @@ +???b```b`fdb`b2???;?1????_???Q????%)??? +?wH_????\m8?[p???s????{??3_ ????2~\}R?0?? , ?@?5/17??;"??????? +?qBxz??PFo?fJqfzn"?S??Z?0???Y?Y?_???& ??t?%?$???JI,I?K+???HP??U \ No newline at end of file Added: pkg/pompExamples/vignettes/parus-tm1.rds =================================================================== --- pkg/pompExamples/vignettes/parus-tm1.rds (rev 0) +++ pkg/pompExamples/vignettes/parus-tm1.rds 2015-01-24 15:19:48 UTC (rev 1055) @@ -0,0 +1 @@ +???b```b`fdb`b2???;?1???;???}???w?????)8???G????a|?e+??gY????????/??O???X????0pi?????b C?? [N~zNf6?? ???B?a?"?)?????0NIFj ????g?f%gQ~??Z^P?4 ???????X sL?+%?$Q/????T??U \ No newline at end of file Added: pkg/pompExamples/vignettes/parus.Rmd =================================================================== --- pkg/pompExamples/vignettes/parus.Rmd (rev 0) +++ pkg/pompExamples/vignettes/parus.Rmd 2015-01-24 15:19:48 UTC (rev 1055) @@ -0,0 +1,107 @@ +%\VignetteIndexEntry{Parus major example} +%\VignetteEngine{knitr::knitr} + +# Analysis of Parus Major data from Wytham Wood +***Aaron A. King*** + +```{r setup,include=FALSE} +require(pomp) +require(plyr) +require(reshape2) +options(stringsAsFactors=FALSE,keep.source=TRUE,encoding="UTF-8") + +require(ggplot2) +theme_set(theme_bw()) + +require(knitr) +opts_knit$set(out.format="html") +opts_chunk$set( + progress=TRUE, + prompt=FALSE,tidy=FALSE,highlight=TRUE, + strip.white=TRUE, + warning=FALSE,message=FALSE,error=FALSE, + echo=TRUE,cache=FALSE, + results='markup', + fig.show='asis', + fig.height=5,fig.width=10, + dpi=100 + ) + +require(pompExamples) +set.seed(862663052L) +``` + +First, a little function to cache the results of expensive computations. + +```{r juliaChild} +juliaChild <- function (file, expr) { + if (file.exists(file)) { + readRDS(file) + } else { + val <- eval(expr) + saveRDS(val,file=file) + val + } + } +``` + +### Load and plot the data + +```{r} +pompExample(parus,proc='Gompertz',meas='Poisson') +plot(parus) +coef(parus) +logLik(traj.match(parus)) +``` + +## Trajectory matching + +```{r} +juliaChild("parus-tm1.rds",{ + tm <- parus + coef(tm,"theta") <- NA + traj.match(tm,est=c("K","r","sigma"),transform=T) -> tm + traj.match(tm,method='subplex') -> tm + data.frame(loglik=logLik(tm),loglik.se=0,as.list(coef(tm))) + }) -> tm +``` +```{r} +ggplot(data=simulate(parus,params=unlist(tm),nsim=10,obs=TRUE, + as.data.frame=TRUE,include.data=TRUE), + mapping=aes(x=time,y=pop,group=sim,alpha=sim=="data"))+ + geom_line() +``` + +## Iterated filtering + +```{r} +juliaChild("parus-mf.rds",{ + mf <- parus + coef(mf,"theta") <- NA + mif(mf,rw.sd=c(K=0.02,r=0.02,sigma=0.02), + cooling.fraction=0.8,var.factor=2, + Nmif=50,Np=2000,method='mif2', + cooling.type='hyperbolic') -> mf + continue(mf,Nmif=250) -> mf + mif(mf) -> mf + mif(mf,Np=5000) -> mf + mif(mf,Np=5000) -> mf + mif(mf,Np=5000) -> mf + continue(mf,Nmif=50) -> mf + plot(mf) + ll <- unname(logmeanexp(raply(5,logLik(pfilter(mf))),se=TRUE)) + data.frame(loglik=ll[1],loglik.se=ll[2],as.list(coef(mf))) +}) -> mf +``` +```{r} +ggplot(data=simulate(parus,params=unlist(mf),nsim=10,obs=TRUE, + as.data.frame=TRUE,include.data=TRUE), + mapping=aes(x=time,y=pop,group=sim,alpha=sim=="data"))+ + geom_line() +``` + +## Comparison + +```{r} +kable(ldply(list(det=tm,stoch=mf),.id='model')) +``` Added: pkg/pompExamples/vignettes/parus.html =================================================================== --- pkg/pompExamples/vignettes/parus.html (rev 0) +++ pkg/pompExamples/vignettes/parus.html 2015-01-24 15:19:48 UTC (rev 1055) @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1055 From noreply at r-forge.r-project.org Sat Jan 24 16:19:52 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 24 Jan 2015 16:19:52 +0100 (CET) Subject: [Pomp-commits] r1056 - pkg/pompExamples Message-ID: <20150124151952.30FDE187924@r-forge.r-project.org> Author: kingaa Date: 2015-01-24 16:19:51 +0100 (Sat, 24 Jan 2015) New Revision: 1056 Modified: pkg/pompExamples/DESCRIPTION Log: - vignette for Parus major example Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-24 15:19:48 UTC (rev 1055) +++ pkg/pompExamples/DESCRIPTION 2015-01-24 15:19:51 UTC (rev 1056) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.26-1 -Date: 2015-01-23 +Version: 0.26-2 +Date: 2015-01-24 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), From noreply at r-forge.r-project.org Mon Jan 26 02:27:50 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 26 Jan 2015 02:27:50 +0100 (CET) Subject: [Pomp-commits] r1057 - in pkg/pompExamples: . vignettes Message-ID: <20150126012750.D10DB185FC1@r-forge.r-project.org> Author: kingaa Date: 2015-01-26 02:27:50 +0100 (Mon, 26 Jan 2015) New Revision: 1057 Modified: pkg/pompExamples/DESCRIPTION pkg/pompExamples/vignettes/parus-tm1.rds pkg/pompExamples/vignettes/parus.Rmd pkg/pompExamples/vignettes/parus.html Log: - update Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-24 15:19:51 UTC (rev 1056) +++ pkg/pompExamples/DESCRIPTION 2015-01-26 01:27:50 UTC (rev 1057) @@ -1,7 +1,7 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.26-2 +Version: 0.26-3 Date: 2015-01-24 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), Modified: pkg/pompExamples/vignettes/parus-tm1.rds =================================================================== --- pkg/pompExamples/vignettes/parus-tm1.rds 2015-01-24 15:19:51 UTC (rev 1056) +++ pkg/pompExamples/vignettes/parus-tm1.rds 2015-01-26 01:27:50 UTC (rev 1057) @@ -1 +1,2 @@ -???b```b`fdb`b2???;?1???;???}???w?????)8???G????a|?e+??gY????????/??O???X????0pi?????b C?? [N~zNf6?? ???B?a?"?)?????0NIFj ????g?f%gQ~??Z^P?4 ???????X sL?+%?$Q/????T??U \ No newline at end of file +???b```b`fdb`b2???;?1???;???}???w?8???eB tm + coef(tm,c("sigma","theta")) <- c(0,NA) + traj.match(tm,est=c("K","r"),transform=T) -> tm traj.match(tm,method='subplex') -> tm data.frame(loglik=logLik(tm),loglik.se=0,as.list(coef(tm))) }) -> tm @@ -69,7 +98,9 @@ ggplot(data=simulate(parus,params=unlist(tm),nsim=10,obs=TRUE, as.data.frame=TRUE,include.data=TRUE), mapping=aes(x=time,y=pop,group=sim,alpha=sim=="data"))+ - geom_line() + geom_line()+ + scale_alpha_manual(name="",labels=c(`TRUE`='data',`FALSE`='simulation'), + values=c(`TRUE`=1,`FALSE`=0.2)) ``` ## Iterated filtering @@ -91,17 +122,19 @@ plot(mf) ll <- unname(logmeanexp(raply(5,logLik(pfilter(mf))),se=TRUE)) data.frame(loglik=ll[1],loglik.se=ll[2],as.list(coef(mf))) -}) -> mf + }) -> mf ``` ```{r} ggplot(data=simulate(parus,params=unlist(mf),nsim=10,obs=TRUE, as.data.frame=TRUE,include.data=TRUE), mapping=aes(x=time,y=pop,group=sim,alpha=sim=="data"))+ - geom_line() + geom_line()+ + scale_alpha_manual(name="",labels=c(`TRUE`='data',`FALSE`='simulation'), + values=c(`TRUE`=1,`FALSE`=0.2)) ``` ## Comparison ```{r} -kable(ldply(list(det=tm,stoch=mf),.id='model')) +kable(ldply(list(det.gomp.poisson=tm,stoch.gomp.poisson=mf),.id='model')) ``` Modified: pkg/pompExamples/vignettes/parus.html =================================================================== --- pkg/pompExamples/vignettes/parus.html 2015-01-24 15:19:51 UTC (rev 1056) +++ pkg/pompExamples/vignettes/parus.html 2015-01-26 01:27:50 UTC (rev 1057) @@ -82,26 +82,43 @@ ## parus
plot(parus)
[TRUNCATED] To get the complete diff run: svnlook diff /svnroot/pomp -r 1057 From noreply at r-forge.r-project.org Mon Jan 26 02:35:51 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 26 Jan 2015 02:35:51 +0100 (CET) Subject: [Pomp-commits] r1058 - in pkg/pomp: . R tests Message-ID: <20150126013551.92F54185FC1@r-forge.r-project.org> Author: kingaa Date: 2015-01-26 02:35:51 +0100 (Mon, 26 Jan 2015) New Revision: 1058 Modified: pkg/pomp/DESCRIPTION pkg/pomp/R/pomp-methods.R pkg/pomp/tests/ou2-mif.Rout.save Log: - dimnames of arrays returned by 'states' and 'obs' will have names Modified: pkg/pomp/DESCRIPTION =================================================================== --- pkg/pomp/DESCRIPTION 2015-01-26 01:27:50 UTC (rev 1057) +++ pkg/pomp/DESCRIPTION 2015-01-26 01:35:51 UTC (rev 1058) @@ -1,8 +1,8 @@ Package: pomp Type: Package Title: Statistical Inference for Partially Observed Markov Processes -Version: 0.58-6 -Date: 2015-01-22 +Version: 0.58-7 +Date: 2015-01-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")), Modified: pkg/pomp/R/pomp-methods.R =================================================================== --- pkg/pomp/R/pomp-methods.R 2015-01-26 01:27:50 UTC (rev 1057) +++ pkg/pomp/R/pomp-methods.R 2015-01-26 01:35:51 UTC (rev 1058) @@ -44,7 +44,9 @@ 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] + y <- object at data[vars,,drop=FALSE] + dimnames(y) <- list(variable=rownames(y),time=time(object)) + y } ## a simple method to extract the data array @@ -52,20 +54,20 @@ setMethod("data.array","pomp",obs.internal) ## a simple method to extract the array of states -setMethod( - "states", - "pomp", - function (object, vars, ...) { - if (length(object at states)==0) { - NULL - } else { - if (missing(vars)) - vars <- seq(length=nrow(object at states)) - object at states[vars,,drop=FALSE] - } - } - ) +states.internal <- function (object, vars, ...) { + if (length(object at states)==0) { + NULL + } else { + if (missing(vars)) + vars <- seq(length=nrow(object at states)) + x <- object at states[vars,,drop=FALSE] + dimnames(x) <- list(variable=rownames(x),time=time(object)) + x + } +} +setMethod("states","pomp",states.internal) + ## a simple method to extract the vector of times setMethod( "time", Modified: pkg/pomp/tests/ou2-mif.Rout.save =================================================================== --- pkg/pomp/tests/ou2-mif.Rout.save 2015-01-26 01:27:50 UTC (rev 1057) +++ pkg/pomp/tests/ou2-mif.Rout.save 2015-01-26 01:35:51 UTC (rev 1058) @@ -26,12 +26,14 @@ > set.seed(64857673L) > > obs(window(ou2,end=20,start=15)) - [,1] [,2] [,3] [,4] [,5] [,6] -y1 8.598190 2.199643 -1.134924 -2.564136 -4.915368 -4.338996 -y2 -4.903347 -10.251144 -10.362431 -8.168859 -7.220312 -2.310222 + time +variable 15 16 17 18 19 20 + y1 8.598190 2.199643 -1.134924 -2.564136 -4.915368 -4.338996 + y2 -4.903347 -10.251144 -10.362431 -8.168859 -7.220312 -2.310222 > obs(window(ou2,end=5),"y1") - [,1] [,2] [,3] [,4] [,5] -y1 -1.700816 0.2421701 3.767589 5.685888 3.774526 + time +variable 1 2 3 4 5 + y1 -1.700816 0.2421701 3.767589 5.685888 3.774526 > > fit1.pfilter <- pfilter(ou2,Np=1000) > cat("coefficients at `truth'\n") @@ -281,4 +283,4 @@ > > proc.time() user system elapsed - 11.452 0.064 11.704 + 14.827 0.050 14.879 From noreply at r-forge.r-project.org Wed Jan 28 13:34:07 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 28 Jan 2015 13:34:07 +0100 (CET) Subject: [Pomp-commits] r1059 - pkg/pompExamples Message-ID: <20150128123407.F0AA11876DD@r-forge.r-project.org> Author: kingaa Date: 2015-01-28 13:34:07 +0100 (Wed, 28 Jan 2015) New Revision: 1059 Modified: pkg/pompExamples/DESCRIPTION Log: bump Modified: pkg/pompExamples/DESCRIPTION =================================================================== --- pkg/pompExamples/DESCRIPTION 2015-01-26 01:35:51 UTC (rev 1058) +++ pkg/pompExamples/DESCRIPTION 2015-01-28 12:34:07 UTC (rev 1059) @@ -1,8 +1,8 @@ Package: pompExamples Type: Package Title: Additional pomp examples -Version: 0.26-3 -Date: 2015-01-24 +Version: 0.26-4 +Date: 2015-01-28 Maintainer: Aaron A. King Authors at R: c(person(given=c("Aaron","A."),family="King",role=c("aut","cre"), email="kingaa at umich.edu"), From noreply at r-forge.r-project.org Wed Jan 28 14:33:26 2015 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 28 Jan 2015 14:33:26 +0100 (CET) Subject: [Pomp-commits] r1060 - pkg/pompExamples/vignettes Message-ID: <20150128133326.8F8D4186041@r-forge.r-project.org> Author: kingaa Date: 2015-01-28 14:33:25 +0100 (Wed, 28 Jan 2015) New Revision: 1060 Modified: pkg/pompExamples/vignettes/bsflu.Rmd pkg/pompExamples/vignettes/bsflu.html pkg/pompExamples/vignettes/parus.Rmd pkg/pompExamples/vignettes/parus.html Log: - replace 'juliaChild' with 'bake' Modified: pkg/pompExamples/vignettes/bsflu.Rmd =================================================================== --- pkg/pompExamples/vignettes/bsflu.Rmd 2015-01-28 12:34:07 UTC (rev 1059) +++ pkg/pompExamples/vignettes/bsflu.Rmd 2015-01-28 13:33:25 UTC (rev 1060) @@ -33,8 +33,8 @@ First, a little function to cache the results of expensive computations. -```{r juliaChild} -juliaChild <- function (file, expr) { +```{r bake} +bake <- function (file, expr) { if (file.exists(file)) { readRDS(file) } else { @@ -64,11 +64,11 @@ ### Trajectory matching ```{r tm1} -juliaChild("bsflu-tm1.rds",{ +bake("bsflu-tm1.rds",{ traj.match(bsflu,est=c("Beta","inf.pd","rho"),transform=TRUE) -> tm traj.match(tm,method='subplex') -> tm data.frame(loglik=logLik(tm),loglik.se=0,as.list(coef(tm))) -}) -> tm1 + }) -> tm1 ``` ```{r tm1-simplot} simdat <- simulate(bsflu,params=unlist(tm1),nsim=10, @@ -84,7 +84,7 @@ ### Iterated filtering ```{r mf1} -juliaChild("bsflu-mf1.rds",{ +bake("bsflu-mf1.rds",{ mif(bsflu,rw.sd=c(Beta=0.05,inf.pd=0.05,rho=0.05), cooling.fraction=0.9,var.factor=2, Nmif=50,Np=1000,method='mif2',transform=TRUE) -> mf @@ -92,7 +92,7 @@ mif(mf,Nmif=50,cooling.fraction=0.1) -> mf ll <- unname(logmeanexp(raply(5,logLik(pfilter(mf))),se=TRUE)) data.frame(loglik=ll[1],loglik.se=ll[2],as.list(coef(mf))) -}) -> mf1 + }) -> mf1 ``` ```{r mf1-simplot} simdat <- simulate(bsflu,params=unlist(mf1),nsim=10, @@ -124,11 +124,11 @@ ### Trajectory matching ```{r tm3} -juliaChild("bsflu-tm3.rds",{ +bake("bsflu-tm3.rds",{ traj.match(bsflu3,est=c("Beta","inf.pd","rho"),transform=TRUE) -> tm traj.match(tm,method='subplex') -> tm data.frame(loglik=logLik(tm),loglik.se=0,as.list(coef(tm))) -}) -> tm3 + }) -> tm3 ``` ```{r tm3-simplot} simdat <- simulate(bsflu3,params=unlist(tm3),nsim=10, @@ -144,7 +144,7 @@ ### Iterated filtering ```{r mf3} -juliaChild("bsflu-mf3.rds",{ +bake("bsflu-mf3.rds",{ mif(bsflu3,rw.sd=c(Beta=0.05,inf.pd=0.05,rho=0.05), cooling.fraction=0.9,var.factor=2, Nmif=50,Np=1000,method='mif2',transform=TRUE) -> mf @@ -152,7 +152,7 @@ mif(mf,Nmif=50,cooling.fraction=0.1) -> mf ll <- unname(logmeanexp(raply(5,logLik(pfilter(mf))),se=TRUE)) data.frame(loglik=ll[1],loglik.se=ll[2],as.list(coef(mf))) -}) -> mf3 + }) -> mf3 ``` ```{r mf3-simplot} simdat <- simulate(bsflu3,params=unlist(mf3),nsim=10, Modified: pkg/pompExamples/vignettes/bsflu.html =================================================================== --- pkg/pompExamples/vignettes/bsflu.html 2015-01-28 12:34:07 UTC (rev 1059) +++ pkg/pompExamples/vignettes/bsflu.html 2015-01-28 13:33:25 UTC (rev 1060) @@ -1,213 +1,72 @@ - - - -Boarding-School Flu Outbreak Analysis + - + - -