Setup

Data Structures

ModelCalibration.BulkVarsStructType
BulkVarsStruct(theta::Array{Float64},sig2::Vector{Float64},tau2::Vector{Float64},
delta::Array{Float64},rho::Array{Float64},accept::Array{Bool},ratio::Array{Float64})

Data structure containing the samples and Metropolis-Hastings information from the Markov Chain Monte Carlo simulation sampling of the posterior distribution in the Bayesian model calibration.


Keyword arguments

  • theta::Array{Float64} An Array to store the samples of θ during the MCMC simulation, dimensions n and m.
  • sig2::Vector{Float64} A Vector to store the samples of σ^2 during the MCMC simulation, length n.
  • tau2::Vector{Float64} A Vector to store the samples of τ^2 during the MCMC simulation, length n.
  • delta::Array{Float64} An Array to store the samples of δ during the MCMC simulation, dimensions n and q.
  • rho::Array{Float64} An Array to store the samples of ρ during the MCMC simulation, dimensions n and p.
  • accept::Array{Bool} An Array to store the acceptance status of each Metropolis-Hastings update during the MCMC, dimensions n and p+m.
  • ratio::Array{Float64} An Array to store the acceptance probability of each Metropolis-Hastings update during the MCMC, dimensions n and p+m.
source
ModelCalibration.CovarParsType
CovarPars(ta2::Float64,rho::Float64,sig2::Float64)

Struct to store mutable params for covar construction.


Keyword arguments

  • sig2::Float64 Variance parameter for identity portion of covaraince.
  • rho::Float64 Correlation parameter.
  • tau2::Float64 Variance parameter for correlation portion of covariance.
source
ModelCalibration.DataStrType
DataStr(sim::SimStr,exp::ExpStr)

Structure containing both the computer simulator and experimental data structures.


Keyword arguments

  • sim::SimStr A data structure containing the computer simulator data
  • exp::ExpStr A data structure containing the experimental data
source
ModelCalibration.ExpStrType
ExpStr(x::Array{Float64},y::Array{Float64},x_reps::Array{Float64},y_reps::Vector{Float64})

Structure containing the experimental data to which the surrogate model is calibrated.


Keyword arguments

  • x::Array{Float64} Array containing all unique settings of the independent control variables in the experimental data. Dimensions n and p where n is the number of unique settings and p is the number of x variables.
  • y::Array{Float64} Array containing all repeated observations of the unique x settings in the experimental data. Dimensions n and m, where n is the number of unique x settings and m is the number of repeated observations.
  • x_reps::Array{Float64} Array containing all settings of the independednt control variables in the experimental data not trimmed to each be unique. Dimensions n*m and p.
  • y_reps::Vector{Float64} Vector containing all response observations in the experimental data not arranged based on unique locations, length n*m.
source
ModelCalibration.GridDataType
GridData(phi::GridPar,rho::GridPar)

Structure containing the grid information for ϕ and ρ for the Griddy Gibbs precomputation.


Keyword arguments

  • phi::GridPar Structure specifying the bounds and number of grid points to evaluate for ϕ during precomputation.
  • rho::GridPar Structure specifying the bounds and number of grid points to evaluate for ρ during precomputation. The bounds should be in (0,1).
source
ModelCalibration.GridParType
GridPar(density::Int,bounds::ScalePar)

Structure containing the density and bounds information of a parameter for the Griddy Gibbs precomputation.


Keyword arguments

  • density::Int Integer specifying the number of grid points for the parameter to use during precomputation.
  • bounds::ScalePar Data structure specifying the lower and upper bounds of the parameter to use for precomputation.
source
ModelCalibration.GriddyPosteriorsType
GriddyPosteriors(theta::Array{Float64},sig2::Vector{Float64},phi::Vector{Float64},
rho::Vector{Float64})

Struct to store the posterior samples from the griddy Gibbs sampler, converted from the posterior indices.


Keyword arguments

  • theta::Array{Float64} Array of unknown computer model parameter samples.
  • sig2::Vector{Float64} Vector of data model variance parameter samples.
  • phi::Vector{Float64} Vector of discrepancy variance parameter samples.
  • rho::Vector{Float64} Vector of discrepancy correlation parameter samples.
source
ModelCalibration.GriddyVarsStructType
GriddyVarsStruct(theta::Vector{Int},sig2::Vector{Float64},phi::Vector{Float64},
rho::Vector{Float64})

Data structure containing posterior index samples for the griddy Gibbs sampler.


Keyword arguments

  • theta::Vector{Int} A Vector to store the index of the values of θ during the MCMC simulation, length n.
  • sig2::Vector{Float64} A Vector to store the samples of τ^2 during the MCMC simulation, length n.
  • phi::Vector{Int} A Vector to store the samples of ϕ during the MCMC simulation, length n.
  • rho::Vector{Int} A Vector to store the samples of ρ during the MCMC simulation, length n.
source
ModelCalibration.MetropolisInfoType
MetropolisInfo(new_value::Float64,ratio::Float64,accept::Bool)

Structure used for storing the acceptance information for a single step in the Metropolis-Hastings algorithm.


Keyword arguments

  • new_value::Float64 The new value, θ^(t+1), for the Metropolis-Hastings algorithm. Taken as either θ* or θ^(t) based on acceptance criteria of the proposed value, θ*.
  • ratio::Float64 The acceptance probability, α, for the proposed value, calculated from p(θ*)/p(θt).
  • accept::Bool The logical value determining whether the proposed value was accepted or rejected.
source
ModelCalibration.PriorDataType
PriorData(theta::PriorVar,sig2::PriorVar,tau2::PriorVar,rho::PriorVar)

Structure containing the PriorVar prior distribution parameters for all parameters in the Bayesian calibration model.


Keyword arguments

  • theta::PriorVar Prior distribution parameters for the unknown model parameters, θ. The two prior parameters are m length Vectors containing minimum and maximum values corresponding to a uniform prior distribution for each of the m θ variables, respectively.
  • sig2::PriorVar Prior distribution parameters for the data error variance. The two prior parameters are the shapre (α) and scale (β) of an inverse gamma distribution, respectively.
  • tau2::PriorVar Prior distribution parameters for the discrepancy term variance. The two prior parameters are the shapre (α) and scale (β) of an inverse gamma distribution, respectively.
  • rho::PriorVar Prior distribution parameters for the discrepancy term correlation structure. The two parameters are p length Vectors containing the α and β parameters for a Beta distribution for each of the p x variables, respectively.
