Skip to content

Generic discrepancy functions #10

@abigailkeller

Description

@abigailkeller

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:

  1. We would need to update code to allow the discrepancy function to return a 3-day array instead of 2-day array
  2. We could make "deviance" the default discType?
  3. 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:

  1. 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:

  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions