fetchBoth: Extract combined results from estimation and prediction.

View source: R/query-functions.R

fetchBothR Documentation

Extract combined results from estimation and prediction.

Description

Combined results from calling estimateModel followed by predictModel, estimateCounts followed by predictCounts, or estimateAccount followed by predictAccount. (Note - functions predictCounts, estimateAccount, and predictAccount have not been written yet.)

Usage

fetchBoth(filenameEst, filenamePred, where, iterations = NULL, impute = TRUE)

Arguments

filenameEst

The filename used for estimation.

filenamePred

The filename used for prediction.

where

A character vector describing the path to the item to be extracted.

iterations

A vector of positive integers giving the iterations to be extracted if an item has multiple iterations.

impute

Logical. Whether to impute missing values. Defaults to TRUE.

Details

Identical results can be obtained by calling fetch separately on the files created by the estimation and prediction functions, and then combining. However, fetchBoth is more convenient.

fetchBoth is particularly convenient in the case of main effects, since it normalises the combines the estimates and predictions before normalising, rather than normalising each separately. (See the documentation for fetch for a discussion of normalisation.)

See Also

Function fetch extracts results from a single file.

Examples

## Not run: 
deaths <- demdata::us.deaths
exposure <- demdata::us.exposure
deaths <- Counts(deaths,
                 dimscales = c(year = "Intervals"))
exposure <- Counts(exposure,
                   dimscales = c(year = "Intervals"))
filename.est <- tempfile()
filename.pred <- tempfile()
model <- Model(y ~ Poisson(mean ~ age + sex + year))
estimateModel(model,
              filename = filename.est,
              y = deaths,
              exposure = exposure,
              nBurnin = 5,
              nSim = 5,
              nChain = 2,
              parallel = FALSE)
predictModel(filenameEst = filename.est,
             filenamePred = filename.pred,
             n = 5)
## the model is too simple, and hasn't been run for long
## enough, but we'll extract some results anyway...
rate <- fetchBoth(filenameEst = filename.est,
                  filenamePred = filename.pred,
                  where = c("model", "likelihood", "rate"))
year <- fetchBoth(filenameEst = filename.est,
                  filenamePred = filename.pred,
                  where = c("model", "prior", "year"))

## End(Not run)

StatisticsNZ/demest documentation built on Nov. 2, 2023, 7:56 p.m.