source
ModelCalibration.PriorVarType
PriorVar(par1::Union{Float64,Vector{Float64}},par2::Union{Float64,Vector{Float64}})

Structure containing prior distribution parameters. Currently, only two-parameter prior distributions are supported herein. Parameters are intended to be specified in the typical ordering. Ex: for a normal distribution, par1 = μ, par2 = σ Ex: for a uniform distribution, par1 = min, par2 = max


Keyword arguments

  • par1::Union{Float64,Vector{Float64}} The first parameter of the prior distribution
  • par2::Union{Float64,Vector{Float64}} The second parameter of the prior distribution
source
ModelCalibration.ScaleParType
ScalePar(min::Float64,max::Float64)

Structure containing the minimum and maximum vales for a variable.


Keyword arguments

  • min::Union{Float64,Vector{Float64}}
  • max::Union{Float64,Vector{Float64}}
source
ModelCalibration.ScalingType
Scaling(y::ScalePar,theta::ScalePar,x::ScalePar)

Structure containing scaling information for the response variable, y, and the unknown model parameters, θ.


Keyword arguments

  • y::ScalePar Scaling data for y.
  • theta::ScalePar Scaling data for theta.
  • x::ScalePar Scaling data for x.
source
ModelCalibration.SimStrType
SimStr(x::Array{Float64},y::Vector{Float64},theta::Array{Float64},x_reps::Array{Float64},
y_reps::Vector{Float64},theta_reps::Array{Float64})

Structure containing the data from the computer simulation, organized for building a surrogate model.


Keyword arguments

  • x::Array{Float64} Array containing independent control variable settings for the simulation data, of dimensions n and nx.
  • y::Array{Float64} Array containing the response variable outputs for the simulation data, of dimensions n and m.
  • theta::Array{Float64} Array containing the independent unknown variables for the simulation data, of dimensions m and ntheta.
  • x_reps::Array{Float64} Array containing independent control variable settings for the simulation data, of dimensions n*m and nx.
  • y_reps::Vector{Float64} Vector containing the response variable outputs for the simulation data, of length n*m.
  • theta_reps::Array{Float64} Array containing the independent unknown variables for the simulation data, of dimensions n*m and ntheta.
source
ModelCalibration.StepSizeType
StepSize(theta::Vector{Float64},rho::Vector{Float64})

Data structure containing the calculated optimal step sizes for θ and ρ for the Metropolis-Hastings algorithm


Keyword arguments

  • theta::Vector{Float64} A Vector of length m containin the optimal step sizes for each of the m θ for use in the Metropolis-Hastings algorithm.
  • rho::Vector{Float64} A Vector of length p containing the optimal step sizes for each of the p ρ for use in the Metropolis-Hastings algorithm.
source
ModelCalibration.UpdatedVarsType
UpdatedVars(theta::Vector{Float64},delta::Vector{Float64},sig2::Float64,tau2::Float64,rho::Vector{Float64})

Data structure containing the most recently sampled values for each parameter during the Markov Chain Monte Carlo simulation sampling of the posterior distribution in the Bayesian model calibration.


Keyword arguments

  • theta::Vector{Float64} A Vector of length m containing the most recently sampled values of each of the m θ parameters.
  • delta::Vector{Float64} A Vector of length q containing the most recently sampled values of δ.
  • sig2::Float64 The most recently sampled value of σ^2.
  • tau2::Float64 The most recently sampled value of τ^2.
  • rho::Vector{Float64} A Vector of length p containing the most recently sampled values of each of the p ρ parameters.
source

Data Setup

ModelCalibration.format_dataMethod
format_data(design::Array{Float64},simobs::Vector{Float64},expobs::Array{Float64},nx::Int64)

Function to format raw data arrays supplied by design, simobs, and expobs into the requisatory structures for model calibration


Positional arguments

  • design::Array{Float64} An Array containing the input settings for both the control and unknown independent variables in the computer simulator. Dimenions n and p+m. The first p columns contain the control variables and the last m columns contain the unknown variables.
  • simobs::Vector{Float64} A Vector containing the response of the computer simulator, corresponding to the inputs specified in design. Length n.
  • expobs::Array{Float64} An Array containing the experimental data to which the computer model is calibrated. Dimensions n and p+1. The first p columns contain the control variables and the last column contains the observations.
  • nx::Int An integer specifying the number of dimensions of the independent control variables

Returns

  • data::data_str The data structure containing the sim_str and exp_str data structures housing the computer simulator and experimental data, respectively.
source
ModelCalibration.format_prior_hyperparametersMethod
format_prior_hyperparameters(data::DataStr,alpha_sig2::Float64,beta_sig2::Float64,
alpha_tau2::Float64,beta_tau2::Float64,a_rho::Float64,b_rho::Float64,nx::Int64,ntheta::Int64)

Funtion to initialize the specified prior distribution hyperparameters into the requisatory struct.


Positional arguments

  • data::DataStr Struct containing the computer simulator and experimental data.
  • alpha_sig2::Float64 Inverse Gamma shape parameter for the data error variance prior (σ^2).
  • beta_sig2::Float64 Inverse Gamma scale parameter for the data error variance prior (σ^2).
  • alpha_tau2::Float64 Inverse Gamma shape parameter for the discrepancy vairiance prior (τ^2).
  • beta_tau2::Float64 Inverse Gamma scale parameter for the discrepancy variance prior (τ^2).
  • a_rho::Float64 Beta shape parameter 1 for the discrepancy correlation prior (ρ).
  • b_rho::Float64 Beta shape parameter 2 for the discrepancy correlation prior (ρ).
  • nx::Int Integer specifying the number of independent control variables (x).
  • ntheta::Int Integer specifying the number of unknown computer model parameters (θ).

Returns

  • priors::PriorData Struct containing the prior distribution hyperparameters for the variables in the model.

Details This function is agnostic to what prior distributions are used for the model but other functions may require the following prior distributions.

  • θ ∼ U(A,B)
  • τ^2 ∼ IG(α,β)
  • σ^2 ∼ IG(α,β)
  • ρ ∼ Beta(a,b)
source
ModelCalibration.normalize_dataFunction
normalize_data(design_in::Array{Float64},simobs_in::Vector{Float64},
expobs_in::Union{Array{Float64},Float64},nx::Int64,nsim::Int64,scales::scaling,rev::Bool=false)

Function to normalize data to the [0,1] interval or reverse the normalization back to the original data.


