Griddy Gibbs Calibration

Grid Generation

ModelCalibration.find_lik_asymptoteMethod
find_lik_asymptote(model,data::DataStr,theta::Vector{Float64},covar::Array{Float64,2};
delta::Float64=1e-3,convergence::Float64=1e-12)

Function to determine the approximate values of θ that result in the start of the asymptote of the likelihood function.


Positional arguments

  • model Surrogate model.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • theta::Vector{Float64} Maximum likelihood estimates for θ.
  • covar::Array{Float64,2} Maximum likelihood estimate for the covariance matrix of the data model.

Keyword arguments

  • delta::Float64 Step size in θ.
    • default value of 1E-3.
  • convergence::Float64 Convergence criteria for algorithm. When the cange in likelihood divided by the maximum likelihood is less than this value, the algorithm will terminate.
    • default value of 1E-12

Returns

  • upper_bounds::Vector{Float64} Vector of θ values greater than their MLE that correspond to the start of the asymptotic behavior of the likelihood function.
  • lower_bounds::Vector{Float64} Vector of θ values lesser than their MLE that correspond to the start of the asymptotic behavior of the likelihood function.

Details

source
ModelCalibration.format_doeMethod
format_doe(doe::Array{Float64,2},data::DataStr,nloc::Int,nx::Int,ntheta::Int)

Function to format the raw DOE of θ generated by get_full_fact to include settings of x variables.


Positional arguments

  • doe::Array{Float64,2} DOE to be edited.
  • data::DataStr Strucdt containing computer simulator and experimental data.
  • nloc::Int The number of x settings for the computer simulator and experimental data.
  • nx::Int The number of independent control variables.
  • ntheta::Int The number of unknown independent variables in the computer simulator, θ.

Returns

  • full_doe::Array{Float64,2} The formatted DOE.
source
ModelCalibration.generate_sample_gridMethod
generate_sample_grid(n::Int,data::DataStr,nx::Int,ntheta::Int,model;
delta::Float64=1e-3,convergence::Float64=1e-12)

Function to generate the sampling grid for the griddy gibbs approach.


Positional arguments

  • n::Int The number of grid points per dimension of θ.
  • data::DataStr Struct containing the computer simulator and experimental data.
  • nx::Int The number of x dimensions.
  • ntheta::Int The number of θ dimensions.
  • model The surrogate model used for calculating the bounds. The default model is the vectorized Gaussian process model generated by this package.

Keyword arguments

  • delta::Float64 The increment by which to adjust theta in the asymptote calculation,
    • default value of 1E-3
  • convergence::Float64 Convergence criteria for algorithm. When the cange in likelihood divided by the maximum likelihood is less than this value, the algorithm will terminate.
    • default value of 1E-12
  • epochs::Int The number of epochs for optimizing in the MLE evaluation.
    • default value of 7000

Returns

  • doe::Array{Float64,2} The sampling grid for θ to use for the griddy Gibbs sampler.

Details This function first solves for the maximum likelihood values of the θ parameters and the covariance matrix. After the MLE are solved, the approximate asymtptotes of the likelihood function are calculated. During this step, the θ values closest to the θ MLEs that generate asymptotic likelihood values are calculated. With these bounds for θ solved, a full factorial, uniform grid DOE is generated over the bounds of θ.

source
ModelCalibration.get_full_factMethod
get_full_fact(n::Int,ntheta::Int,bounds::Tuple{Vector{Float64},Vector{Float64}})

Function to generate a full factorial, uniform grid, design of experiments for θ, in the bounds specified.


Positional arguments

  • n::Int The number of grid points to use per dimension of θ.
  • ntheta::Int The number of unknown independent variables in the computer simulator.
  • bounds::Tuple{Vector{Float64},Vector{Float64}} A Tuple of two Vectors, each having a length of ntheta, that specify the bounds for each θ. The first Vector in the Tuple contains the upper bounds and the second Vector contains the lower bounds.

Returns

  • doe::Array{Float64,2} design of experiments.
source

Precomputation

ModelCalibration.preallocateMethod
preallocate(theta_grid::Array{Float64,2},sig_grid::GridData,nx::Int)

Function to preallocate Arrays for precomputation in Griddy Gibbs approach.


Positional arguments

  • theta_grid::Array{Float64,2} Grid of theta values for the griddy Gibbs sampler.
  • sig_grid::GridData A data structure specifying the bounds and number of grid points for ϕ and ρ.
  • nx::Int

