[Pomp-commits] r1218 - in pkg/pomp: . R demo inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jun 18 11:41:22 CEST 2015
Author: kingaa
Date: 2015-06-18 11:41:22 +0200 (Thu, 18 Jun 2015)
New Revision: 1218
Modified:
pkg/pomp/DESCRIPTION
pkg/pomp/R/builder.R
pkg/pomp/R/pomp.R
pkg/pomp/demo/gompertz.R
pkg/pomp/demo/sir.R
pkg/pomp/inst/NEWS
pkg/pomp/inst/NEWS.Rd
pkg/pomp/man/csnippet.Rd
Log:
- option pomp.file.dir -> pomp.cache
- make cache dir if it does not exist
- update demos
Modified: pkg/pomp/DESCRIPTION
===================================================================
--- pkg/pomp/DESCRIPTION 2015-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/DESCRIPTION 2015-06-18 09:41:22 UTC (rev 1218)
@@ -1,8 +1,8 @@
Package: pomp
Type: Package
Title: Statistical Inference for Partially Observed Markov Processes
-Version: 0.68-1
-Date: 2015-06-17
+Version: 0.68-2
+Date: 2015-06-18
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-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/R/builder.R 2015-06-18 09:41:22 UTC (rev 1218)
@@ -9,6 +9,14 @@
if (is.null(name)) name <- randomName()
if (is.null(dir)) dir <- tempdir()
+ else {
+ try(
+ rv <- dir.create(dir,recursive=TRUE,showWarnings=FALSE,mode="0700"),
+ silent=TRUE
+ )
+ if (inherits(rv,"try-error"))
+ stop("cannot create cache directory ",sQuote(dir),call.=TRUE)
+ }
if (missing(globals)) globals <- character(0)
if (is(globals,"Csnippet")) globals <- globals at text
Modified: pkg/pomp/R/pomp.R
===================================================================
--- pkg/pomp/R/pomp.R 2015-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/R/pomp.R 2015-06-18 09:41:22 UTC (rev 1218)
@@ -13,7 +13,7 @@
globals, userdata, ...,
.solibfile = list(),
.filename = NULL,
- .filedir = getOption("pomp.file.dir",NULL),
+ .filedir = getOption("pomp.cache",NULL),
verbose = getOption("verbose",FALSE)) {
## preliminary error checking
Modified: pkg/pomp/demo/gompertz.R
===================================================================
--- pkg/pomp/demo/gompertz.R 2015-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/demo/gompertz.R 2015-06-18 09:41:22 UTC (rev 1218)
@@ -43,10 +43,10 @@
f <- dlnorm(x=Y,meanlog=log(X),sdlog=tau,log=log)
return(f)
},
- parameter.inv.transform=function(params,...){
+ toEstimationScale=function(params,...){
log(params)
},
- parameter.transform=function(params,...){
+ fromEstimationScale=function(params,...){
exp(params)
}
) -> gompertz
@@ -76,6 +76,14 @@
"
partrans <- "
+ Tr = log(r);
+ TK = log(K);
+ Tsigma = log(sigma);
+ TX_0 = log(X_0);
+ Ttau = log(tau);
+"
+
+paruntrans <- "
Tr = exp(r);
TK = exp(K);
Tsigma = exp(sigma);
@@ -83,14 +91,6 @@
Ttau = exp(tau);
"
-paruntrans <- "
- Tr = log(r);
- TK = log(K);
- Tsigma = log(sigma);
- TX_0 = log(X_0);
- Ttau = log(tau);
-"
-
pomp(
data=data.frame(t=1:100,Y=NA),
times="t",
@@ -106,8 +106,8 @@
skeleton=Csnippet(skel),
skeleton.type="map",
skelmap.delta.t=1,
- parameter.inv.transform=Csnippet(partrans),
- parameter.transform=Csnippet(paruntrans)
+ toEstimationScale=Csnippet(partrans),
+ fromEstimationScale=Csnippet(paruntrans)
) -> Gompertz
## simulate some data
Modified: pkg/pomp/demo/sir.R
===================================================================
--- pkg/pomp/demo/sir.R 2015-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/demo/sir.R 2015-06-18 09:41:22 UTC (rev 1218)
@@ -54,7 +54,6 @@
double rate[6]; // transition rates
double term[6]; // transition numbers
double beta; // transmission rate
- double dW; // white noise increment
int k;
for (k = 0, beta = 0.0; k < nbasis; k++)
@@ -90,6 +89,19 @@
## adjacent memory locations, in that order
partrans <- "
int k;
+ Tgamma = log(gamma);
+ Tmu = log(mu);
+ Tiota = log(iota);
+ for (k = 0; k < nbasis; k++)
+ (&Tbeta1)[k] = log((&beta1)[k]);
+ Tbeta_sd = log(beta_sd);
+ Trho = logit(rho);
+ Ttheta = log(theta);
+ to_log_barycentric(&TS_0,&S_0,3);
+"
+
+paruntrans <- "
+ int k;
Tgamma = exp(gamma);
Tmu = exp(mu);
Tiota = exp(iota);
@@ -101,17 +113,13 @@
from_log_barycentric(&TS_0,&S_0,3);
"
-paruntrans <- "
- int k;
- Tgamma = log(gamma);
- Tmu = log(mu);
- Tiota = log(iota);
- for (k = 0; k < nbasis; k++)
- (&Tbeta1)[k] = log((&beta1)[k]);
- Tbeta_sd = log(beta_sd);
- Trho = logit(rho);
- Ttheta = log(theta);
- to_log_barycentric(&TS_0,&S_0,3);
+initlzr <- "
+ double m = popsize/(S_0+I_0+R_0);
+ S = nearbyint(m*S_0);
+ I = nearbyint(m*I_0);
+ R = nearbyint(m*R_0);
+ incid = 0;
+ W = 0;
"
cbind(
@@ -145,23 +153,15 @@
skeleton=Csnippet(skel),
covar=covar,
tcovar="time",
- parameter.transform=Csnippet(partrans),
- parameter.inv.transform=Csnippet(paruntrans),
+ toEstimationScale=Csnippet(partrans),
+ fromEstimationScale=Csnippet(paruntrans),
statenames=c("S","I","R","incid","W"),
paramnames=c(
"gamma","mu","iota","beta1","beta.sd",
"popsize","rho","theta","S.0","I.0","R.0"
),
zeronames=c("incid","W"),
- comp.names=c("S","I","R"),
- ic.names=c("S.0","I.0","R.0"),
- initializer=function(params, t0, comp.names, ic.names, ...) {
- x0 <- numeric(5)
- names(x0) <- c("S","I","R","incid","W")
- fracs <- params[ic.names]
- x0[comp.names] <- round(params['popsize']*fracs/sum(fracs))
- x0
- }
+ initializer=Csnippet(initlzr)
) -> po
coef(po) <- c(
Modified: pkg/pomp/inst/NEWS
===================================================================
--- pkg/pomp/inst/NEWS 2015-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/inst/NEWS 2015-06-18 09:41:22 UTC (rev 1218)
@@ -1,11 +1,11 @@
_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._6_8-_1:
+_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_8-_2:
• When using ‘Csnippet’s, by default, the C codes and
shared-object files are stored in the R session's temporary
directory. One can override this behavior by setting the
- global ‘pomp.file.dir’ option.
+ global ‘pomp.cache’ option.
_C_h_a_n_g_e_s _i_n '_p_o_m_p' _v_e_r_s_i_o_n _0._6_7-_1:
Modified: pkg/pomp/inst/NEWS.Rd
===================================================================
--- pkg/pomp/inst/NEWS.Rd 2015-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/inst/NEWS.Rd 2015-06-18 09:41:22 UTC (rev 1218)
@@ -1,9 +1,9 @@
\name{NEWS}
\title{News for package `pomp'}
-\section{Changes in \pkg{pomp} version 0.68-1}{
+\section{Changes in \pkg{pomp} version 0.68-2}{
\itemize{
\item When using \code{Csnippet}s, by default, the C codes and shared-object files are stored in the R session's temporary directory.
- One can override this behavior by setting the global \code{pomp.file.dir} option.
+ One can override this behavior by setting the global \code{pomp.cache} option.
}
}
\section{Changes in \pkg{pomp} version 0.67-1}{
Modified: pkg/pomp/man/csnippet.Rd
===================================================================
--- pkg/pomp/man/csnippet.Rd 2015-06-18 09:28:44 UTC (rev 1217)
+++ pkg/pomp/man/csnippet.Rd 2015-06-18 09:41:22 UTC (rev 1218)
@@ -21,7 +21,7 @@
Furnishing one or more \code{Csnippet}s as arguments to the \code{pomp} constructor causes them to be written to a C file stored in the \R session's temporary directory, which is then compiled (via \code{\link[=SHLIB]{R CMD SHLIB}}) into a dynamically loadable shared object file.
This is then loaded as needed.
- One can choose to store these files in a different directory by setting the global option \code{pomp.file.dir}, e.g.: \preformatted{options(pomp.file.dir=getwd())}.
+ One can choose to store these files in a different directory by setting the global option \code{pomp.cache}, e.g.: \preformatted{options(pomp.cache=getwd())}.
\strong{Note to Windows and Mac users:}
By default, your \R installation may not support \code{\link[=SHLIB]{R CMD SHLIB}}.
More information about the pomp-commits
mailing list