[Pomp-commits] r343 - in pkg: man tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 29 03:03:15 CEST 2010
Author: kingaa
Date: 2010-09-29 03:03:14 +0200 (Wed, 29 Sep 2010)
New Revision: 343
Modified:
pkg/man/basic-probes.Rd
pkg/tests/ricker-probe.Rout.save
Log:
- update documentation with an entry for 'probe.nlar'
Modified: pkg/man/basic-probes.Rd
===================================================================
--- pkg/man/basic-probes.Rd 2010-09-28 19:26:17 UTC (rev 342)
+++ pkg/man/basic-probes.Rd 2010-09-29 01:03:14 UTC (rev 343)
@@ -6,10 +6,11 @@
\alias{probe.sd}
\alias{probe.period}
\alias{probe.quantile}
-\alias{probe.acf}
\alias{probe.cov}
\alias{probe.cor}
+\alias{probe.acf}
\alias{probe.marginal}
+\alias{probe.nlar}
\title{Some probes for partially-observed Markov processes}
\description{
Several simple and configurable probes are provided in the package.
@@ -21,6 +22,7 @@
probe.var(var, transform = identity, na.rm = TRUE)
probe.sd(var, transform = identity, na.rm = TRUE)
probe.marginal(var, ref, order = 3, diff = 1, transform = identity)
+probe.nlar(var, lags, powers, transform = identity)
probe.acf(var, lag.max, type = c("covariance", "correlation"),
transform = identity)
probe.cov(vars, lag, method = c("pearson", "kendall", "spearman"),
@@ -72,6 +74,10 @@
The resulting regression coefficients capture information about the shape of the marginal distribution.
A good choice for \code{ref} is the data itself.
}
+ \item{lags, powers}{
+ the lags and powers, respectively, specifying the nonlinear autoregressive model that will be fit to the actual and simulated data.
+ See Details, below, for a precise description.
+ }
\item{order}{
order of polynomial regression.
}
@@ -103,6 +109,13 @@
Polynomial regression of order \code{order} is used.
This probe returns \code{order} regression coefficients (the intercept is zero).
}
+ \item{\code{probe.nlar}}{
+ returns a function that
+ fit a nonlinear (polynomial) autoregressive model to the univariate series (variable \code{var}).
+ Specifically, a model of the form \eqn{y_t = \sum \beta_k y_{t-\tau_k}^{p_k}+\epsilon_t}{y[t] = \sum beta[k] y[t-tau[k]]^p[k]+e[t]} will be fit, where \eqn{\tau_k}{tau[k]} are the \code{lags} and \eqn{p_k}{p[k]} are the \code{powers}.
+ The data are first centered.
+ This function returns the regression coefficients, \eqn{\beta_k}{beta[k]}.
+ }
\item{\code{probe.acf}}{
returns a function that,
if \code{type=="covariance"}, computes the autocovariance function of variable \code{var} at lags 0 through \code{lag.max};
Modified: pkg/tests/ricker-probe.Rout.save
===================================================================
--- pkg/tests/ricker-probe.Rout.save 2010-09-28 19:26:17 UTC (rev 342)
+++ pkg/tests/ricker-probe.Rout.save 2010-09-29 01:03:14 UTC (rev 343)
@@ -25,6 +25,7 @@
> z <- as.numeric(data.array(ricker))
>
> po <- ricker
+>
> pb <- probe(
+ po,
+ probes=probe.median("y"),
@@ -49,6 +50,78 @@
>
> pb <- probe(
+ po,
++ probes=probe.nlar("y",lags=c(1,2,3),powers=c(1,1,1),transform="sqrt"),
++ nsim=1000,
++ seed=838775L
++ )
+> plot(pb)
+> summary(pb)
+$coef
+ log.r log.sigma log.phi N.0 e.0
+ 3.800000 -1.203973 2.302585 7.000000 0.000000
+
+$nsim
+[1] 1000
+
+$quantiles
+nlar.1^1 nlar.2^1 nlar.3^1
+ 0.225 0.246 0.801
+
+$pvals
+ nlar.1^1 nlar.2^1 nlar.3^1
+0.4515485 0.4935065 0.3996004
+
+>
+> pb <- probe(
++ po,
++ probes=probe.nlar("y",lags=c(1,2,3),powers=1,transform="sqrt"),
++ nsim=1000,
++ seed=838775L
++ )
+> plot(pb)
+> summary(pb)
+$coef
+ log.r log.sigma log.phi N.0 e.0
+ 3.800000 -1.203973 2.302585 7.000000 0.000000
+
+$nsim
+[1] 1000
+
+$quantiles
+nlar.1^1 nlar.2^1 nlar.3^1
+ 0.225 0.246 0.801
+
+$pvals
+ nlar.1^1 nlar.2^1 nlar.3^1
+0.4515485 0.4935065 0.3996004
+
+>
+> pb <- probe(
++ po,
++ probes=probe.nlar("y",lags=1,powers=c(1,2,3),transform="sqrt"),
++ nsim=1000,
++ seed=838775L
++ )
+> plot(pb)
+> summary(pb)
+$coef
+ log.r log.sigma log.phi N.0 e.0
+ 3.800000 -1.203973 2.302585 7.000000 0.000000
+
+$nsim
+[1] 1000
+
+$quantiles
+nlar.1^1 nlar.1^2 nlar.1^3
+ 0.440 0.746 0.332
+
+$pvals
+ nlar.1^1 nlar.1^2 nlar.1^3
+0.8811189 0.5094905 0.6653347
+
+>
+> pb <- probe(
++ po,
+ probes=probe.marginal(
+ var="y",
+ transform=sqrt,
@@ -60,8 +133,8 @@
+ seed=838775L
+ )
> pb at datvals
-od.1 od.2 od.3
- 1 0 0
+marg.1 marg.2 marg.3
+ 1 0 0
> summary(pb)
$coef
log.r log.sigma log.phi N.0 e.0
@@ -71,11 +144,11 @@
[1] 1000
$quantiles
- od.1 od.2 od.3
-0.731 0.304 0.345
+marg.1 marg.2 marg.3
+ 0.731 0.304 0.345
$pvals
- od.1 od.2 od.3
+ marg.1 marg.2 marg.3
0.5394605 0.6093906 0.6913087
> plot(pb)
@@ -100,7 +173,7 @@
+ seed=838775L
+ )
> pb at datvals
- od.1 od.2 od.3 acf.0.y acf.1.y acf.2.y
+ marg.1 marg.2 marg.3 acf.0.y acf.1.y acf.2.y
1.000000 0.000000 0.000000 3486.365244 -1157.950734 -629.406461
acf.3.y acf.4.y acf.5.y mean
409.878220 -557.216308 406.454875 4.419695
@@ -113,11 +186,11 @@
[1] 1000
$quantiles
- od.1 od.2 od.3 acf.0.y acf.1.y acf.2.y acf.3.y acf.4.y acf.5.y mean
+ marg.1 marg.2 marg.3 acf.0.y acf.1.y acf.2.y acf.3.y acf.4.y acf.5.y mean
0.731 0.304 0.345 0.545 0.202 0.443 0.913 0.119 0.744 0.841
$pvals
- od.1 od.2 od.3 acf.0.y acf.1.y acf.2.y acf.3.y acf.4.y
+ marg.1 marg.2 marg.3 acf.0.y acf.1.y acf.2.y acf.3.y acf.4.y
0.5394605 0.6093906 0.6913087 0.9110889 0.4055944 0.8871129 0.1758242 0.2397602
acf.5.y mean
0.5134865 0.3196803
@@ -139,8 +212,8 @@
+ seed=838775L
+ )
> pb at datvals
-od.1 od.2 od.3
- 1 0 0
+marg.1 marg.2 marg.3
+ 1 0 0
> summary(pb)
$coef
log.r log.sigma log.phi N.0 e.0
@@ -150,11 +223,11 @@
[1] 1000
$quantiles
- od.1 od.2 od.3
-1.000 0.119 0.252
+marg.1 marg.2 marg.3
+ 1.000 0.119 0.252
$pvals
- od.1 od.2 od.3
+ marg.1 marg.2 marg.3
0.001998002 0.239760240 0.505494505
> plot(pb)
@@ -172,7 +245,7 @@
+ )
+ )
user system elapsed
- 10.083 0.030 10.115
+ 10.040 0.015 10.056
> plot(pm)
>
> cbind(truth=coef(ricker),est=coef(pm),guess=coef(po))
@@ -185,6 +258,62 @@
>
> pb <- probe(
+ po,
++ probes=probe.nlar(
++ var="y",
++ transform=sqrt,
++ lags=1,
++ powers=c(1,2,3)
++ ),
++ nsim=1000,
++ seed=838775L
++ )
+> pb at datvals
+ nlar.1^1 nlar.1^2 nlar.1^3
+-0.48035604 -0.12200818 0.01188791
+> summary(pb)
+$coef
+ log.r log.sigma log.phi N.0 e.0
+ 2.302585 -1.203973 2.995732 5.000000 0.000000
+
+$nsim
+[1] 1000
+
+$quantiles
+nlar.1^1 nlar.1^2 nlar.1^3
+ 1.000 0.053 0.063
+
+$pvals
+ nlar.1^1 nlar.1^2 nlar.1^3
+0.001998002 0.107892108 0.127872128
+
+> plot(pb)
+>
+> system.time(
++ pm <- probe.match(
++ pb,
++ est=c("log.r","log.phi","N.0"),
++ parscale=c(0.1,0.1,0.1),
++ nsim=1000,
++ seed=838775L,
++ method="Nelder-Mead",
++ reltol=1e-7,
++ fail.value=1e9
++ )
++ )
+ user system elapsed
+ 6.325 0.006 6.333
+> plot(pm)
+>
+> cbind(truth=coef(ricker),est=coef(pm),guess=coef(po))
+ truth est guess
+log.r 3.800000 1.636451 2.302585
+log.sigma -1.203973 -1.203973 -1.203973
+log.phi 2.302585 3.438907 2.995732
+N.0 7.000000 5.375076 5.000000
+e.0 0.000000 0.000000 0.000000
+>
+> pb <- probe(
++ po,
+ probes=probe.marginal(
+ var="y",
+ transform=sqrt,
@@ -196,7 +325,7 @@
+ seed=838775L
+ )
> pb at datvals
- od.1 od.2 od.3
+ marg.1 marg.2 marg.3
27.509248 -4.882377 -3.481160
> summary(pb)
$coef
@@ -207,11 +336,11 @@
[1] 1000
$quantiles
- od.1 od.2 od.3
-1.000 0.000 0.255
+marg.1 marg.2 marg.3
+ 1.000 0.000 0.255
$pvals
- od.1 od.2 od.3
+ marg.1 marg.2 marg.3
0.001998002 0.001998002 0.511488511
> plot(pb)
@@ -287,16 +416,22 @@
+ probe.acf(
+ var="y",
+ transform=sqrt,
-+ lag.max=0,
++ lag.max=2,
+ type="cov"
-+ )
++ ),
++ probe.nlar(
++ var="y",
++ transform=sqrt,
++ lags=c(1,2),
++ powers=1
++ )
+ ),
+ nsim=1000,
+ seed=838775L
+ )
> pb at datvals
- v acf.0.y
-21.33562 20.91728
+ v acf.0.y acf.1.y acf.2.y nlar.1^1 nlar.2^1
+21.3356248 20.9172792 -6.5053300 -5.1051986 -0.4337480 -0.3889323
> summary(pb)
$coef
log.r log.sigma log.phi N.0 e.0
@@ -306,12 +441,12 @@
[1] 1000
$quantiles
- v acf.0.y
- 0.424 0.424
+ v acf.0.y acf.1.y acf.2.y nlar.1^1 nlar.2^1
+ 0.424 0.424 0.171 0.294 0.143 0.139
$pvals
- v acf.0.y
-0.8491508 0.8491508
+ v acf.0.y acf.1.y acf.2.y nlar.1^1 nlar.2^1
+0.8491508 0.8491508 0.3436563 0.5894106 0.2877123 0.2797203
> plot(pb)
>
@@ -361,7 +496,6 @@
Error in .local(object, probes, ...) :
probes return different number of values on different datasets
>
->
> dev.off()
null device
1
More information about the pomp-commits
mailing list