Positional arguments

  • design_in::Array{Float64} Matrix of input values for the computer simulator, of dimensions n and p+m. The first p columns correspond to control variables (x) and the last m correspond to unknown variables (θ).
  • simobs_in::Vector{Float64} Vector of response values from the computer simulator, of length n. The rows must correspond to their appropriate input settings in design.
  • expobs_in::Union{Array{Float64},Float64} Matrix of experimental data, of dimensions v and p+1. The first p columns correspond the control independent variables (x) and the last column corresponds to the observed response.
  • nx::Int64 The number of independent control variables (x) in the experimental and computer simulator data.
  • nsim::Int64 The number of computer simulator data points.
  • scales::Scaling Data structure containing minimum and maximum values for the x, y, and θ variables for scaling.

Optional arguments

  • rev::Bool An indicator of whether to normalize the data or reverse the normalization. Default value of false.
    • default value of false

Returns

  • design_out::Array{Float64} The design_raw Matrix normalized to the relative Euclidean distance between the values specified in scales.
  • simobs_out::Vector{Float64} The simobs_raw Vector normalized to the relative Euclidean distance between the values specified in scales.
  • expobs_out::Union{Array{Float64},Float64} The expobs_raw Matrix normalized to the relative Euclidean distance between the values specified in scales.

Details Concatenates all values for y from the computer simulator and experimental data. Concatenates all values for each dimension of x in the computer simulator and experimental data. Calls normalize_var or unnormalize_var on the concatenated y data, the concatenated x data in each dimension of x, and the computer simulator θ values for each dimension of θ.

source
ModelCalibration.normalize_varMethod
normalize_var(var::Array{Float64},scales::ScalePar)

Function to scale a single variable's Array data to the relative distance between the minimum and maximum values specified by the scales structure. The function returns an Array, output, of equal size to var with its data scaled based on the minimum and maximum value described in values.


Positional arguments

  • var::Array{Float64} The array of field values to be scaled, with dimensions n and p.
  • scales::ScalePar The data structure containing the minimum and maximum values for scaling. The minimum and maximum values specified in this structure must be Vectors of length p.

∀ x ∈ var, y = (x-scales.min)/(scales.max-scales.min)

Returns

  • output::Array{Float64} An array containing the original field values, var, scaled to show the relative distance between the minimum and maximum values specified by scales.
source
ModelCalibration.pivot_data_wideMethod
pivot_data_wide(x::Array{Float64},y::Vector{Float64})

Function to pivot multiple observations of the same n-length multivariate normal distribution into a wider array. Given there are m repeated observations of the same n-length multivariate normal distribution, with each repeated observation having the same independent variable settings, this function will reorganize the m*n length Array into a wider pivoted observation data Array, which is preferrable for likelihood calculations.


Positional arguments

  • x::Array{Float64} An Array of dimensions n*m and p, containing the settings of the p independent variables at each observational data point
  • y::Vector{Float64} A Vector of length n*m, containing the experimental observations aligning to the settings specified in x

Returns

  • x_unique::Array{Float64} An array of the unique settings of the independent control variables, dimensions n and p
  • y_wide::Array{Float64} An array of the observations organized by repetition, dimensions n and m
source
ModelCalibration.setupMethod
setup(design_raw::Array{Float64,2},simobs_raw::Vector{Float64},expobs_raw::Union{Array{Float64},
Float64},nx::Int,ntheta::Int,alpha_sig2::Float64,beta_sig2::Float64,alpha_tau2::Float64,
beta_tau2::Float64,a_rho::Float64,b_rho::Float64)

Function to perform necessary calculation prior to calibration.


Positional arguments

  • design_raw::Array{Float64,2} Matrix of input values for the computer simulator, of dimensions n and p+m. The first p columns correspond to control variables (x) and the last m correspond to unknown variables (θ).
  • simobs_raw::Vector{Float64} Vector of response values from the computer simulator, of length n. The rows must correspond to their appropriate input settings in design.
  • expobs_raw::Union{Array{Float64},Float64} Matrix of experimental data, of dimensions v and p+1. The first p columns correspond the control independent variables (x) and the last column corresponds to the observed response.
  • nx::Int The number of independent control variables (x) in the experimental and computer simulator data.
  • ntheta::Int The number of independent unknown variables (θ) in the computer simulator data.
  • alpha_sig2::Float64 Inverse Gamma shape parameter for the data error variance prior (σ^2).
  • beta_sig2::Float64 Inverse Gamma scale parameter for the data error variance prior (σ^2).
  • alpha_tau2::Float64 Inverse Gamma shape parameter for the discrepancy vairiance prior (τ^2).
  • beta_tau2::Float64 Inverse Gamma scale parameter for the discrepancy variance prior (τ^2).
  • a_rho::Float64 Beta shape parameter 1 for the discrepancy correlation prior (ρ).
  • b_rho::Float64 Beta shape parameter 2 for the discrepancy correlation prior (ρ).

Returns

  • nobs_tot::Int An integer decsribing the total number of data points in the experimental data.
  • nrep::Int An integer describing the number of independent repeated observations of the same multivariate normal dsitribution data.
  • nloc::Int An integer describing the number of unique points in the multivariate normal distribution data.
  • scales::Scaling A data structure describing the minimum and maximum values for the x, y, and θ variables.
  • data::DataStr A data structure containing the normalized computer simulator and experimental data.
  • priors::PriorData A data structure containing the prior distribution hyperparameters.
source
ModelCalibration.unnormalize_varMethod
unnormalize_var(var::Array{Float64},scales::ScalePar)

Function to un-normalize a normalized variable's Array data. This function takes data ∈ [0,1] and scales it based on the scales.


Positional arguments

  • var::Array{Float64} The array of field values to be scaled, with dimensions n and p.
  • scales::ScalePar The data structure containing the minimum and maximum values for scaling. The minimum and maximum values specified in this structure must be Vectors of length p.

∀ x ∈ var, y = (x-scales.min)/(scales.max-scales.min)

Returns

  • output::Array{Float64} An array containing the original field values, var, scaled to show the relative distance between the minimum and maximum values specified by scales.
source

Surrogate Model

ModelCalibration.predict_y_allMethod
predict_y_all(theta_settings::Vector{Float64},model)

Function to get the default surrogate model output for a specified input setting.


Keyword arguments

  • theta_settings::Vector{Float64} Vector of θ input settings for prediction.
  • model Surrogate model.

Returns

  • responses:Vector{Float64} Vector of p responses of the surrogate model, for the p control variable settings on which it is trained.
source
ModelCalibration.surrogate_modelMethod
surrogate_model(x::Array{Float64},theta::Array{Float64},y::Array{Float64},nx::Int,ntheta::Int)

Function to generate the default surrogate model for calibration (a vector of Gaussian Processes, using the GaussianProcesses.jl package).


Keyword arguments

  • x::Array{Float64} Array of control independent variables in the computer model data set, dimensions q and p.
  • theta::Array{Float64} Array of unknown independent variables in the computer model data set, dimensions n and m.
  • y::Array{Float64} Array of responses from the computer model data set, dimensions n and q.
  • nx::Int Integer indicating the number of independent control variables, p.
  • ntheta::Int Integer indicating the number of unknown independent variables, m.

Returns

  • model::Vector{GPE} A Vector of length q whose elements are GPE models from the GaussianProcesses.jl package.

Details For a computer model data set where evaluated of n settings of theta, and at each setting of theta, is evaluated at q settings of x (producing an n by q Array of responses), this function creates a vector of q Gaussian process models. Each Gaussian process model is trained on the ith response at the ith setting of x, as a function of theta. Each model is trained on data scaled to the [0,1] interval and uses the following initial values for hyperparameters.

  • zero-mean function.
  • squared exponential covariance kernel with initial hyperparameters of 0.0 for all log length scales and log standard deviation.
  • Prior distributions of N(0,1) for the log length scale and log standard deviation hyperparameters.
  • Prior distribution of N(-2,1) for the log noise of the model (observational error).
source
ModelCalibration.train_model!Method
train_model!(model)
train_model!(model;epochs::Int,make_plots::Bool,save_plots::Bool,show_plots::Bool,
mdl_apnd::String)

Function to train the surrogate model with Bayesian inference via elliptical slice sampling.


Positional arguments

  • model Surrogate model.

Keyword arguments

  • epochs::Int The number of MCMC samples for training the model.
    • default value of 2500
  • make_plots::Bool Indicator of whether to make plots.
    • default value of true
  • save_plots::Bool Indicator of whether to save the plots.
    • default value of true
  • show_plots::Bool Indicator of whether to show the plots.
    • default value of true
  • mdl_apnd::String String to append to the front of the generated plots' file names.
    • default value of ""
source

Optimization

ModelCalibration.get_mleMethod
get_mle(data::DataStr,nx::Int,nloc::Int,ntheta::Int,model;epochs::Int=7000)

Wrapper function to find the MLE of θ and σ^2.


Positional arguments

  • data::DataStr Struct containing the computer simulator and experimental data.
  • nx::Int The number of control independent variables.
  • nloc::Int The number of locations at which the MVN data model is observed.
  • ntheta::Int The number of unknown independent variables.
  • model Surrogate model.

Keyword arguments

  • epochs::Int The number of epochs to run for the opimization.
    • default value of 7000.

Returns

  • theta_mle::Vector{Float64} MLE for θ.
  • covar::Array{Float64,2} MLE of the variance parameter for an identity-based covariance matrix.
source
ModelCalibration.make_covarMethod
make_covar(sig2::Float64,nloc::Int)

Simple function to generate a covariance matrix. This dispatch (passed only a variance parameter and size of the matrix) will use the σ^2I form.


Positional arguments

  • sig2::Float64 Variance parameter.
  • nloc::Int Size of the square matrix.

Returns

  • covar::Array{Float64,2} The covariance matrix.
source
ModelCalibration.make_covarMethod
make_covar(params::CovarPars,nobs::Int)

Simple function to generate a covariance matrix. This dispatch (passed CovarPars struct) will use a form with an integrated discrepancy.


Keyword arguments

  • params::CovarPars Struct containing covariance matrix parameters for integrated discrepancy.
  • nobs::Int Size of the square matrix.

Returns

  • covar::Array{Float64,2} The covariance matrix.
source
ModelCalibration.max_lik_covarFunction
max_lik_covar(nx::Int,nloc::Int,data::DataStr,epochs::Int=7000)

Function to get the maximum likelihood values of the hyperparameters for the data model covariance matrix. For a data model case where the discrepancy term (δ) is integrated out.


Positional arguments

  • nx::Int The number of x variables.
  • nloc::Int The number of locations at which the MVN data model is observed.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • epochs::Int The number of optimization epochs.

Returns

  • covar_par_mle::Vector{Float64} The MLE values of the covariance matrix hyperparameters.
source
ModelCalibration.max_lik_sigmaFunction
max_lik_sigma(opt_response::Vector{Float64},epochs::Int=7000)

Function to get the maximum likelihood value for the data model error variance, σ.


Positional arguments

  • opt_response::Vector{Float64} Vector containing the surrogate model prediction at the MLE of θ.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • epochs::Int Number of optimization epochs.

Returns

  • sig_mle::Float64 The maximum likelihood estimate the standard deviation, whose square when multiplied by the identity matrix, gives the covariance matrix for the data model.
source
ModelCalibration.max_lik_thetaFunction
max_lik_theta(ntheta::Int,model,data::DataStr,epochs::Int=7000)

Function to find the MLE of θ.


Positional arguments

  • ntheta::Int The number of dimensions of θ.
  • model Surrogate model.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • epochs::Int The number of optimization epochs. Default value of 7000.

Returns

  • theta_mle::Vector{Float64} A Vector containing the MLE for θ.

Details This function calls the BlackBoxOptim.jl differential evolutionary optimizer on theta_opt, and returns the best candidate from the optimization.

source

Prior Distributions

ModelCalibration.log_prior_deltaMethod
log_prior_delta(data::DataStr,delta::Vector{Float64},rho::Vector{Float64},
tau2::Float64nx::Int64,nloc::Int64)

Function to evaluate the probability density function of the discrepancy term (δ) prior distribution. This implementation is for a case where the correlation matrix is not yet calculated.


Positional arguments

  • data::DataStr Struct containing the experimental and computer simulator data.
  • delta::Vector{Float64} The value of delta at which to evaluate the distribution.
  • rho::Vector{Float64} A Vector of length p containing the ρ values for evaluating the prior distribution density function.
  • tau2::Float64 The variance of the discrepancy function's covariance matrix.
  • nx::Int64 The number of x variables in the model.
  • nloc::Int64 The length of the data model (multivariate normal distribution) for a single independent observation.

Note that rho are supplied separately from the other variables contained in vars to allow evaluation of the likelihood at different values of ρ without requiring altering the vars struct during Matropolis-Hastings updates.