Returns

  • c_sse::Array{Float64} An initialized Array to store the precomputed values of the scaled SSE.
  • sig_det::Array{Float64} An initialized Array to store the precomputed values of det(Σ).
  • sig_design::Array{Float64} An initialized Array to store the ρ and ϕ inputs for Σ.
  • rho::Array{Float64} An initialized Array to store the values of ρ for precomputation.
  • phi::Vector{Float64} An initialized Vector to store the values of ϕ for precomputation.

Details Preallocates Arrays for the griddy Gibbs precomputation. If the data model is univariate, nothing is returned for the integrated discrepancy covariance marix variables.

source
ModelCalibration.precompute!Method
precompute!(grid_response::Array{Float64,2},data::DataStr,c_sse::Array{Float64,3},
sig_det::Array{Float64,2},sig_design::Array{Float64,3},nx::Int)

Function to precompute required values for Griddy Gibbs calibration. Implementation for a multivariate normal distribution data model. –- Positional arguments

  • grid_response::Array{Float64,2} Response grid from surrogate model.
  • data::DataStr Struct containing computer simulator and experimental data.
  • c_sse::Array{Float64,3} Array to store precomputed values of the SSE scaled by the covariance matrix.
  • sig_det::Array{Float64,2} Array to store the precomputed values for the determinant of the covariance matrix.
  • sig_design::Array{Float64,3} Array to containing the ρ and ϕ input values for computing Σ.
  • nx::Int The number of x variables in the data.
source
ModelCalibration.precompute!Method
precompute!(grid_response::Array{Float64,2},data::DataStr,c_sse::Vector{Float64},
sig_det::Nothing,sig_design::Nothing,nx::Int)

Function to precompute required values for Griddy Gibbs calibration. Implementation for a univariate normal distribution data model. This uses the same input arguments as the MVN implementation to allow using a similar function call. The key diffence is that this accepts a Vector for c_sse instead of an Array{Float64,3} and the variables for the corrleation structure are Nothing. These types are automatically determined by and returned from the preallocate() function, allowing for identical function calls.


Positional arguments

  • grid_response::Array{Float64,2} Response grid from surrogate model.
  • data::DataStr Struct containing computer simulator and experimental data.
  • c_sse::Vector{Float64} Array to store precomputed values of the SSE scaled by the covariance matrix.
  • sig_det::Nothing Dummy argument for function call.
  • sig_design::Nothing Dummy variable for function call.
  • nx::Int Dummy variable for function call.
source
ModelCalibration.scaled_sseMethod
scaled_sse(y_hat::Vector{Float64},y::Array{Float64})

Function to calculate the exponent in the likelihood function. Implementation for a univariate normal distribution data model.


Positional arguments

  • y_hat::Vector{Float64} A Vector of length n containing the computer model's estimates of the experimental responses for a setting of θ.
  • y::Array{Float64} A Vector of length n containing the experimental responses.

Returns

  • sse::Float64 A scalar Float describing the sum of squared error between y_hat and y.
source
ModelCalibration.scaled_sseMethod
scaled_sse(y_hat::Vector{Float64},sigma_inv::Array{Float64,2},y_bar::Vector{Float64},nobs::Int)

Function to calculate the exponent in the likelihood function. Implementation for a multivariate normal distribution data model.


Positional arguments

  • y_hat::Vector{Float64} A Vector of length n containing the computer model's estimates of the experimental responses for a setting of θ.
  • sigma_inv::Array{Float64} A n by n Array describing the covariance structure of the data model.
  • y_bar::Array{Float64} A Vector of length n containing the mean experimental observations, averaged of all m independent observations.
  • nobs::Int A scalar integer describing the number of independent observations of the data (m).

Returns

  • sse::Float64 A scalar Float describing the sum of squared error between y_hat and y_bar, scaled by the covariance matrix.
source

Posterior Functions

ModelCalibration.loglik_covar!Method
loglik_covar!(c_sse::Array{Float64,2},log_det_sig::Array{Float64,2},sig2_inv::Float64,
loglik_covar::Array{Float64,2})

Function to calculate the optimized log-likelihood for Σ* in the griddy Gibbs sampling method. Implementation for preallocated array in which to store results. –- Positional arguments

  • c_sse::Array{Float64,2} Correlation sum of of squared error over grid of rho and phi. This is calculated by sum([y-μ]'Σ*^-1[y-μ]).
  • log_det_sig::Array{Float64,2} Determinant of Σ* raised to the power of (-m/2), where mis the number of observations.
  • sig2_inv::Float64 Date model error variance.
  • loglik_theta::Array{Float64,2} Pre-allocated Vector to store the log likelihood values in.
source
ModelCalibration.loglik_covar!Method
loglik_covar!(c_sse::Array{Float64,2},log_det_sig::Array{Float64,2},sig2_inv::Float64,
loglik_covar::Array{Float64,2})

Function to calculate the optimized log-likelihood for Σ* in the griddy Gibbs sampling method. Implementation for no preallocated array in which to store results. –- Positional arguments

  • c_sse::Array{Float64,2} Correlation sum of of squared error over grid of rho and phi. This is calculated by sum([y-μ]'Σ*^-1[y-μ]).
  • log_det_sig::Array{Float64,2} Determinant of Σ* raised to the power of (-m/2), where mis the number of observations.
  • sig2_inv::Float64 Date model error variance.
source
ModelCalibration.loglik_theta!Method
loglik_theta!(c_sse::Vector{Float64},sig2_inv::Float64,loglik_theta::Vector{Float64})

Function to calculate the optimized log-likelihood for θ in the griddy Gibbs sampling method. Implementation for preallocated vector in which to store the results –- Positional arguments

  • c_sse::Vector{Float64} Correlation sum of of squared error over grid of theta. This is calculated by sum([y-μ]'Σ*^-1[y-μ]).
  • sig2_inv::Float64 Date model error variance.
  • loglik_theta::Vector{Float64} Pre-allocated Vector to store the log likelihood values in.
source
ModelCalibration.loglik_thetaMethod
loglik_theta!(c_sse::Vector{Float64},sig2_inv::Float64)

Function to calculate the optimized log-likelihood for θ in the griddy Gibbs sampling method. Implementation for no preallocated vector in which to store results –- Positional arguments

  • c_sse::Vector{Float64} Correlation sum of of squared error over grid of theta. This is calculated by sum([y-μ]'Σ*^-1[y-μ]).
  • sig2_inv::Float64 Date model error variance.
source

Sampling

ModelCalibration.griddy_gibbs!Method
griddy_gibbs!(data::DataStr,sample_vals::GriddyVarsStruct,c_sse::Array{Float64,3},
log_det_sig::Vector{Float64,2},sig_design::Array{Float64,3},
priors::PriorData,nmcmc::Int)

Function to perform griddy Gibbs sampling on the model and data. Implementation for a multivariate normal distribution data model.


Positional arguments

  • data::DataStr Struct containing computer simulator and experimental data.
  • sample_vals Structure to store the sampled values during MCMC.
  • c_sse::Array{Float64,3} Array to store precomputed values of the SSE scaled by the covariance matrix.
  • log_det_sig::Array{Float64,2} Array to store the precomputed values for the determinant of the covariance matrix.
  • sig_design::Array{Float64,3} Array to containing the ρ and ϕ input values for computing Σ.
  • priors::PriorData Struct containing prior distribution hyperparameters.
  • nmcmc::Int Number of samples to draw.
source
ModelCalibration.griddy_gibbs!Method
griddy_gibbs!(data::DataStr,sample_vals::GriddyVarsStruct,c_sse::Vector{Float64},
log_det_sig::Vector{Float64,2},sig_design::Array{Float64,3},
priors::PriorData,nmcmc::Int)

Function to perform griddy Gibbs sampling on the model and data. Implementation for a univarite normal distribution data model. The same arguments that would be passed to the multivariate normal distribution are accepted here to allow the function call to be the same for either data model. The key diffence is that this accepts a Vector for c_sse instead of an Array{Float64,3} and the variables for the corrleation structure are Nothing. These types are automatically determined by and returned from the preallocate() function, allowing for identical function calls.


Positional arguments

  • data::DataStr Struct containing computer simulator and experimental data.
  • sample_vals Structure to store the sampled values during MCMC.
  • c_sse::Vector{Float64} Array to store precomputed values of the SSE scaled by the covariance matrix.
  • log_det_sig::Nothing Dummy argument to allow same function call as MVN implementation.
  • sig_design::Nothing Dummy argument to allow same function call as MVN implementation.
  • priors::PriorData Struct containing prior distribution hyperparameters.
  • nmcmc::Int Number of samples to draw.
source