Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add other sampling schemes #16

Closed
4 tasks
abigailsnyder opened this issue Jul 8, 2020 · 1 comment
Closed
4 tasks

add other sampling schemes #16

abigailsnyder opened this issue Jul 8, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@abigailsnyder
Copy link

Forgot to open issue on Jul 06, 2020, when work started:
currently, from the code, it appears that the monthly fractions are sampled from a distribution once for each realization of annual data. So every year in realization 1 is the same kind of year, every year in realization 2 is the same kind of year (but different from the kind of year in realization 1).

  • verify that is what the code is doing
  • add option for using just the mode estimate from the fit for the fractions from the fit multivariable beta distribution, for all years and realizations
  • add option for sampling across years (year 1 is the same kind of year in every realization, but a different kind of year than year 2)
  • add option for sampling across realizations and years
@rplzzz
Copy link
Contributor

rplzzz commented Jul 8, 2020

currently, from the code, it appears that the monthly fractions are sampled from a distribution once for each realization of annual data. So every year in realization 1 is the same kind of year, every year in realization 2 is the same kind of year (but different from the kind of year in realization 1).

I don't think that's what's happening. Here is the code that calculates the monthly fractions:

monthly_fractions <- gtools::rdirichlet(nyear, alpha[,igrid]) # matrix[nyear,12]

This should produce nyear distinct sets of 12 monthly fractions, which are subsequently multiplied by the annual totals to get monthly totals. For example, for nyear = 10:

> alpha <- seq(1,12)
> yrs10 <- gtools::rdirichlet(10, alpha)
> round(yrs10,4)
        [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]   [,9]  [,10]  [,11]  [,12]
 [1,] 0.0167 0.0240 0.0429 0.0175 0.0535 0.1124 0.0848 0.0682 0.1773 0.1497 0.0727 0.1802
 [2,] 0.0085 0.0299 0.0530 0.0951 0.0538 0.0807 0.1000 0.0847 0.1098 0.0952 0.1362 0.1530
 [3,] 0.0065 0.0243 0.0045 0.0727 0.0955 0.1721 0.0658 0.0339 0.0548 0.2302 0.1346 0.1051
 [4,] 0.0331 0.0314 0.0221 0.0690 0.0556 0.0487 0.0717 0.1458 0.1131 0.1415 0.1844 0.0834
 [5,] 0.0125 0.0066 0.0496 0.0559 0.0658 0.1015 0.0364 0.0828 0.1786 0.1142 0.0844 0.2117
 [6,] 0.0366 0.0148 0.0158 0.0173 0.0458 0.1023 0.0585 0.0966 0.1201 0.1516 0.1422 0.1983
 [7,] 0.0071 0.0025 0.0491 0.0829 0.0620 0.0745 0.0827 0.1170 0.0873 0.0910 0.1860 0.1581
 [8,] 0.0001 0.0423 0.0439 0.0262 0.0877 0.1008 0.0652 0.1211 0.0915 0.1442 0.1348 0.1420
 [9,] 0.0074 0.0407 0.0857 0.0541 0.0866 0.0314 0.1105 0.1502 0.1123 0.0992 0.1241 0.0979
[10,] 0.0035 0.0043 0.0461 0.0583 0.1280 0.0378 0.0968 0.0536 0.1275 0.1614 0.1745 0.1081

Unless there is something else that I've missed, this should give the desired result: nyear different years, each with its annual total apportioned according to a different draw from the same Dirichlet distribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants