Announcement

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

  • Creation of a transitional matrix: How to proceed?

    Hello everyone,

    I need to create a transitional matrix, but I've never done this before and I've been wasting time on it for a while.
    I've had a lot of trouble with -xttrans-, because I always get a "no observations" message, which seems strange to me because when I inspect the data manually, I observe changes. Here are my steps:
    1. xtset idcontrato date_contract_start
    2. xttrans tariff_ekon_id_encod
    3. "no observations"

    So, to give a bit of context. I have a database (which I'll make available below) which includes data on households and their contractual information about their energy tariffs, the various dates the contracts came into effect, etc. In particular, I'd like to look at how the contracts have changed over time.

    In particular, I would like to observe the probability of household i changing from tariff a to tariff b when signing a new contract. I would also like to observe the probability of changing from a type of contract y to a type of contract z. It should be important to know when those changes occur, please.

    Please find a dataex with the first 10 observations, and also a dataex in .dta format if necessary as an attachment. This enclosed example contains 1,000 observations.

    Dataex


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long(id idcontrato sp_zipcode) double(date_contract_start date_contract_end) long(product_classification_encod tariff_ekon_id_encod)
    1001    1001  9200 18887 21700 1 1
    1001  451697  9200 21701 22431 1 2
    1001 1236132  9200 22432 22645 1 4
    1001 1730454  9200 22646 22676 1 4
    1001 2082075  9200 22677 22735 1 4
    1001 2172904  9200 22736 23010 1 4
    1001 2872183  9200 23011 23069 1 4
    1001 3107888  9200 23070     . 4 4
    1005    1005 48600 18800 21639 1 1
    1005  420392 48600 21640 21651 1 1
    end
    format %td date_contract_start
    format %td date_contract_end
    label values product_classification_encod product_classification_encod
    label def product_classification_encod 1 "Clasico", modify
    label def product_classification_encod 4 "Tarifa Justa", modify
    label values tariff_ekon_id_encod tariff_ekon_id_encod
    label def tariff_ekon_id_encod 1 "20A", modify
    label def tariff_ekon_id_encod 2 "20DHA", modify
    label def tariff_ekon_id_encod 4 "20TD", modify

    Here a small description about variables:
    Variables Description
    id Household ID
    idcontrato Contract ID (those should be unique)
    sp_zipcode Zip Code of a given household
    date_contract_start Starting Date of a given contract
    date_contract_end Ending Date of a given contract
    product_classification_encod Represents the Contract Type. It contains 4 types.
    tariff_ekon_id_encod Represents the Tariff Type. In my dataex, it should have 6 types.
    Could you please give me a solution to that?

    Thank you so much in advance!
    Best,

    Michael
    Attached Files

  • #2
    Could anyone help me please?

    I am really stuck as my date variable is not given 1 unit by 1 unit, and I don't know how to proceed.
    Thank you.

    Michael

    Comment

    Working...
    X