Returns

  • log_pdf_val The log evaluation of the discrepancy term (δ) prior distribution density function.

Details The discrepancy term (δ) assumes a zero mean prior distribution with a covariance structure defined by Σ=τ^2C. C is the correlation structure. It is a size n square matrix with each element calculated by the following: C(x,x') = ∏(ρ^[4(x-x')]) The δ prior distribution density is evaluated by MVN(0,Σ)

source
ModelCalibration.log_prior_deltaMethod
log_prior_delta(delta::Vector{Float64},corr::Array{Float64,2},tau2::Float64)

Function to evaluate the probability density function of the discrepancy term (δ) prior distribution. This implementation is for a case where the correlation matrix is already calculated.


Positional arguments

  • delta::Vector{Float64} The value of delta at which to evaluate the distribution.
  • corr::Array{Float64,2} Discrepancy function correlation matrix.
  • tau2::Float64 The variance of the discrepancy function's covariance matrix.

Returns

  • log_pdf_val The log evaluation of the discrepancy term (δ) prior distribution density function.

Details The discrepancy term (δ) assumes a zero mean prior distribution with a covariance structure defined by Σ=τ^2C. C is the correlation structure. It is a size n square matrix with each element calculated by the following: C(x,x') = ∏(ρ^[4(x-x')]) The δ prior distribution density is evaluated by MVN(0,Σ)

source
ModelCalibration.prior_thetaMethod
prior_theta(prior_data::PriorData,vars::UpdatedVars)

This function evaluates the probability density function of the prior distribution on θ. Given that θ is modeled to have a uniform prior distribution, this function returns the same value for any value of θ. Generally, this function is not required for evaluation in a posterior sampling scheme.


Positional arguments

  • prior_data::PriorData Data structure containing the prior distribution hyperparameters for all variables
  • vars::UpdatedVars Data structure containing the most recently sampled values of all variables in the MCMC sampling scheme.

Returns

  • pdf_val A scalar Float giving the value of the θ prior distribution.

Details Given that θ are all modeled to have uniform prior distributions, this function evaluates to 1/(B-A) where B and A are the upper and lower bounds for the uniform distribution, respectively.

source

Likelihood

ModelCalibration.likMethod
lik(data::DataStr,eta::Float64,sig2::Float64)

Function to evaluate the data model's likelihood function. Implementation for a univariate normal distribution data model where the surrogate model's estimate is already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • eta::Float64 Vector of theta sample values.
  • sig2::Float64 Data model error variance sample.

Returns

  • likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a univariate normal distribution with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The likelihood is calculated following: L(θ,σ^2|y)=∏^m [N(η,σ)]

source
ModelCalibration.likMethod
lik(data::DataStr,theta::Vector{Float64},sig2::Float64,model)

Function to evaluate the data model's likelihood function. Implementation for a univariate normal distribution data model where the surrogate model's estimate is not already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • theta::Vector{Float64} Vector of theta sample values.
  • sig2::Float64 Data model error variance sample.
  • model Surrogate model.

Returns

  • likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a univariate normal distribution with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The likelihood is calculated following: L(θ,σ^2|y)=∏^m [N(η,σ)] In this implementation, the surrogate model prediction is calculated in this function.

source
ModelCalibration.likMethod
lik(data::DataStr,delta::Vector{Float64},sig2::Float64,eta::Vector{Float64})

Function to evaluate the data model's likelihood function. Implementation for a multivariate normal distribution data model where the surrogate model's estimate is already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • delta::Vector{Float64} Vector of discrepancy function sample.
  • sig2::Float64 Data model error variance sample.
  • eta::Vector{Float64} Surrogate model prediction

Returns

  • likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a multivariate normal distribution (having length n) with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The likelihood is calculated following: L(θ,σ^2,δ|y)=∏^m [MVN(η+δ,σ^2*I)]

source
ModelCalibration.likMethod
lik(data::DataStr,theta::Vector{Float64},delta::Vector{Float64},sig2::Float64,model)

Function to evaluate the data model's likelihood function. Implementation for a multivariate normal distribution data model where the surrogate model's estimate is not already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • theta::Vector{Float64} Vector of theta sample values.
  • delta::Vector{Float64} Vector of discrepancy function sample.
  • sig2::Float64 Data model error variance sample.
  • model Surrogate model.

Returns

  • likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a multivariate normal distribution (having length n) with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The likelihood is calculated following: L(θ,σ^2,δ|y)=∏^m [MVN(η+δ,σ^2*I)] In this implementation, the surrogate model prediction is calculated in this function.

source
ModelCalibration.loglikMethod
loglik(data::DataStr,theta::Vector{Float64},sig2::Float64,model)

Function to evaluate the data model's log likelihood function. Implementation for a univariate normal distribution data model where the surrogate model's estimate is already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • theta::Vector{Float64} Vector of theta sample values.
  • sig2::Float64 Data model error variance sample.
  • model Surrogate model.

Returns

  • log_likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a univariate normal distribution with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The log likelihood is calculated following: l(θ,σ^2|y)=∏^m [log(N(η,σ))]

source
ModelCalibration.loglikMethod
loglik(data::DataStr,theta::Vector{Float64},sig2::Float64,model)

Function to evaluate the data model's log likelihood function. Implementation for a univariate normal distribution data model where the surrogate model's estimate is not already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • theta::Vector{Float64} Vector of theta sample values.
  • sig2::Float64 Data model error variance sample.
  • model Surrogate model.

Returns

  • log_likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a univariate normal distribution with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The log likelihood is calculated following: l(θ,σ^2|y)=∏^m [log(N(η,σ))] In this implementation, the surrogate model prediction is calculated in this function.

source
ModelCalibration.loglikMethod
log_lik(data::DataStr,delta::Vector{Float64},sig2::Float64,eta::Vector{Float64})

Function to evaluate the data model's log likelihood function. Implementation for a multivariate normal distribution data model where the surrogate model's estimate is already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • delta::Vector{Float64} Vector of discrepancy function sample.
  • sig2::Float64 Data model error variance sample.
  • eta::Vector{Float64} Surrogate model estimate.

Returns

  • log_likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a multivariate normal distribution (having length n) with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The likelihood is calculated following: l(θ,σ^2,δ|y)=Σ^m [log(MVN(η+δ,τ^2*I))]

source
ModelCalibration.loglikMethod
loglik(data::DataStr,theta::Vector{Float64},delta::Vector{Float64},sig2::Float64,model)

