USEPA / useeior

Estimating potential environmental impacts of goods and services in the US economy
MIT License
31 stars 19 forks source link

calculateOutputRatio returning invalid ratios for summary level models #236

Closed WesIngwersen closed 1 year ago

WesIngwersen commented 2 years ago

Function at https://github.com/USEPA/useeior/blob/0e4ac3d7c37e7860da9194b5b12d9bacf89ce74a/R/UtilityFunctions.R#L63

All values should be 1 for toSummaryRatio for this model because its a summary model

library(useeior)
modelname <- "USEEIOv2.0-s-GHG"
model <- buildModel(modelname)
output_ratio <- calculateOutputRatio(model, output_type="Commodity")

>output_ratio
    SectorCode toSummaryRatio toSectorRatio
1        111CA     0.10000000  0.0960437453
11       113FF     0.33333333  0.0131875158
14         211     1.00000000  0.2503478926
15         212     0.20000000  0.0894759801
20         213     0.50000000  0.1511361035
22          22     0.33333333  0.3333333333
25          23     0.08333333  0.0833333333
37       311FT     0.03448276  0.0101030461
66       313TT     0.16666667  0.0005438286
72       315AL     0.50000000  0.0002199816
74         321     0.25000000  0.0008787147
78         322     0.12500000  0.0019647823
86         323     0.50000000  0.0007514927
88         324     0.25000000  0.0090303522
92         325     0.05263158  0.0085031100
111        326     0.10000000  0.0023793767
121        327     0.08333333  0.0010636447
133        331     0.10000000  0.0029537768
143        332     0.05000000  0.0036793449
163        333     0.03571429  0.0043410796
191        334     0.05000000  0.0033940180
211        335     0.05882353  0.0013183889
228     3361MV     0.07142857  0.0055513231
242     3364OT     0.09090909  0.0029478071
253        337     0.12500000  0.0007009107
261        339     0.09090909  0.0016013701
272         42     0.09090909  0.0909090909
283        441     1.00000000  0.0307028537
284        445     1.00000000  0.0378843633
285        452     1.00000000  0.0398317726
286        4A0     0.16666667  0.1485968351
292        483     1.00000000  0.0402610495
293        484     1.00000000  0.2361283061
294        485     1.00000000  0.0533961126
295        486     1.00000000  0.0321745080
296      487OS     0.50000000  0.1639421384
298        493     1.00000000  0.0907843225
299        481     1.00000000  0.1562879803
300        482     1.00000000  0.0630834443
301        511     0.20000000  0.0424076491
306        512     0.50000000  0.0264083178
308        513     0.20000000  0.1263907303
313        514     0.33333333  0.0343971557
316         61     0.33333333  0.0374489400
318        621     0.14285714  0.0983260414
323        622     1.00000000  0.0952151152
327        624     0.33333333  0.0191264725
329        623     0.50000000  0.0233881789
332      711AS     0.20000000  0.0378825361
337        721     1.00000000  0.0493111510
338        713     0.33333333  0.0477563813
341        722     0.33333333  0.2060023416
344         81     0.08333333  0.0833333333
356      521CI     0.50000000  0.0650160215
358        523     0.50000000  0.0450634003
360        524     0.33333333  0.0744383790
363        525     1.00000000  0.0129755322
364      532RL     0.25000000  0.0346899761
368         HS     0.50000000  0.1597787382
370        ORE     1.00000000  0.0852331065
371        GFE     0.33333333  0.0125245127
373       GSLE     0.33333333  0.0141060012
375       GFGD     1.00000000  0.1078772855
376       GFGN     1.00000000  0.0579552320
377       GSLG     0.33333333  0.2514253136
382      Other     0.50000000  0.5000000000
384       5411     1.00000000  0.0129823678
385     5412OP     0.10000000  0.0688180223
393       5415     0.33333333  0.0176076690
395         55     1.00000000  0.0196974222
396        561     0.12500000  0.0277787120
407        562     1.00000000  0.0040872846
408       Used     0.50000000  0.5000000000
MoLi7 commented 2 years ago

https://github.com/USEPA/useeior/commit/d8fc51cbff716b0c4d32f5d86df643b0d749c5bc corrects the calculation of output ratio and execute it conditionally based on model IO level.