[Pomp-commits] r989 - in branches/premif2: . R data demo inst inst/data-R inst/doc inst/examples inst/include man src tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jun 29 14:21:39 CEST 2014
Author: kingaa
Date: 2014-06-29 14:21:37 +0200 (Sun, 29 Jun 2014)
New Revision: 989
Removed:
branches/premif2/.Rbuildignore
branches/premif2/.Rinstignore
branches/premif2/DESCRIPTION
branches/premif2/NAMESPACE
branches/premif2/R/aaa.R
branches/premif2/R/authors.R
branches/premif2/R/basic-probes.R
branches/premif2/R/bsmc.R
branches/premif2/R/bsplines.R
branches/premif2/R/builder.R
branches/premif2/R/compare-mif.R
branches/premif2/R/compare-pmcmc.R
branches/premif2/R/dmeasure-pomp.R
branches/premif2/R/dprocess-pomp.R
branches/premif2/R/eulermultinom.R
branches/premif2/R/init-state-pomp.R
branches/premif2/R/mif-class.R
branches/premif2/R/mif-methods.R
branches/premif2/R/mif.R
branches/premif2/R/nlf-funcs.R
branches/premif2/R/nlf-guts.R
branches/premif2/R/nlf-objfun.R
branches/premif2/R/nlf.R
branches/premif2/R/parmat.R
branches/premif2/R/particles-mif.R
branches/premif2/R/pfilter-methods.R
branches/premif2/R/pfilter.R
branches/premif2/R/plot-pomp.R
branches/premif2/R/plugins.R
branches/premif2/R/pmcmc-methods.R
branches/premif2/R/pmcmc.R
branches/premif2/R/pomp-fun.R
branches/premif2/R/pomp-methods.R
branches/premif2/R/pomp.R
branches/premif2/R/probe-match.R
branches/premif2/R/probe.R
branches/premif2/R/profile-design.R
branches/premif2/R/rmeasure-pomp.R
branches/premif2/R/rprocess-pomp.R
branches/premif2/R/sannbox.R
branches/premif2/R/simulate-pomp.R
branches/premif2/R/skeleton-pomp.R
branches/premif2/R/slice-design.R
branches/premif2/R/sobol.R
branches/premif2/R/spect-match.R
branches/premif2/R/spect.R
branches/premif2/R/traj-match.R
branches/premif2/R/trajectory-pomp.R
branches/premif2/R/version.R
branches/premif2/data/LondonYorke.rda
branches/premif2/data/bbs.rda
branches/premif2/data/blowflies.rda
branches/premif2/data/dacca.rda
branches/premif2/data/euler.sir.rda
branches/premif2/data/gillespie.sir.rda
branches/premif2/data/gompertz.rda
branches/premif2/data/ou2.rda
branches/premif2/data/ricker.rda
branches/premif2/data/rw2.rda
branches/premif2/data/verhulst.rda
branches/premif2/demo/00Index
branches/premif2/demo/gompertz.R
branches/premif2/demo/logistic.R
branches/premif2/demo/rw2.R
branches/premif2/demo/sir.R
branches/premif2/inst/CHANGES_0.29-1.txt
branches/premif2/inst/CITATION
branches/premif2/inst/ChangeLog
branches/premif2/inst/GPL
branches/premif2/inst/LICENSE
branches/premif2/inst/NEWS
branches/premif2/inst/O_CHANGES
branches/premif2/inst/TODO
branches/premif2/inst/data-R/Makefile
branches/premif2/inst/data-R/blowflies.R
branches/premif2/inst/data-R/blowflies.csv
branches/premif2/inst/data-R/dacca.R
branches/premif2/inst/data-R/gompertz.R
branches/premif2/inst/data-R/make.R
branches/premif2/inst/data-R/ou2.R
branches/premif2/inst/data-R/ricker.R
branches/premif2/inst/data-R/rw2.R
branches/premif2/inst/data-R/sir.R
branches/premif2/inst/data-R/verhulst.R
branches/premif2/inst/doc/Makefile
branches/premif2/inst/doc/advanced_topics_in_pomp.Rnw
branches/premif2/inst/doc/advanced_topics_in_pomp.pdf
branches/premif2/inst/doc/bsmc-ricker-flat-prior.rda
branches/premif2/inst/doc/bsmc-ricker-normal-prior.rda
branches/premif2/inst/doc/complex-sir-def.rda
branches/premif2/inst/doc/fullnat.bst
branches/premif2/inst/doc/gompertz-multi-mif.rda
branches/premif2/inst/doc/gompertz-pfilter-guess.rda
branches/premif2/inst/doc/gompertz-trajmatch.rda
branches/premif2/inst/doc/index.html
branches/premif2/inst/doc/intro_to_pomp.Rnw
branches/premif2/inst/doc/intro_to_pomp.pdf
branches/premif2/inst/doc/nlf-block-boot.rda
branches/premif2/inst/doc/nlf-boot.rda
branches/premif2/inst/doc/nlf-fit-from-truth.rda
branches/premif2/inst/doc/nlf-fits.rda
branches/premif2/inst/doc/nlf-lag-tests.rda
branches/premif2/inst/doc/nlf-multi-short.rda
branches/premif2/inst/doc/plugin-C-code.rda
branches/premif2/inst/doc/plugin-R-code.rda
branches/premif2/inst/doc/pomp.bib
branches/premif2/inst/doc/ricker-comparison.rda
branches/premif2/inst/doc/ricker-first-probe.rda
branches/premif2/inst/doc/ricker-mif.rda
branches/premif2/inst/doc/ricker-probe-match.rda
branches/premif2/inst/doc/ricker-probe.rda
branches/premif2/inst/doc/sim-sim.rda
branches/premif2/inst/doc/sir-pomp-def.rda
branches/premif2/inst/doc/vectorized-C-code.rda
branches/premif2/inst/doc/vectorized-R-code.rda
branches/premif2/inst/examples/ou2.c
branches/premif2/inst/examples/sir.c
branches/premif2/inst/include/pomp.h
branches/premif2/man/LondonYorke.Rd
branches/premif2/man/basic-probes.Rd
branches/premif2/man/blowflies.Rd
branches/premif2/man/bsmc.Rd
branches/premif2/man/bsplines.Rd
branches/premif2/man/builder.Rd
branches/premif2/man/dacca.Rd
branches/premif2/man/dmeasure-pomp.Rd
branches/premif2/man/dprocess-pomp.Rd
branches/premif2/man/eulermultinom.Rd
branches/premif2/man/gompertz.Rd
branches/premif2/man/init.state-pomp.Rd
branches/premif2/man/mif-class.Rd
branches/premif2/man/mif-methods.Rd
branches/premif2/man/mif.Rd
branches/premif2/man/nlf.Rd
branches/premif2/man/ou2.Rd
branches/premif2/man/parmat.Rd
branches/premif2/man/particles-mif.Rd
branches/premif2/man/pfilter-methods.Rd
branches/premif2/man/pfilter.Rd
branches/premif2/man/plugins.Rd
branches/premif2/man/pmcmc-methods.Rd
branches/premif2/man/pmcmc.Rd
branches/premif2/man/pomp-class.Rd
branches/premif2/man/pomp-fun.Rd
branches/premif2/man/pomp-methods.Rd
branches/premif2/man/pomp-package.Rd
branches/premif2/man/pomp.Rd
branches/premif2/man/probe.Rd
branches/premif2/man/probed-pomp-methods.Rd
branches/premif2/man/profile-design.Rd
branches/premif2/man/ricker.Rd
branches/premif2/man/rmeasure-pomp.Rd
branches/premif2/man/rprocess-pomp.Rd
branches/premif2/man/rw2.Rd
branches/premif2/man/sannbox.Rd
branches/premif2/man/simulate-pomp.Rd
branches/premif2/man/sir.Rd
branches/premif2/man/skeleton-pomp.Rd
branches/premif2/man/slice-design.Rd
branches/premif2/man/sobol.Rd
branches/premif2/man/spect.Rd
branches/premif2/man/traj-match.Rd
branches/premif2/man/trajectory-pomp.Rd
branches/premif2/man/verhulst.Rd
branches/premif2/src/Makevars
branches/premif2/src/R_init_pomp.c
branches/premif2/src/SSA.f90
branches/premif2/src/SSA_wrapper.c
branches/premif2/src/blowfly.c
branches/premif2/src/bspline.c
branches/premif2/src/cholmodel.c
branches/premif2/src/dmeasure.c
branches/premif2/src/dprocess.c
branches/premif2/src/dsobol.c
branches/premif2/src/euler.c
branches/premif2/src/eulermultinom.c
branches/premif2/src/gompertz.c
branches/premif2/src/initstate.c
branches/premif2/src/lookup_table.c
branches/premif2/src/lpa.c
branches/premif2/src/ou2.c
branches/premif2/src/partrans.c
branches/premif2/src/pfilter.c
branches/premif2/src/pomp.h
branches/premif2/src/pomp_fun.c
branches/premif2/src/pomp_internal.h
branches/premif2/src/pomp_mat.h
branches/premif2/src/probe.c
branches/premif2/src/probe_acf.c
branches/premif2/src/probe_marginal.c
branches/premif2/src/probe_nlar.c
branches/premif2/src/ricker.c
branches/premif2/src/rmeasure.c
branches/premif2/src/rprocess.c
branches/premif2/src/simulate.c
branches/premif2/src/sir.c
branches/premif2/src/skeleton.c
branches/premif2/src/sobol.f
branches/premif2/src/synth_lik.c
branches/premif2/src/trajectory.c
branches/premif2/src/tsir.c
branches/premif2/src/userdata.c
branches/premif2/tests/bbs-trajmatch.R
branches/premif2/tests/bbs-trajmatch.Rout.save
branches/premif2/tests/bbs.R
branches/premif2/tests/bbs.Rout.save
branches/premif2/tests/blowflies.R
branches/premif2/tests/blowflies.Rout.save
branches/premif2/tests/dacca.R
branches/premif2/tests/dacca.Rout.save
branches/premif2/tests/dimchecks.R
branches/premif2/tests/dimchecks.Rout.save
branches/premif2/tests/fhn.R
branches/premif2/tests/fhn.Rout.save
branches/premif2/tests/filtfail.R
branches/premif2/tests/filtfail.Rout.save
branches/premif2/tests/gillespie.R
branches/premif2/tests/gillespie.Rout.save
branches/premif2/tests/gompertz.R
branches/premif2/tests/gompertz.Rout.save
branches/premif2/tests/logistic.R
branches/premif2/tests/logistic.Rout.save
branches/premif2/tests/ou2-bsmc.R
branches/premif2/tests/ou2-bsmc.Rout.save
branches/premif2/tests/ou2-forecast.R
branches/premif2/tests/ou2-forecast.Rout.save
branches/premif2/tests/ou2-icfit.R
branches/premif2/tests/ou2-icfit.Rout.save
branches/premif2/tests/ou2-kalman.R
branches/premif2/tests/ou2-kalman.Rout.save
branches/premif2/tests/ou2-mif-fp.R
branches/premif2/tests/ou2-mif-fp.Rout.save
branches/premif2/tests/ou2-mif.R
branches/premif2/tests/ou2-mif.Rout.save
branches/premif2/tests/ou2-nlf.R
branches/premif2/tests/ou2-nlf.Rout.save
branches/premif2/tests/ou2-pmcmc.R
branches/premif2/tests/ou2-pmcmc.Rout.save
branches/premif2/tests/ou2-probe.R
branches/premif2/tests/ou2-probe.Rout.save
branches/premif2/tests/ou2-procmeas.R
branches/premif2/tests/ou2-procmeas.Rout.save
branches/premif2/tests/ou2-simulate.R
branches/premif2/tests/ou2-simulate.Rout.save
branches/premif2/tests/ou2-trajmatch.R
branches/premif2/tests/ou2-trajmatch.Rout.save
branches/premif2/tests/partrans.R
branches/premif2/tests/partrans.Rout.save
branches/premif2/tests/pfilter.R
branches/premif2/tests/pfilter.Rout.save
branches/premif2/tests/pomppomp.R
branches/premif2/tests/pomppomp.Rout.save
branches/premif2/tests/ricker-bsmc.R
branches/premif2/tests/ricker-bsmc.Rout.save
branches/premif2/tests/ricker-probe.R
branches/premif2/tests/ricker-probe.Rout.save
branches/premif2/tests/ricker-spect.R
branches/premif2/tests/ricker-spect.Rout.save
branches/premif2/tests/ricker.R
branches/premif2/tests/ricker.Rout.save
branches/premif2/tests/rw2.R
branches/premif2/tests/rw2.Rout.save
branches/premif2/tests/sir.R
branches/premif2/tests/sir.Rout.save
branches/premif2/tests/skeleton.R
branches/premif2/tests/skeleton.Rout.save
branches/premif2/tests/steps.R
branches/premif2/tests/steps.Rout.save
branches/premif2/tests/synlik.R
branches/premif2/tests/synlik.Rout.save
branches/premif2/tests/verhulst.R
branches/premif2/tests/verhulst.Rout.save
Log:
- remove unneeded 'branches' directory
Deleted: branches/premif2/.Rbuildignore
===================================================================
--- branches/premif2/.Rbuildignore 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/.Rbuildignore 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,6 +0,0 @@
-inst/doc/Makefile
-inst/data-R/Makefile
-inst/data-R/make.R
-inst/doc/(.+?)\.bst$
-inst/doc/(.+?)\.R$
-inst/doc/(.+?)\.png$
Deleted: branches/premif2/.Rinstignore
===================================================================
--- branches/premif2/.Rinstignore 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/.Rinstignore 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,3 +0,0 @@
-inst/doc/Makefile
-inst/doc/fullnat.bst
-inst/doc/(.+?)\.rda$
Deleted: branches/premif2/DESCRIPTION
===================================================================
--- branches/premif2/DESCRIPTION 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/DESCRIPTION 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,33 +0,0 @@
-Package: pomp
-Type: Package
-Title: Statistical inference for partially observed Markov processes
-Version: 0.43-9
-Date: 2013-06-03
-Maintainer: Aaron A. King <kingaa at umich.edu>
-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")),
- person(given=c("Carles"),family="Breto",role=c("aut")),
- person(given=c("Stephen","P."),family="Ellner",role=c("ctb")),
- person(given=c("Matthew","J."),family="Ferrari",role=c("ctb")),
- person(given=c("Bruce","E."),family="Kendall",role=c("ctb")),
- person(given=c("Michael"),family="Lavine",role=c("ctb")),
- person(given=c("Daniel","C."),family="Reuman",role=c("ctb")),
- person(given=c("Helen"),family="Wearing",role=c("ctb")),
- person(given=c("Simon","N."),family="Wood",role=c("ctb")))
-URL: http://pomp.r-forge.r-project.org
-Description: Inference methods for partially-observed Markov processes
-Depends: R(>= 2.14.1), stats, methods, graphics, mvtnorm, subplex, deSolve
-License: GPL(>= 2)
-LazyLoad: true
-LazyData: false
-BuildVignettes: no
-Collate: aaa.R authors.R version.R eulermultinom.R plugins.R
- parmat.R slice-design.R profile-design.R sobol.R bsplines.R sannbox.R
- pomp-fun.R pomp.R pomp-methods.R rmeasure-pomp.R rprocess-pomp.R init-state-pomp.R
- dmeasure-pomp.R dprocess-pomp.R skeleton-pomp.R simulate-pomp.R trajectory-pomp.R plot-pomp.R
- pfilter.R pfilter-methods.R traj-match.R bsmc.R
- mif-class.R particles-mif.R mif.R mif-methods.R compare-mif.R
- pmcmc.R pmcmc-methods.R compare-pmcmc.R
- nlf-funcs.R nlf-guts.R nlf-objfun.R nlf.R
- probe.R probe-match.R basic-probes.R spect.R spect-match.R
- builder.R
Deleted: branches/premif2/NAMESPACE
===================================================================
--- branches/premif2/NAMESPACE 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/NAMESPACE 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,97 +0,0 @@
-useDynLib(
- pomp,
- get_pomp_fun,
- bspline_basis,
- periodic_bspline_basis,
- bspline_basis_function,
- systematic_resampling,
- euler_model_simulator,
- euler_model_density,
- lookup_in_table,
- SSA_simulator,
- R_Euler_Multinom,D_Euler_Multinom,R_GammaWN,
- pfilter_computations,
- simulation_computations,
- iterate_map,traj_transp_and_copy,
- apply_probe_data,apply_probe_sim,
- probe_marginal_setup,probe_marginal_solve,
- probe_acf,probe_ccf,
- probe_nlar,
- synth_loglik,
- pomp_desolve_setup,pomp_desolve_takedown,
- pomp_vf_eval,
- do_partrans,
- do_rprocess,
- do_dprocess,
- do_rmeasure,
- do_dmeasure,
- do_skeleton,
- do_init_state
- )
-
-importFrom(graphics,plot)
-importFrom(stats,simulate,time,coef,logLik,window)
-importFrom(mvtnorm,dmvnorm,rmvnorm)
-importFrom(subplex,subplex)
-importFrom(deSolve,ode)
-
-exportClasses(
- pomp,
- pfilterd.pomp,
- mif,
- pmcmc,
- traj.matched.pomp,
- probed.pomp,probe.matched.pomp,
- spect.pomp,spect.matched.pomp
- )
-
-exportMethods(
- pomp,
- plot,show,print,coerce,summary,logLik,window,"$",
- dprocess,rprocess,rmeasure,dmeasure,init.state,skeleton,
- data.array,obs,partrans,coef,"coef<-",time,"time<-",timezero,"timezero<-",
- simulate,pfilter,
- eff.sample.size,cond.logLik,
- particles,mif,continue,states,trajectory,
- pred.mean,pred.var,filter.mean,conv.rec,
- bsmc,
- pmcmc,dprior,
- spect,probe,
- probe.match,traj.match
- )
-
-export(
- as.data.frame.pomp,
- as.data.frame.pfilterd.pomp,
- reulermultinom,
- deulermultinom,
- rgammawn,
- euler.sim,
- discrete.time.sim,
- onestep.sim,
- onestep.dens,
- gillespie.sim,
- sobol,
- sobolDesign,
- sliceDesign,
- profileDesign,
- bspline.basis,
- periodic.bspline.basis,
- compare.mif,
- nlf,
- parmat,
- probe.mean,
- probe.median,
- probe.var,
- probe.sd,
- probe.period,
- probe.quantile,
- probe.acf,
- probe.ccf,
- probe.nlar,
- probe.marginal,
- sannbox,
- spect.match,
- traj.match.objfun,
- pompBuilder
- )
Deleted: branches/premif2/R/aaa.R
===================================================================
--- branches/premif2/R/aaa.R 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/R/aaa.R 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,25 +0,0 @@
-## .onAttach <- function (...) {
-## version <- library(help=pomp)$info[[1]]
-## version <- strsplit(version[pmatch("Version",version)]," ")[[1]]
-## version <- version[nchar(version)>0][2]
-## packageStartupMessage("This is pomp version ",version,"\n")
-## }
-
-setGeneric("print",function(x,...)standardGeneric("print"))
-setGeneric("plot",function(x,y,...)standardGeneric("plot"))
-setGeneric("summary",function(object,...)standardGeneric("summary"))
-setGeneric("simulate",function(object,nsim=1,seed=NULL,...)standardGeneric("simulate"))
-setGeneric("time",function(x,...)standardGeneric("time"))
-setGeneric("coef",function(object,...)standardGeneric("coef"))
-setGeneric("logLik",function(object,...)standardGeneric("logLik"))
-setGeneric("window",function(x,...)standardGeneric("window"))
-setGeneric("continue",function(object,...)standardGeneric("continue"))
-setGeneric("pred.mean",function(object,...)standardGeneric("pred.mean"))
-setGeneric("pred.var",function(object,...)standardGeneric("pred.var"))
-setGeneric("filter.mean",function(object,...)standardGeneric("filter.mean"))
-setGeneric("cond.logLik",function(object,...)standardGeneric("cond.logLik"))
-setGeneric("eff.sample.size",function(object,...)standardGeneric("eff.sample.size"))
-
-if (!exists("paste0",where="package:base")) {
- paste0 <- function(...) paste(...,sep="")
-}
Deleted: branches/premif2/R/authors.R
===================================================================
--- branches/premif2/R/authors.R 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/R/authors.R 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,12 +0,0 @@
-list(
- aak=person(given=c("Aaron","A."),family="King",role=c("aut","cre"),email="kingaa at umich.edu"),
- eli=person(given=c("Edward","L."),family="Ionides",role=c("ctb")),
- cb=person(given=c("Carles"),family="Breto",role=c("ctb")),
- spe=person(given=c("Stephen","P."),family="Ellner",role=c("ctb")),
- bek=person(given=c("Bruce","E."),family="Kendall",role=c("ctb")),
- mf=person(given=c("Matthew","J."),family="Ferrari",role=c("ctb")),
- ml=person(given=c("Michael"),family="Lavine",role=c("ctb")),
- dcr=person(given=c("Daniel","C."),family="Reuman",role=c("ctb")),
- hw=person(given=c("Helen"),family="Wearing",role=c("ctb")),
- snw=person(given=c("Simon","N."),family="Wood",role=c("ctb"))
- ) -> author.list
Deleted: branches/premif2/R/basic-probes.R
===================================================================
--- branches/premif2/R/basic-probes.R 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/R/basic-probes.R 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,176 +0,0 @@
-probe.mean <- function (var, trim = 0, transform = identity, na.rm = TRUE) {
- if (length(var)>1) stop(sQuote("probe.mean")," is a univariate probe")
- transform <- match.fun(transform)
- function(y) mean(x=transform(y[var,]),trim=trim,na.rm=na.rm)
-}
-
-probe.median <- function (var, na.rm = TRUE) {
- if (length(var)>1) stop(sQuote("probe.median")," is a univariate probe")
- function(y) median(x=as.numeric(y[var,]),na.rm=na.rm)
-}
-
-probe.var <- function (var, transform = identity, na.rm = TRUE) {
- if (length(var)>1) stop(sQuote("probe.var")," is a univariate probe")
- transform <- match.fun(transform)
- function(y) var(x=transform(y[var,]),na.rm=na.rm)
-}
-
-probe.sd <- function (var, transform = identity, na.rm = TRUE) {
- if (length(var)>1) stop(sQuote("probe.sd")," is a univariate probe")
- transform <- match.fun(transform)
- function(y) sd(x=transform(y[var,]),na.rm=na.rm)
-}
-
-probe.period <- function (var, kernel.width, transform = identity) {
- if (length(var)>1) stop(sQuote("probe.period")," is a univariate probe")
- transform <- match.fun(transform)
- function (y) {
- zz <- spec.pgram(
- x=transform(y[var,]),
- kernel=kernel("modified.daniell",m=kernel.width),
- taper=0,
- fast=FALSE,
- pad=0,
- detrend=FALSE,
- plot=FALSE
- )
- 1/zz$freq[which.max(zz$spec)]
- }
-}
-
-probe.quantile <- function (var, prob, transform = identity) {
- if (length(var)>1) stop(sQuote("probe.quantile")," is a univariate probe")
- transform <- match.fun(transform)
- function (y) quantile(transform(y[var,]),probs=prob)
-}
-
-probe.cov <- function (
- vars,
- lag,
- method = c("pearson", "kendall", "spearman"),
- transform = identity
- ) {
- method <- match.arg(method)
- lag <- as.integer(lag)
- transform <- match.fun(transform)
- var1 <- vars[1]
- if (length(vars)>1)
- var2 <- vars[2]
- else
- var2 <- var1
- function (y) {
- if (lag>=0) {
- val <- cov(
- x=transform(y[var1,seq(from=1+lag,to=ncol(y),by=1)]),
- y=transform(y[var2,seq(from=1,to=ncol(y)-lag,by=1)]),
- method=method
- )
- } else {
- val <- cov(
- x=transform(y[var1,seq(from=1,to=ncol(y)+lag,by=1)]),
- y=transform(y[var2,seq(from=-lag,to=ncol(y),by=1)]),
- method=method
- )
- }
- val
- }
-}
-
-probe.cor <- function (
- vars,
- lag,
- method = c("pearson", "kendall", "spearman"),
- transform = identity
- ) {
- method <- match.arg(method)
- lag <- as.integer(lag)
- transform <- match.fun(transform)
- var1 <- vars[1]
- if (length(vars)>1)
- var2 <- vars[2]
- else
- var2 <- var1
- function (y) {
- if (lag>=0) {
- val <- cor(
- x=transform(y[var1,seq(from=1+lag,to=ncol(y),by=1)]),
- y=transform(y[var2,seq(from=1,to=ncol(y)-lag,by=1)]),
- method=method
- )
- } else {
- val <- cor(
- x=transform(y[var1,seq(from=1,to=ncol(y)+lag,by=1)]),
- y=transform(y[var2,seq(from=-lag,to=ncol(y),by=1)]),
- method=method
- )
- }
- val
- }
-}
-
-probe.acf <- function (var, lags, type = c("covariance", "correlation"), transform = identity) {
- type <- match.arg(type)
- corr <- type=="correlation"
- transform <- match.fun(transform)
- if (corr && any(lags==0)) {
- warning("useless zero lag discarded in ",sQuote("probe.acf"))
- lags <- lags[lags!=0]
- }
- lags <- as.integer(lags)
- function (y) .Call(
- probe_acf,
- x=transform(y[var,,drop=FALSE]),
- lags=lags,
- corr=corr
- )
-}
-
-probe.ccf <- function (vars, lags, type = c("covariance", "correlation"), transform = identity) {
- type <- match.arg(type)
- corr <- type=="correlation"
- transform <- match.fun(transform)
- if (length(vars)!=2)
- stop(sQuote("vars")," must name two variables")
- lags <- as.integer(lags)
- function (y) .Call(
- probe_ccf,
- x=transform(y[vars[1],,drop=TRUE]),
- y=transform(y[vars[2],,drop=TRUE]),
- lags=lags,
- corr=corr
- )
-}
-
-probe.marginal <- function (var, ref, order = 3, diff = 1, transform = identity) {
- if (length(var)>1) stop(sQuote("probe.marginal")," is a univariate probe")
- transform <- match.fun(transform)
- setup <- .Call(probe_marginal_setup,transform(ref),order,diff)
- function (y) .Call(
- probe_marginal_solve,
- x=transform(y[var,,drop=TRUE]),
- setup=setup,
- diff=diff
- )
-}
-
-probe.nlar <- function (var, lags, powers, transform = identity) {
- if (length(var)>1) stop(sQuote("probe.nlar")," is a univariate probe")
- transform <- match.fun(transform)
- if (any(lags<1)||any(powers<1))
- stop(sQuote("lags")," and ",sQuote("powers")," must be positive integers")
- if (length(lags)<length(powers)) {
- if (length(lags)>1) stop(sQuote("lags")," must match ",sQuote("powers")," in length, or have length 1")
- lags <- rep(lags,length(powers))
- } else if (length(lags)>length(powers)) {
- if (length(powers)>1) stop(sQuote("powers")," must match ",sQuote("lags")," in length, or have length 1")
- powers <- rep(powers,length(lags))
- }
- lags <- as.integer(lags)
- powers <- as.integer(powers)
- function (y) .Call(
- probe_nlar,
- x=transform(y[var,,drop=TRUE]),
- lags=lags,
- powers=powers
- )
-}
Deleted: branches/premif2/R/bsmc.R
===================================================================
--- branches/premif2/R/bsmc.R 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/R/bsmc.R 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,409 +0,0 @@
-## Bayesian particle filtering codes
-##
-## in annotation L&W AGM == Liu & West "A General Algorithm"
-##
-## params = the initial particles for the parameter values;
-## these should be drawn from the prior distribution for the parameters
-## est = names of parameters to estimate; other parameters are not updated.
-## smooth = parameter 'h' from AGM
-## ntries = number of samplesto draw from x_{t+1} | x(k)_{t} to estimate
-## mean of mu(k)_t+1 as in sect 2.2 Liu & West
-## lower = lower bounds on prior
-## upper = upper bounds on prior
-
-setClass(
- "bsmcd.pomp",
- contains="pomp",
- representation=representation(
- transform="logical",
- post="array",
- prior="array",
- est="character",
- eff.sample.size="numeric",
- smooth="numeric",
- seed="integer",
- nfail="integer",
- cond.log.evidence="numeric",
- log.evidence="numeric",
- weights="numeric"
- )
- )
-
-setGeneric("bsmc",function(object,...)standardGeneric("bsmc"))
-
-setMethod(
- "bsmc",
- "pomp",
- function (object, params, Np, est,
- smooth = 0.1,
- ntries = 1,
- tol = 1e-17,
- lower = -Inf, upper = Inf,
- seed = NULL,
- verbose = getOption("verbose"),
- max.fail = 0,
- transform = FALSE,
- ...) {
-
- transform <- as.logical(transform)
-
- if (missing(seed)) seed <- NULL
- if (!is.null(seed)) {
- if (!exists(".Random.seed",where=.GlobalEnv))
- runif(1) ## need to initialize the RNG
- save.seed <- get(".Random.seed",pos=.GlobalEnv)
- set.seed(seed)
- }
-
- error.prefix <- paste(sQuote("bsmc"),"error: ")
-
- if (missing(params)) {
- if (length(coef(object))>0) {
- params <- coef(object)
- } else {
- stop(error.prefix,sQuote("params")," must be supplied",call.=FALSE)
- }
- }
-
- if (missing(Np)) Np <- NCOL(params)
- else if (is.matrix(params)&&(Np!=ncol(params)))
- warning(sQuote("Np")," is ignored when ",sQuote("params")," is a matrix")
-
- if (transform)
- params <- partrans(object,params,dir="inverse")
-
- ntimes <- length(time(object))
- if (is.null(dim(params))) {
- params <- matrix(
- params,
- nrow=length(params),
- ncol=Np,
- dimnames=list(
- names(params),
- NULL
- )
- )
- }
-
- npars <- nrow(params)
- paramnames <- rownames(params)
- prior <- params
-
- if (missing(est))
- est <- paramnames[apply(params,1,function(x)diff(range(x))>0)]
- estind <- match(est,paramnames)
- npars.est <- length(estind)
-
- if (npars.est<1)
- stop(error.prefix,"no parameters to estimate",call.=FALSE)
-
- if (is.null(paramnames))
- stop(error.prefix,sQuote("params")," must have rownames",call.=FALSE)
-
- if ((length(smooth)!=1)||(smooth>1)||(smooth<=0))
- stop(error.prefix,sQuote("smooth")," must be a scalar in [0,1)",call.=FALSE)
-
- hsq <- smooth^2 # see Liu & West eq(3.6) p10
- shrink <- sqrt(1-hsq)
-
- if (
- ((length(lower)>1)&&(length(lower)!=npars.est))||
- ((length(upper)>1)&&(length(upper)!=npars.est))
- ) {
- stop(
- error.prefix,
- sQuote("lower")," and ",sQuote("upper"),
- " must each have length 1 or length equal to that of ",sQuote("est"),
- call.=FALSE
- )
- }
-
- for (j in seq_len(Np)) {
- if (any((params[estind,j]<lower)|(params[estind,j]>upper))) {
- ind <- which((params[estind,j]<lower)|(params[estind,j]>upper))
- stop(
- error.prefix,
- "parameter(s) ",paste(paramnames[estind[ind]],collapse=","),
- " in column ",j," in ",sQuote("params"),
- " is/are outside the box defined by ",
- sQuote("lower")," and ",sQuote("upper"),
- call.=FALSE
- )
- }
- }
-
- xstart <- init.state(
- object,
- params=if (transform) {
- partrans(object,params,dir="forward")
- } else {
- params
- }
- )
- statenames <- rownames(xstart)
- nvars <- nrow(xstart)
-
- times <- time(object,t0=TRUE)
- x <- xstart
-
- evidence <- rep(NA,ntimes)
- eff.sample.size <- rep(NA,ntimes)
- nfail <- 0
-
- mu <- array(data=NA,dim=c(nvars,Np,1))
- rownames(mu) <- rownames(xstart)
- m <- array(data=NA,dim=c(npars,Np))
- rownames(m) <- rownames(params)
-
- for (nt in seq_len(ntimes)) {
-
- ## calculate particle means ; as per L&W AGM (1)
- params.mean <- apply(params,1,mean)
- ## calculate particle covariances : as per L&W AGM (1)
- params.var <- cov(t(params[estind,,drop=FALSE]))
-
- if (verbose) {
- cat("at step",nt,"(time =",times[nt+1],")\n")
- print(
- rbind(
- prior.mean=params.mean[estind],
- prior.sd=sqrt(diag(params.var))
- )
- )
- }
-
- ## update mean of states at time nt as per L&W AGM (1)
- tries <- rprocess(
- object,
- xstart=parmat(x,nrep=ntries),
- times=times[c(nt,nt+1)],
- params=if (transform) {
- partrans(object,params,dir="forward")
- } else {
- params
- },
- offset=1
- )
- dim(tries) <- c(nvars,Np,ntries,1)
- mu <- apply(tries,c(1,2,4),mean)
- rownames(mu) <- statenames
- ## shrink parameters towards mean as per Liu & West eq (3.3) and L&W AGM (1)
- m <- shrink*params+(1-shrink)*params.mean
-
- ## evaluate probability of obervation given mean value of parameters and states (used in L&W AGM (5) below)
- g <- dmeasure(
- object,
- y=object at data[,nt,drop=FALSE],
- x=mu,
- times=times[nt+1],
- params=if (transform) {
- partrans(object,m,dir="forward")
- } else {
- m
- }
- )
- storeForEvidence1 <- log(sum(g))
- ## sample indices -- From L&W AGM (2)
-## k <- .Call(systematic_resampling,g)
- k <- sample.int(n=Np,size=Np,replace=TRUE,prob=g)
- params <- params[,k]
- m <- m[,k]
- g <- g[k]
-
- ## sample new parameter vector as per L&W AGM (3) and Liu & West eq(3.2)
- pvec <- try(
- mvtnorm::rmvnorm(
- n=Np,
- mean=rep(0,npars.est),
- sigma=hsq*params.var,
- method="svd"
- ),
- silent=FALSE
- )
- if (inherits(pvec,"try-error"))
- stop(error.prefix,"error in ",sQuote("rmvnorm"),call.=FALSE)
- if (any(!is.finite(pvec)))
- stop(error.prefix,"extreme particle depletion",call.=FALSE)
- params[estind,] <- m[estind,]+t(pvec)
-
- if (transform)
- tparams <- partrans(object,params,dir="forward")
-
- ## sample current state vector x^(g)_(t+1) as per L&W AGM (4)
- X <- rprocess(
- object,
- xstart=x[,k,drop=FALSE],
- times=times[c(nt,nt+1)],
- params=if (transform) {
- tparams
- } else {
- params
- },
- offset=1
- )
-
- ## evaluate likelihood of observation given X (from L&W AGM (4))
- numer <- dmeasure(
- object,
- y=object at data[,nt,drop=FALSE],
- x=X,
- times=times[nt+1],
- params=if (transform) {
- tparams
- } else {
- params
- }
- )
- ## evaluate weights as per L&W AGM (5)
-
- weights <- numer/g
- storeForEvidence2 <- log(mean(weights))
-
- ## apply box constraints as per the priors
- for (j in seq_len(Np)) {
- ## the following seems problematic: will it tend to make the boundaries repellors
- if (any((params[estind,j]<lower)|(params[estind,j]>upper))) {
- weights[j] <- 0
- }
- ## might this rejection method be preferable?
- ## while (any((params[estind,j]<lower)|(params[estind,j]>upper))) {
- ## ## rejection method
- ## pvec <- try(
- ## mvtnorm::rmvnorm(
- ## n=1,
- ## mean=rep(0,npars.est),
- ## sigma=hsq*params.var,
- ## method="eigen"
- ## ),
- ## silent=FALSE
- ## )
- ## if (inherits(pvec,"try-error"))
- ## stop(error.prefix,"error in ",sQuote("rmvnorm"),call.=FALSE)
- ## if (any(!is.finite(pvec)))
- ## stop(error.prefix,"extreme particle depletion",call.=FALSE)
- ## params[estind,j] <- m[estind,j]+pvec[1,]
- ## }
- }
-
- x[,] <- X
-
- ## test for failure to filter
- dim(weights) <- NULL
- failures <- ((weights<tol)|(!is.finite(weights))) # test for NA weights
- all.fail <- all(failures)
- if (all.fail) { # all particles are lost
- if (verbose) {
- message("filtering failure at time t = ",times[nt+1])
- }
- nfail <- nfail+1
- if (nfail > max.fail)
- stop(error.prefix,"too many filtering failures",call.=FALSE)
- evidence[nt] <- log(tol) # worst log-likelihood
- weights <- rep(1/Np,Np)
- eff.sample.size[nt] <- 0
- } else { # not all particles are lost
- ## compute log-likelihood
- evidence[nt] <- storeForEvidence1+storeForEvidence2
- weights[failures] <- 0
- weights <- weights/sum(weights)
- ## compute effective sample-size
- eff.sample.size[nt] <- 1/crossprod(weights)
- }
-
- if (verbose) {
- cat("effective sample size =",round(eff.sample.size[nt],1),"\n")
- }
-
- ## Matrix with samples (columns) from filtering distribution theta.t | Y.t
- if (!all.fail) {
- ## smp <- .Call(systematic_resampling,weights)
- smp <- sample.int(n=Np,size=Np,replace=TRUE,prob=weights)
- x <- x[,smp,drop=FALSE]
- params[estind,] <- params[estind,smp,drop=FALSE]
- }
-
- }
-
- if (!is.null(seed)) {
- assign(".Random.seed",save.seed,pos=.GlobalEnv)
- seed <- save.seed
- }
-
- ## if (transform) {
- ## params <- partrans(object,params,dir="forward")
- ## prior <- partrans(object,prior,dir="forward")
- ## }
-
- ## replace parameters with point estimate (posterior median)
- coef(object,transform=transform) <- apply(params,1,median)
-
- new(
- "bsmcd.pomp",
- object,
- transform=transform,
- post=params,
- prior=prior,
- est=as.character(est),
- eff.sample.size=eff.sample.size,
- smooth=smooth,
- seed=as.integer(seed),
- nfail=as.integer(nfail),
- cond.log.evidence=evidence,
- log.evidence=sum(evidence),
- weights=weights
- )
- }
- )
-
-setMethod("$",signature(x="bsmcd.pomp"),function (x,name) slot(x,name))
-
-bsmc.plot <- function (prior, post, pars, thin, ...) {
- p1 <- sample.int(n=ncol(prior),size=min(thin,ncol(prior)))
- p2 <- sample.int(n=ncol(post),size=min(thin,ncol(post)))
- if (!all(pars%in%rownames(prior))) {
- missing <- which(!(pars%in%rownames(prior)))
- stop("unrecognized parameters: ",paste(sQuote(pars[missing]),collapse=","))
-
- }
- prior <- t(prior[pars,])
- post <- t(post[pars,])
- all <- rbind(prior,post)
- pairs(
- all,
- labels=pars,
- panel=function (x, y, ...) { ## prior, posterior pairwise scatterplot
- op <- par(new=TRUE)
- on.exit(par(op))
- i <- which(x[1]==all[1,])
- j <- which(y[1]==all[1,])
- points(prior[p1,i],prior[p1,j],pch=20,col=rgb(0.85,0.85,0.85,0.1),xlim=range(all[,i]),ylim=range(all[,j]))
- points(post[p2,i],post[p2,j],pch=20,col=rgb(0,0,1,0.01))
- },
- diag.panel=function (x, ...) { ## marginal posterior histogram
- i <- which(x[1]==all[1,])
- d1 <- density(prior[,i])
- d2 <- density(post[,i])
- usr <- par('usr')
- op <- par(usr=c(usr[1:2],0,1.5*max(d1$y,d2$y)))
- on.exit(par(op))
- polygon(d1,col=rgb(0.85,0.85,0.85,0.5))
- polygon(d2,col=rgb(0,0,1,0.5))
- }
- )
-}
-
-setMethod(
- "plot",
- signature(x="bsmcd.pomp"),
- function (x, ..., pars, thin) {
- if (missing(pars)) pars <- names(coef(x,transform=!x at transform))
- if (missing(thin)) thin <- Inf
- bsmc.plot(
- prior=if (x at transform) partrans(x,x at prior,dir="forward") else x at prior,
- post=if (x at transform) partrans(x,x at post,dir="forward") else x at post,
- pars=pars,
- thin=thin,
- ...
- )
- }
- )
Deleted: branches/premif2/R/bsplines.R
===================================================================
--- branches/premif2/R/bsplines.R 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/R/bsplines.R 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,33 +0,0 @@
-bspline.basis <- function (x, nbasis, degree = 3, names = NULL) {
- y <- .Call(bspline_basis,x,nbasis,degree)
- if (!is.null(names)) {
- if (length(names)==1) {
- nm <- sprintf(names,seq_len(nbasis))
- if (length(unique(nm))!=nbasis)
- nm <- paste(names,seq_len(nbasis),sep=".")
- colnames(y) <- nm
- } else if (length(names)==nbasis) {
- colnames(y) <- names
- } else {
- stop(sQuote("length(names)")," must be either 1 or ",nbasis)
- }
- }
- y
-}
-
-periodic.bspline.basis <- function (x, nbasis, degree = 3, period = 1, names = NULL) {
- y <- .Call(periodic_bspline_basis,x,nbasis,degree,period)
- if (!is.null(names)) {
- if (length(names)==1) {
- nm <- sprintf(names,seq_len(nbasis))
- if (length(unique(nm))!=nbasis)
- nm <- paste(names,seq_len(nbasis),sep=".")
- colnames(y) <- nm
- } else if (length(names)==nbasis) {
- colnames(y) <- names
- } else {
- stop(sQuote("length(names)")," must be either 1 or ",nbasis)
- }
- }
- y
-}
Deleted: branches/premif2/R/builder.R
===================================================================
--- branches/premif2/R/builder.R 2014-06-27 19:50:35 UTC (rev 988)
+++ branches/premif2/R/builder.R 2014-06-29 12:21:37 UTC (rev 989)
@@ -1,284 +0,0 @@
-setClass(
- "pompCode",
- representation=representation(
- type="character",
- slot="character",
- text="character",
- fun="function"
- ),
- prototype=prototype(
- type="ccode",
- slot=character(0),
- text=character(0),
- fun=function(...)stop("function not specified")
- )
- )
-
-
-CCode <- function (text, slot) {
- new("pompCode",type="ccode",slot=as.character(slot))
-}
-
-pompBuilder <- function (data, times, t0, name,
- statenames, paramnames, tcovar, covar,
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/pomp -r 989
More information about the pomp-commits
mailing list