Function to evaluate the data model's log likelihood function. Implementation for a multivariate normal distribution data model where the surrogate model's estimate is not already known.


Positional arguments

  • data::DataStr A data structure containing the computer simulator and experimental data.
  • theta::Vector{Float64} Vector of theta sample values.
  • delta::Vector{Float64} Vector of discrepancy function sample.
  • sig2::Float64 Data model error variance sample.
  • model Surrogate model.

Returns

  • log_likelihood A scalar Float64 value of the likelihood function.

Details The likelihood function is evaluated as the product of probability density function of the data model over each independent observation. This likelihood calculation assumes a multivariate normal distribution (having length n) with m independent observations. Let η be the surrogate model's prediction of the response variabeles, y, for the given θ values specified in theta. The log likelihood is calculated following: l(θ,σ^2,δ|y)=Σ^m [log(MVN(η+δ,τ^2*I))] In this implementation, the surrogate model prediction is calculated in this function.

source

Gaussian Process Kernel

ModelCalibration.correlation_constructMethod
correlation_construct(rho::Vector{Float64},x::Array{Float64,2},nx::Int64,nobs::Int64)

Function to construct the correlation Matrix for a set of x locations.


Positional arguments

  • rho::Vector{Float64} Vector of correlation parameters (ρ) across the different dimensions of x, length nx.
  • x::Array{Float64,2} Array of x locations for calculating the correlation Matrix, dimensions nobs and nx.
  • nx::Int64 The number of x dimensions.
  • nobs::Int64 The number of data points for calculating the correlation Matrix.

Returns

  • correlation::Array{Float64,2} The correlation matrix of x, given ρ.

Details An nobs by nobs Matrix is initialized and, at each [i,j] index in the matrix, correlation_kernel is called to calculate the correlation given ρ, x[i,:], and x[j,:]. The square root of the machine precision for a Float64 is added to the diagonal elements of the Matrix for stability purposes.

source
ModelCalibration.correlation_kernelMethod
correlation_kernel(x1::Vector{Float64},x2::Vector{Float64},rho::Vector{Float64},nx::Int64)

Function to calculate the correlation value between two locations, x1 and x2, given the correlation parameters, rho.


Positional arguments

  • x1::Vector{Float64} Vector of settings at the first location, length nx.
  • x2::Vector{Float64} Vector of settings at the second location, length nx.
  • rho::Vector{Float64} Vector of correlation parameters (ρ) across the different dimensions of x, length nx.
  • nx::Int64 Integer specifying the number of x dimensions.

Returns

  • correlation::Float64 A float describing the correlation between the two locations x1 and x2 given rho.

Details Correlation is calculated as ∏[ρ^(4(x1-x2)^2)], where the product is taken over the number of x dimensions.

source

Initialization

ModelCalibration.init_varsMethod
init_vars(nmcmc::Int)

Function to initialize structure to store samples for discrete domain griddy Gibbs MCMC sampling. Implementation for griddy Gibbs sampling scheme.


Positional arguments:

  • nmcmc::Int Integer specifying the number of MCMC samples.

Returns

  • ::GriddyVarsStruct Data structure containing initialized Arrays to store the sampled values for each variable in the model.
source
ModelCalibration.init_varsMethod
init_vars(data::DataStr,nmcmc::Int,nx::Int,ntheta::Int,theta_init::Vector{Float64})

Function to initialize structure to store samples for continuous domain MCMC sampling. Implementation for continuous sampling scheme.


Positional arguments:

  • data::DataStr Strcture containing computer simulator and experimental data.
  • nmcmc::Int Integer specifying the number of MCMC samples.
  • nx::Int Integer specifying the number of independent control variables (x).
  • ntheta::Int Integer specifying the number of unknown computer model variabels (θ).
  • theta_init::Vector{Float64} Vector of length ntheta specifying the values at which to initialize the θ variables for MCMC.

Returns

  • ::BulkVarsStruct Data structure containing initialized Arrays to store the sampled values for each variable in the model.
source

Results Processing

ModelCalibration.get_estimatesMethod
get_estimates(data::Vector{Float64})

Function to get the mean, median, and 95% credible bounds of a set of posterior samples.


Positional arguments

  • data::Vector{Float64}

Returns

  • temp::Vector{Float64} Vector containing the estimates.
source
ModelCalibration.make_estimate_tableMethod
make_estimate_table(samples::BulkVarsStruct,nx::Int,ntheta::Int,mdl_apnd::String)

Function to make the table of estimates from the posterior samples.


Positional arguments

  • samples::BulkVarsStruct struct containing the posterior samples from the continuous sampler.
  • nx::Int number of x variables.
  • ntheta::Int number of theta variables.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.make_estimate_tableMethod
make_estimate_table!(samples::GriddyPosteriors,nx::Int,ntheta::Int,mdl_apnd::String)

Function to make the table of estimates from the posterior samples.


Positional arguments

  • samples::GriddyPosteriors struct containing the posterior samples from the griddy Gibbs sampler.
  • nx::Int number of x variables.
  • ntheta::Int number of theta variables.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.normalize_samplesFunction
normalize_samples(samples::BulkVarsStruct,scales::Scaling)
normalize_samples(samples::BulkVarsStruct,scales::Scaling,rev::Bool)

Function to normalize or reverse the normalization of the posterior samples. This is the implementation for the continuous sampler results.


Positional arguments

  • samples::BulkVarsStruct Struct containing the posterior samples.
  • scales::Scaling Struct containing the minimum and maximum values for each variables.

Optional arguments

  • rev::Bool Indicator of whether to reverse the normalization or not.
    • default value of true.
source
ModelCalibration.normalize_samplesFunction
normalize_samples(samples::GriddyVarsStruct,scales::Scaling,theta_grid::Array{Float64},
sig_grid::Union{Nothing,Array{Float64}})
normalize_samples(samples::GriddyVarsStruct,scales::Scaling,theta_grid::Array{Float64},
sig_grid::Union{Nothing,Array{Float64}},rev::Bool)

Function to normalize or reverse the normalization of the posterior samples. This implementation is for the griddy Gibbs sampler.


Positional arguments

  • samples::GriddyVarsStruct Struct containing the posterior samples (in index form) from the griddy Gibbs sampler.
  • scales::Scaling Struct containing the minimum and maximum values for each variables.
  • theta_grid::Array{Float64} Array containing the sampling grid for θ that was used for the griddy Gibbs sampler.
  • sig_grid::Union{Nothing,Array{Float64}} Array containing the sampling grid for the proportional covariance matrix used for the griddy Gibbs sampler.

