Two-dimensional Monte Carlo: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(→‎Rationale: updated to enable additional indices using info ovariable)
(→‎Answer: a suggestion for non-marginal problem)
Line 12: Line 12:
*  N2 = 1000, # Number of iterations in the new Iter
*  N2 = 1000, # Number of iterations in the new Iter
*  run2d = TRUE, # Should the mc2d function be used or not?
*  run2d = TRUE, # Should the mc2d function be used or not?
*  newmarginals = c("Gender", "Ages", "Country"), # Names of columns that are non-marginals but will be sampled enough to become marginals {{attack|# |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 are re-converted to non-marginals. This should be fixed somehow.|--[[User:Jouni|Jouni]] ([[User talk:Jouni|talk]]) 15:11, 11 June 2017 (UTC)}}
*  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.
*  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.
*  fun = mean # Function for aggregating the first Iter dimension.
Line 19: Line 20:


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


== Rationale ==
== Rationale ==

Revision as of 12:47, 4 October 2017



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

+ Show code

See also