I created a pull request with some ideas for generic discrepancy functions.
The relevant functions are in:
-
R/GenericDiscrFunction.R: contains a function that 1) returns a 3-d array, results[j, i, k], (discrepancy $j$, MCMC iteration $i$, and $k$ = 1 for observed or 2 for simulated) and 2) as input takes MCMCSamples and discControl:
discControl = list(
model = model_uncompiled,
dataNames = dataNames,
dataNodes = dataNodes,
paramNames = paramNames,
paramNodes = paramNodes,
expectedNames = expectedNames,
expectedNodes = expectedNodes,
discType = discType # character vector of one or more discrepancy functions
)
R/registeredDiscrepancies.R: contains a few discrepancy functions of class discrepancyFunction_BASE, as well as a lookup list, discLookup, that maps a character string to the associated discrepancy function
Right now it seems to work as a stand-alone function - check out tests/test-GenericDiscrFunction.R that generates original MCMC samples and tests the output of calcDiscrepancies(). But it is not yet integrated into runCalibration().
A few notes/questions/ideas on the generic discrepancy function:
- We would need to update code to allow the discrepancy function to return a 3-day array instead of 2-day array
- We could make "deviance" the default
discType?
- We need to add error traps to make sure
expectedNodes is not NULL if chisquared or freemantukey is in discType
And then a thought on tests:
- It seems like we want to create a model and original MCMC samples that can be used across all of the tests?
And then a general thought:
- I'm wondering if we want to limit
dataNodes to be one node in the model? And then if a user has multiple data nodes, then they can run the function separately on each data node? This makes some sense if someone wants to test different parts of their model separately or wants to use different discrepancy function for different data nodes. But perhaps that is too limiting.
I created a pull request with some ideas for generic discrepancy functions.
The relevant functions are in:
R/GenericDiscrFunction.R: contains a function that 1) returns a 3-d array,results[j, i, k], (discrepancyMCMCSamplesanddiscControl:R/registeredDiscrepancies.R: contains a few discrepancy functions of classdiscrepancyFunction_BASE, as well as a lookup list,discLookup, that maps a character string to the associated discrepancy functionRight now it seems to work as a stand-alone function - check out
tests/test-GenericDiscrFunction.Rthat generates original MCMC samples and tests the output ofcalcDiscrepancies(). But it is not yet integrated intorunCalibration().A few notes/questions/ideas on the generic discrepancy function:
discType?expectedNodesis not NULL ifchisquaredorfreemantukeyis indiscTypeAnd then a thought on tests:
And then a general thought:
dataNodesto be one node in the model? And then if a user has multiple data nodes, then they can run the function separately on each data node? This makes some sense if someone wants to test different parts of their model separately or wants to use different discrepancy function for different data nodes. But perhaps that is too limiting.