Two-dimensional Monte Carlo

From Opasnet
Jump to: navigation, search



Question

How to perform two-dimensional Monte Carlo in Opasnet?

Answer

Use function mc2d to perform two-dimensional Monte Carlo. The function samples the current ovariable results by bootstrapping, applies an aggregate function to the samples, and then produces a new Iter index location for each sample. The function requires a parameter list mc2dparam, which contains the following parameters (with some example values):

  • N2 = 1000, # Number of iterations in the new Iter
  • run2d = TRUE, # Should the mc2d function be used or not?
  • info = 1, # An ovariable that may add new indices to the ovariable to be converted. If none, use 1.
  • newmarginals = c("Gender", "Ages", "Country"), # Names of columns that are non-marginals but will be sampled enough to become marginals. The function will produce an ovariable that correctly has these indices as marginals. However, if the function is used within an ovariable formula (which is typically the case), the marginal status is in the end inherited from parents and they may be re-converted to non-marginals. If this happens, the marginal status has to be updated in the assessment model code on case by case basis. Any automatic solution would violate the inheritance rules.
  • method = "bootstrap", # which method to use for 2D Monte Carlo? Currently bootsrap is the only option.
  • fun = mean # Function for aggregating the first Iter dimension.

You can call the function by using code

objects.latest("Op_en7805", code_name = "mc2d")

Rationale

  • 22.11.2017 Version where run2d==FALSE does nothing. [1]

+ Show code

See also