[Pomp-commits] r878 - in pkg/pomp: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jan 10 20:50:48 CET 2014
Author: kingaa
Date: 2014-01-10 20:50:48 +0100 (Fri, 10 Jan 2014)
New Revision: 878
Modified:
pkg/pomp/R/logmeanexp.R
pkg/pomp/man/logmeanexp.Rd
Log:
- add 'se' argument to 'logmeanexp'
Modified: pkg/pomp/R/logmeanexp.R
===================================================================
--- pkg/pomp/R/logmeanexp.R 2014-01-09 16:12:09 UTC (rev 877)
+++ pkg/pomp/R/logmeanexp.R 2014-01-10 19:50:48 UTC (rev 878)
@@ -1,4 +1,10 @@
-logmeanexp <- function (x) {
+logmeanexp <- function (x, se = FALSE) {
mx <- max(x)
- mx+log(mean(exp(x-mx)))
+ mean <- mx+log(mean(exp(x-mx)))
+ if (se) {
+ se <- sd(exp(x-mx))/exp(mean-mx)
+ c(mean,se=se)
+ } else {
+ mean
+ }
}
Modified: pkg/pomp/man/logmeanexp.Rd
===================================================================
--- pkg/pomp/man/logmeanexp.Rd 2014-01-09 16:12:09 UTC (rev 877)
+++ pkg/pomp/man/logmeanexp.Rd 2014-01-10 19:50:48 UTC (rev 878)
@@ -5,13 +5,15 @@
\code{logmeanexp} computes the log-mean-exp of a set of numbers.
}
\usage{
-logmeanexp(x)
+logmeanexp(x, se = FALSE)
}
\arguments{
\item{x}{numeric}
+ \item{se}{logical; give approximate standard error?}
}
\value{
\code{log(mean(exp(x)))} computed so as to avoid over- or underflow.
+ If \code{se = FALSE}, the approximate standard error is returned as well.
}
\author{Aaron A. King \email{kingaa at umich dot edu}}
\examples{
@@ -20,4 +22,5 @@
ll <- replicate(n=5,logLik(pfilter(ricker,Np=1000)))
## an estimate of the log likelihood:
logmeanexp(ll)
+ logmeanexp(ll,se=TRUE)
}
More information about the pomp-commits
mailing list