View source: R/class_prediction.R
prediction | R Documentation |
Creates a new instance of a 'prediction' object
prediction(
X,
spagFiles,
data.dir = getwd(),
data.fnames = paste0("X", 1:length(X), ".pred"),
fname = paste0("Config_Pred_", paste0(sample(c(letters, LETTERS, 0:9), 6), collapse =
""), ".txt"),
doParametric = FALSE,
doStructural = rep(FALSE, length(spagFiles)),
transposeSpag = TRUE,
priorNsim = NULL,
envFiles = paste0(tools::file_path_sans_ext(spagFiles), ".env"),
consoleProgress = TRUE,
spagFiles_state = NULL,
transposeSpag_state = TRUE,
envFiles_state = switch(is.null(spagFiles_state) + 1,
paste0(tools::file_path_sans_ext(spagFiles_state), ".env"), NULL),
parSamples = NULL
)
X |
data frame or list of dataframes / matrices, representing the values taken by the input variables.
|
spagFiles |
Character vector (size nY, the number of output variables). Name of the files containing the spaghettis for each output variable. NOTE: provide file names only, not full paths. Using a '.spag' extension is a good practice. |
data.dir |
Character, directory where a copies of the dataset X will be written if required (1 file per variable in X). Default is the current working directory, but you may prefer to use the BaM workspace. |
data.fnames |
Character, data file names. |
fname |
Character, configuration file name. |
doParametric |
Logical, propagate parametric uncertainty? If FALSE, maxpost parameters are used. |
doStructural |
Logical, propagate structural uncertainty for each output variable? (size nY) |
transposeSpag |
Logical. If FALSE, spaghettis are written horizontally (row-wise), otherwise they will be transposed so that each spaghetti is a column. |
priorNsim |
Integer, number of samples from the prior distribution for 'prior prediction' experiments. If negative or NULL (default), posterior samples are used. |
envFiles |
Character vector (size nY, the number of output variables). Name of the files containing the envelops (e.g. prediction intervals) computed from the spaghettis for each output variable. By default, same name as spaghetti files but with a '.env' extension. If NULL, envelops are not computed. |
consoleProgress |
Logical, print progress in BaM.exe console? |
spagFiles_state |
Character vector (size nState, the number of state variables), same as spagFiles but for states rather than outputs. If NULL, states are not predicted. Note that only parametric uncertainty is propagated for state variables since they are not observed. Consequently, structural uncertainty = 0 and total uncertainty = parametric uncertainty. |
transposeSpag_state |
Logical. Same as transposeSpag, but for states rather than outputs. |
envFiles_state |
Character vector (size nState, the number of state variables), same as envFiles, but for states rather than outputs. |
parSamples |
data frame, parameter samples that will replace the MCMC-generated one for this prediction. |
An object of class 'prediction'.
#--------------
# Example using the twoPopulations dataset, containing 101 values for
# 3 input variables (time t, temperature at site 1 T1, temperature at site 2 T2)
# and 2 output variables (population at site 1 P1, population at site 2 P2).
pred=prediction(X=twoPopulations[,1:3],spagFiles=c('P1.spag','P2.spag'))
#--------------
# Alternative example showing how to propagate uncertainty in some of
# the input variables (here, temperatures T1 and T2)
# Create 100 noisy replicates for T1, representing uncertainty
T1rep=matrix(rnorm(101*100,mean=twoPopulations$T1,sd=0.1),nrow=101,ncol=100)
# Same for T2
T2rep=matrix(rnorm(101*100,mean=twoPopulations$T2,sd=0.1),nrow=101,ncol=100)
# Create prediction object
pred=prediction(X=list(twoPopulations$t,T1rep,T2rep),spagFiles=c('P1.spag','P2.spag'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.