Optional arguments

  • rev::Bool Indicator of whether to reverse the normalization or not.
    • default value of true.

Returns

  • converted_samples::GriddyPosteriors A struct containing the real value samples from the griddy Gibbs sampler.
source
ModelCalibration.plot_correlationMethod
plot_correlation(data::Array{Float64,2},var::String,save_plots::Bool,show_plots::Bool,
mdl_apnd::String)

Function to generate a correlation plot for the samples of a multidimensional variable. Optionally, display and/or save the plot.


Positional arguments

  • data::Array{Float64,2} Data to plot.
  • var::String Name of the variable being plotted.
  • save_plots::Bool Indicator of whether to save the plot that is generated.
  • show_plots::Bool Indicator of whether to display the plot that is generated.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.plot_credible_boundsMethod
plot_credible_bounds(data::Array{Float64},x_coords::Array{Float64},scales::ScalePar)

Function to generate a plot of a function over the x coordinates of the data along with its 95% credible bounds.


Positional arguments

  • data::Array{Float64} Function's data to plot.
  • x_coords::Array{Float64} the x coordinates of the data.
  • scales::ScalePar Struct containing the minimum and maximum value of the variable in data.

Returns

  • p The generated plot.
source
ModelCalibration.plot_disc!Method
plot_disc!(delta::Array{Float64},x_coords::Array{Float64},scales::Scaling,
show_plots::Bool,save_plots::Bool,mdl_apnd::String)

Function to generate plots for the discrepancy function. This implementation does not generate a histogram or trace plot.


Positional arguments

  • delta::Array{Float64} Array containing the posterior samples of the discrepancy function, each row of the Matrix is a sample of δ.
  • x_coords::Array{Float64} Array containing the x coordinates from the experimental data.
  • scales::Scaling Struct containing scaling information for the variables in the data.
  • save_plots::Bool Indicator of whether to save the plot that is generated.
  • show_plots::Bool Indicator of whether to display the plot that is generated.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.plot_disc!Method
plot_disc!(delta::Array{Float64},x_coords::Array{Float64},scales::Scaling,nbins::Int,
show_plots::Bool,save_plots::Bool,mdl_apnd::String)

Function to generate plots for the discrepancy function. This implementation generates a histogram and a trace plot.


Positional arguments

  • delta::Array{Float64} Array containing the posterior samples of the discrepancy function, each row of the Matrix is a sample of δ.
  • x_coords::Array{Float64} Array containing the x coordinates from the experimental data.
  • scales::Scaling Struct containing scaling information for the variables in the data.
  • nbins::Int The number of bins to use for the histograms.
  • save_plots::Bool Indicator of whether to save the plot that is generated.
  • show_plots::Bool Indicator of whether to display the plot that is generated.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.plot_prediction!Method
plot_prediction!(samples::BulkVarsStruct,data::DataStr,scales::Scaling,
save_plots::Bool,show_plots::Bool,mdl_apnd::String)

Function to plot the surrogate model and data model estimations.


Positional arguments

  • samples::BulkVarsStruct Struct containing non-normalized posterior samples.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • scales::Scaling Struct containing the minimum and maximum values for each variable.
  • save_plots::Bool Indicator of whether to save the plot that is generated.
  • show_plots::Bool Indicator of whether to display the plot that is generated.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.plot_prediction!Method
plot_prediction!(theta_idx::Vector{Int},samples::GriddyPosteriors,x_coords::Array{Float64},
grid_resp::Array{Float64,2},data::DataStr,scales::Scaling,save_plots::Bool,
show_plots::Bool,mdl_apnd::String)

Function to plot the surrogate model and data model estimations.


Positional arguments

  • theta_idx::Vector{Int} Sampled indices of theta from the griddy Gibbs sampler.
  • samples::GriddyPosteriors Struct containing non-normalized posterior samples.
  • grid_resp::Array{Float64,2} Matrix of grid responses.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • scales::Scaling Struct containing the minimum and maximum values for each variable.
  • save_plots::Bool Indicator of whether to save the plot that is generated.
  • show_plots::Bool Indicator of whether to display the plot that is generated.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.post_processMethod
post_process(samples::BulkVarsStruct,data::DataStr,nx::Int,ntheta::Int,nburn::Int,
scales::Scaling)
post_process(samples::BulkVarsStruct,data::DataStr,nx::Int,ntheta::Int,nburn::Int,
scales::Scaling;make_plots::Bool,save_plots::Bool,show_plots::Bool,
nbins::Int,nthin::Int,mdl_apnd::String)

Wrapper function to post-process the posterior samples.


Positional arguments

  • samples::BulkVarsStruct Struct containing the posterior samples.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • nx::Int Number of x dimensions.
  • ntheta::Int number of θ dimensions.
  • nburn::Int The number of samples to burn.
  • scales::Scalint Struct containing the scaling information for the data.

Keyword arguments

  • make_plots::Bool Indicator of whether to make plots.
    • default value of true
  • save_plots::Bool Indicator of whether to save the plots.
    • default value of true
  • show_plots::Bool Indicator of whether to show the plots.
    • default value of true
  • nthin::Int The number of samples to skip when thinning.
    • default value of 5
  • nbins::Int The number of bins to use for histograms.
    • default value of 30
  • mdl_apnd::String String to append to the front of the generated plots' file names.
    • default value of ""
source
ModelCalibration.post_processMethod
post_process(samples::GriddyVarsStruct,data::DataStr,nx::Int,ntheta::Int,nburn::Int,
scales::Scaling,theta_grid::Array{Float64,2},sig_grid::Union{Nothing,Array{Float64,2}},
grid_resp::Array{Float64,2})
post_process(samples::GriddyVarsStruct,data::DataStr,nx::Int,ntheta::Int,nburn::Int,
scales::Scaling,theta_grid::Array{Float64,2},sig_grid::Union{Nothing,Array{Float64,2}},
grid_resp::Array{Float64,2};make_plots::Bool,save_plots::Bool,show_plots::Bool,
nbins::Int,nthin::Int,mdl_apnd::String)

Wrapper function to post-process the posterior samples.


Positional arguments

  • samples::GriddyVarsStruct Struct containing the posterior samples.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • nx::Int Number of x dimensions.
  • ntheta::Int number of θ dimensions.
  • nburn::Int The number of samples to burn.
  • scales::Scalint Struct containing the scaling information for the data.
  • theta_grid::Array{Float64,2} Matrix of theta grid values.
  • sig_grid::Union{Nothing,Array{Float64,2}} Matrix of integrated discrepancy covaraince grid values.
  • grid_resp::Array{Float64,2} Responses of the surrogate model corresponding theta_grid.

