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

profile_sector() fails to handle case "c" #279

Open
Tilmon opened this issue Jun 28, 2024 · 2 comments · May be fixed by #282
Open

profile_sector() fails to handle case "c" #279

Tilmon opened this issue Jun 28, 2024 · 2 comments · May be fixed by #282
Assignees
Labels
bug Something isn't working

Comments

@Tilmon
Copy link
Collaborator

Tilmon commented Jun 28, 2024

The following expectation is met for tiltIndicator::sector_profile() but not for tiltIndicatorAfter::profile_sector() (reprex):

  • Given a company with products from "ipr" exclusively,
  • when the scenarios dataset also includes data from "weo",
  • then the output at product level should also include rows where scenario comes from "weo" and sector_profile is NA.

(Original)

Dear @maurolepore,

in the output you created for Bundesbank, I realized that NAs are not preserved for sector_profile() on product-level as they should, acc. to this reprex.

Specifically, I'm referring to cases similar to the clustered "c" in the reprex - a product in the Land Use sector which hence only has results for IPR scenarios, not for WEO scenarios. Acc. to the reprex, this should lead on product-level to the risk_category == NA for grouped_by == WEO (see screenshot below)

Image

However, this is not how the data behave in the output you shared: I identified a company that only has products in land use sector. While on company-level, the NAs for WEO are shown, on product-level, the output only shows the IPR scenario.

Please bare with me... I wanted to share a reprex... But I get errors. I will try to solve the erros, but given the end is coming to an end, I'll just copy in my code here.

The input data I load are from the latest Release v0.0.0.9003. The code just shows the output for the sample company. You'll see that the grouped_by == WEO is missing on product-level.

# Load packages
library(dplyr)
library(here)
library(readr)

# Data
sec_prod <- read_csv(here("Bundesbank_data_2024-06-27/sector_profile_at_product_level.csv"))

sec_comp <- read_csv(here("Bundesbank_data_2024-06-27/sector_profile_at_company_level.csv"))

# Example 1: of company only producing land use-related goods. 
# What you'll see is that on company-level, NA category is shown for WEO scenario because it doesn't cover land use. 
# But this is not shown on product-level. On product-level, only scenario == IPR is shown.

ex1_sec_prod <- sec_prod |> 
  filter(companies_id == "-fred-sl_00000005407085-741049001")

ex1_sec_comp <- sec_comp |> 
  filter(companies_id == "-fred-sl_00000005407085-741049001")

print(ex1_sec_prod)
print(ex1_sec_comp)

`

cc' @AnneSchoenauer @kalashsinghal

@Tilmon Tilmon changed the title Please check why NAs are not preserved for sector_profile() Please check why NAs are not preserved for sector_profile() on product-level Jun 28, 2024
@Tilmon
Copy link
Collaborator Author

Tilmon commented Jun 28, 2024

@maurolepore addendum: The dataset sector_profile_at_product_level.csv shows has no NAs in the column sector_profile as long as ep_product is not NA. Hence, there must be something wrong, as in the reprex you shared there are two cases in which the sector_profile (or risk_category) can be NA, even if the ep_product (or clustered) is not NA, as you see with clustered c and b in the reprex.

@Tilmon Tilmon changed the title Please check why NAs are not preserved for sector_profile() on product-level Please check why NAs for grouped_by weo_x are not preserved for sector_profile() on product-level Jul 1, 2024
@maurolepore
Copy link
Contributor

maurolepore commented Jul 2, 2024

@Tilmon the problem seems to be in tiltIndicatorAfter. I'll transfer this issue from tiltIndicator to tiltIndicatorAfter.

@maurolepore maurolepore transferred this issue from 2DegreesInvesting/tiltIndicator Jul 2, 2024
@maurolepore maurolepore changed the title Please check why NAs for grouped_by weo_x are not preserved for sector_profile() on product-level profile_sector() should include a scenario of unmatched type Jul 2, 2024
@maurolepore maurolepore changed the title profile_sector() should include a scenario of unmatched type profile_sector() fails to handle the case "c" Jul 2, 2024
@maurolepore maurolepore added the bug Something isn't working label Jul 2, 2024
@maurolepore maurolepore changed the title profile_sector() fails to handle the case "c" profile_sector() fails to handle case "c" Jul 2, 2024
@maurolepore maurolepore linked a pull request Jul 2, 2024 that will close this issue
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants