https://github.com/cran/ensembleBMA
Tip revision: f5ae722309f273a5b3e5fae294b71d73501cec72 authored by Chris Fraley on 15 July 2013, 00:00:00 UTC
version 5.0.4
version 5.0.4
Tip revision: f5ae722
plot.fitBMAgamma0.R
plot.fitBMAgamma0 <-
function(x, ensembleData, dates=NULL, ...)
{
#
# copyright 2006-present, University of Washington. All rights reserved.
# for terms of use, see the LICENSE file
#
exchangeable <- x$exchangeable
powfun <- function(x,power) x^power
powinv <- function(x,power) x^(1/power)
weps <- 1.e-4
if (!is.null(dates)) warning("dates ignored")
ensembleData <- ensembleData[,matchEnsembleMembers(x,ensembleData)]
M <- !dataNA(ensembleData,dates=FALSE)
if (!all(M)) ensembleData <- ensembleData[M,]
fitDates <- modelDates(x)
M <- matchDates( fitDates, ensembleValidDates(ensembleData), dates=NULL)
if (!all(M$ens)) ensembleData <- ensembleData[M$ens,]
if (!all(M$fit)) x <- x[fitDates[M$fit]]
obs <- dataVerifObs(ensembleData)
nObs <- length(obs)
if (nObs == 0) obs <- rep( NA, nrow(ensembleData))
nForecasts <- ensembleSize(ensembleData)
ensembleData <- ensembleForecasts(ensembleData)
WEIGHTS <- x$weights
if (!all(Wmiss <- is.na(WEIGHTS))) {
for (i in 1:nObs) {
f <- ensembleData[i,]
M <- is.na(f) | Wmiss
VAR <- x$varCoefs[1] + x$varCoefs[2]*f
fTrans <- sapply(f, powfun, power = x$power)
MEAN <- apply(rbind(1, fTrans) * x$biasCoefs, 2, sum)
PROB0 <- sapply(apply(rbind( 1, fTrans, f == 0)*x$prob0coefs,
2,sum), inverseLogit)
W <- WEIGHTS
if (any(M)) {
W <- W + weps
W <- W[!M]/sum(W[!M])
}
plotBMAgamma0(WEIGHTS = W, MEAN = MEAN[!M], VAR = VAR[!M],
PROB0 = PROB0[!M], obs = obs[i],
exchangeable = exchangeable)
}
}
invisible()
}