Keyword arguments

  • make_plots::Bool Indicator of whether to make plots.
    • default value of true
  • save_plots::Bool Indicator of whether to save the plots.
    • default value of true
  • show_plots::Bool Indicator of whether to show the plots.
    • default value of true
  • nthin::Int The number of samples to skip when thinning.
    • default value of 5
  • nbins::Int The number of bins to use for histograms.
    • default value of 30
  • mdl_apnd::String String to append to the front of the generated plots' file names.
    • default value of ""
source
ModelCalibration.posterior_hist!Method
posterior_hist!(data::Array{Float64},nbins::Int,var::String,iter::Int,save_plots::Bool,
show_plots::Bool,mdl_apnd::String)

Function to generate a combined posterior histogram and kernel density plot for the posterior samples of a variable. Optionally, display and/or save the plot.


Positional arguments

  • data::Array{Float64} Array of posterior samples to plot.
  • nbins::Int The number of bins to use for the histogram.
  • var::String A string specifying the name of the variable being plotted.
  • iter::Int An Integer specifying the iterate of a multidimensional variable, e.g. θ.
    • for a univariate variable, e.g. τ^2, specify 0.
  • save_plots::Bool Indicator of whether to save the plot that is generated.
  • show_plots::Bool Indicator of whether to display the plot that is generated.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source
ModelCalibration.remove_burnMethod
remove_burn(samples::BulkVarsStruct,nburn::Int)

Function to extract the posterior samples after the burned values. Implementation for the continuous sampler results.


Positional arguments

  • samples::BulkVarsStruct Struct containing the posterior samples from the continuous sampler.
  • nburn::Int The number of samples to discard

Returns

  • truncated::BulkVarsStruct Bulk vars struct that contains the samples retained after discarding the burned samples.

Details This selects all posterior samples from nburn + 1 through the end of the samples. These values are retained and placed into a new posterior samples struct, which is then returned.

source
ModelCalibration.remove_burnMethod
remove_burn(samples::GriddyPosteriors,nburn::Int)

Function to extract the posterior samples after the burned values. Implementation for the griddy Gibbs sampler results.


Positional arguments

  • samples::GriddyPosteriors Struct containing the posterior samples from the griddy Gibbs sampler.
  • nburn::Int The number of samples to discard

Returns

  • truncated::GriddyPosteriors Bulk vars struct that contains the samples retained after discarding the burned samples.

Details This selects all posterior samples from nburn + 1 through the end of the samples. These values are retained and placed into a new posterior samples struct, which is then returned.

source
ModelCalibration.remove_burnMethod
remove_burn(samples::GriddyVarsStruct,nburn::Int)

Function to extract the posterior samples after the burned values. Implementation for the griddy Gibbs sampler results, still in index form.


Positional arguments

  • samples::GriddyVarsStruct Struct containing the posterior samples from the griddy Gibbs sampler.
  • nburn::Int The number of samples to discard

Returns

  • truncated::GriddyVarsStruct Bulk vars struct that contains the samples retained after discarding the burned samples.

Details This selects all posterior samples from nburn + 1 through the end of the samples. These values are retained and placed into a new posterior samples struct, which is then returned.

source
ModelCalibration.sqrt_variance!Method
sqrt_variance(samples::BulkVarsStruct)

Function to take the square root of the posterior samples of the variance parameters, making them standard deviations. This implementation is for the continuous sampler posterior samples.


Positional arguments

  • samples::BulkVarsStruct Posterior samples from the continuous sampler.
source
ModelCalibration.sqrt_variance!Method
sqrt_variance(samples::GriddyPosteriors)

Function to take the square root of the posterior samples of the variance parameters, making them standard deviations. This implementation is for the griddy Gibbs sampler posterior samples.


Keyword arguments

  • samples::GriddyPosteriors Posterior samples from the griddy Gibbs sampler.
source
ModelCalibration.thin_samplesMethod
thin_samples(samples::BulkVarsStruct,nthin::Int)

Function to thin the posterior samples, helping remove autocorrelated values from the samples. This implementation is for the continuous sampler results.


Positional arguments

  • samples::BulkVarsStruct Struct storing the posterior samples.
  • nthin::Int The number of samples to skip.

Returns

  • thinned::BulkVarsStruct Struct containing the thinned posterior samples.

Details This function selects retains every nthinth sample from the posterior samples, starting at the first index and going through to the end.

source
ModelCalibration.thin_samplesMethod
thin_samples(samples::GriddyPosteriors,nthin::Int)

Function to thin the posterior samples, helping remove autocorrelated values from the samples. This implementation is for the griddy Gibbs sampler results.


Positional arguments

  • samples::GriddyPosteriors Struct storing the posterior samples.
  • nthin::Int The number of samples to skip.

Returns

  • thinned::GriddyPosteriors Struct containing the thinned posterior samples.

Details This function selects retains every nthinth sample from the posterior samples, starting at the first index and going through to the end.

source
ModelCalibration.thin_samplesMethod
thin_samples(samples::GriddyVarsStruct,nthin::Int)

Function to thin the posterior samples, helping remove autocorrelated values from the samples. This implementation is for the griddy Gibbs sampler, with the results still in index form.


Positional arguments

  • samples::GriddyVarsStruct Struct storing the posterior samples.
  • nthin::Int The number of samples to skip.

Returns

  • thinned::GriddyVarsStruct Struct containing the thinned posterior samples.

Details This function selects retains every nthinth sample from the posterior samples, starting at the first index and going through to the end.

source
ModelCalibration.trace_plot!Method
trace_plot!(data::Array{Float64},var::String,iter::Int,save_plots::Bool,
show_plots::Bool,mdl_apnd::String)

Function to generate a combined posterior histogram and kernel density plot for the posterior samples of a variable. Optionally, display and/or save the plot.


Positional arguments

  • data::Array{Float64} Array of posterior samples to plot.
  • var::String A string specifying the name of the variable being plotted.
  • iter::Int An Integer specifying the iterate of a multidimensional variable, e.g. θ.
    • for a univariate variable, e.g. τ^2, specify 0.
  • save_plots::Bool Indicator of whether to save the plot that is generated.
  • show_plots::Bool Indicator of whether to display the plot that is generated.
  • mdl_apnd::String String to append to the front of the saved plot's file name.
source