useeior icon indicating copy to clipboard operation
useeior copied to clipboard

derive an M matrix for IEF models

Open bl-young opened this issue 1 year ago • 14 comments

When an M matrix is present an N matrix will also be constructed during the regular course of model build.

bl-young avatar Sep 06 '24 19:09 bl-young

Leaving this as draft for now as it may require further discussion.

bl-young avatar Sep 06 '24 19:09 bl-young

A few notes about this approach:

  • Sectors for which have no final demand (e.g. "211") will have coefficients of 0 in the M matrix, even if values exist in M_m and M_d
  • I had assumed that for all sectors, the M value for any flow and sector would be somewhere in between the value for M_m and M_d, but this is not the case, perhaps this relates to the first point

Example: M_d: image

M_m: image

derived M: image

bl-young avatar Sep 06 '24 20:09 bl-young

  • I had assumed that for all sectors, the M value for any flow and sector would be somewhere in between the value for M_m and M_d, but this is not the case, perhaps this relates to the first point

And this is especially clear for the flows not available in the IEFs which are identical for M_m and M_d e.g. HFCs

bl-young avatar Sep 06 '24 20:09 bl-young

@WesIngwersen see the commit above which is using ratios from the domestic production demand vector relative to the import consumption demand vector, which I'm not sure is quite right still

bl-young avatar Sep 10 '24 01:09 bl-young

Yes i reviewed the approach and its still problematic, perhaps due to differences in the demand vectors as well as the negatives present which mess up ratios.

I propose more of a weighted average approach, using commodity output, q and the total imports m

$$dr = q/(q+m)$$

$$mr = 1 - dr$$

$$M = M_d \hat{dr} + M_m \hat{mr}$$

WesIngwersen avatar Sep 10 '24 17:09 WesIngwersen

Have you made any scripts for testing this with different models?

WesIngwersen avatar Sep 11 '24 12:09 WesIngwersen

Have you made any scripts for testing this with different models?

The automated model builds include USEEIOv2.3-GHG and USEEIOv2.3-s-GHG, as well as a two region model (GA) with IEFs GAEEIOv1.1-GHG-19-IF. So all those models are able to build the M.

But no I haven't done an external script to do that explicitly - are there certain validations that we want to test after building the M this way?

bl-young avatar Sep 11 '24 14:09 bl-young

Make sure each value is in between the respective value in M_m and M_d. To do this might need to get max and min matrices

WesIngwersen avatar Sep 11 '24 16:09 WesIngwersen

the detail model is failing for S00900 Rest of World Adjustment. total imports for that sector are negative, so the ratios are dr > 1, and mr <0 for that sector, causing the error. Would it make sense to force that ratio to all domestic for that sector (dr = 1)

bl-young avatar Sep 11 '24 23:09 bl-young

the detail model is failing for S00900 Rest of World Adjustment. total imports for that sector are negative, so the ratios are dr > 1, and mr <0 for that sector, causing the error. Would it make sense to force that ratio to all domestic for that sector (dr = 1)

That's OK, that should not be an issue - we always have exceptions with RoW adjustment since its an accounting correction row and meaningless for use in the model.

thanks I assume this check passes for some state models and the summary model?

WesIngwersen avatar Sep 12 '24 20:09 WesIngwersen

That's OK, that should not be an issue - we always have exceptions with RoW adjustment since its an accounting correction row and meaningless for use in the model.

ok I'll change this from a stop to a print statement or something like that as a form of validation, not a requirement

thanks I assume this check passes for some state models and the summary model?

I need to check - the other models may not have run on the action when the detail model failed, but yes I tested this with those models as well and it should work.

bl-young avatar Sep 12 '24 21:09 bl-young

Confirmed that the validation passes for summary model and 2R GA model, and prints the failures for the detail model: image

bl-young avatar Sep 13 '24 01:09 bl-young

OK I think we can proceed with updating N and related vars using this new M

WesIngwersen avatar Sep 13 '24 12:09 WesIngwersen

by building $M$ in this way, which is to say, right after $M_m$ and $M_d$, means that $N$ is produced automatically

https://github.com/USEPA/useeior/blob/e232ca115ee63a513b644950a04f533542888407/R/BuildModel.R#L72-L83

bl-young avatar Sep 13 '24 12:09 bl-young

We will need to decide if this is going to be integrated with v1.6.1 (CBEI model release) or wait until v1.7

bl-young avatar Oct 22 '24 13:10 bl-young

Bring this in w/ v1.6.1 as it will be described in the CBEI report.

bl-young avatar Oct 30 '24 20:10 bl-young