Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to compute a mean before and after a specific period that differ across households, and then put it in a single graph?

    Hi everyone,

    I would like to compute the average of consumption shares before and after households install solar panels (represented by -date_pv_install-). My dataset goes from January 2021 to July 2023. But I don't know exactly how to proceed. Here is a dataex:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long id double date_pv_install float(date_elec_consumption h_0 h_1 h_2 h_3)
    1059 22973 22281 .005 .005 .006 .005
    1059 22973 22282 .006 .005 .005 .006
    1059 22973 22283 .006 .005 .006 .005
    1059 22973 22284 .005 .005 .006 .005
    1059 22973 22285 .005 .006 .005 .005
    1059 22973 22286 .005 .006 .005 .005
    1059 22973 22287 .006 .005 .005 .006
    1059 22973 22288 .005 .005 .006 .005
    1059 22973 22289 .006 .005 .005 .006
    1059 22973 22290 .005 .006 .005 .005
    end
    format %td date_pv_install
    format %td date_elec_consumption
    The -h_0-, -h_1-, -h_2- and -h_3- represent 12 a.m., 1 a.m., 2 a.m. and 3 a.m. respectively, and so on. These hours go to -h_23-.

    My idea was the following to compute consumption shares, but not sure if feasible:
    1. First, add all the hours to have the daily consumption, by ID and date,
    2. Second, find the consumption shares by dividing each hour by the daily consumption that we compute at 1.
    3. Collapse and have the daily hourly shares, for each hour, day and consumer. The hourly shares have to sum up to one normally.
    4. Do the average before and after the date households installed PV (I don't know how to do that),
    5. Finally, produce a graph showing before the PV installation, and after the PV installation. I would like to have "a normalized" graph, as the date in which households installed PV differs tremendously. But I don't know if this point is feasible or not.
    Thank you in advance for your help!
    Lovely day.

    Michael
    Last edited by Michael Duarte Goncalves; 19 Jan 2024, 04:45.
Working...
X