Announcement

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

  • -xttrans- message: "no observations"

    Hi everyone,

    I have some problems with -xttrans- command and need some help please.
    To provide some background, here is a dataset:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long(id sp_zipcode) double(date_contract_start date_contract_end) float kW_power_p1 long(product_classification_encod tariff_ekon_id_encod idcontrato) float solar_dummy
    74163 7010 20462 21608 3.45 3 2 93357 0
    31196 7600 20462 21608 3.45 3 2 93367 0
    27112 7400 20465 21608 5.75 3 2 93375 0
    17066 7310 20521 20971 5.75 3 2 93376 0
    36635 7518 20503 20517 5.75 3 2 93380 0
    44639 7570 20467 21608 5.75 3 2 93384 0
    35215 7590 20458 21608 5.75 3 2 93387 0
    33886 7530 20458 21608 5.75 3 2 93389 0
    17068 7340 20461 21608 4.6 3 2 93395 0
    35869 7670 20466 21608 9.2 1 2 93398 0
    30888 7340 20461 21274 5.75 1 2 93407 0
    22556 7620 20458 21307 4.6 1 2 93421 0
    27386 7011 20459 21608 3.45 3 2 93425 0
    15695 7141 20465 21608 6.9 3 2 93426 0
    end
    format %td date_contract_start
    format %td date_contract_end
    abel values product_classification_encod product_classification_encod label def product_classification_encod 1 "Clasico", modify
    label def product_classification_encod 3 "Sin Sorpresas", modify
    label values tariff_ekon_id_encod tariff_ekon_id_encod
    label def tariff_ekon_id_encod 2 "20DHA", modify
    Basically, I declare -xtset- as a first option:

    Code:
     xtset idcontrato date_contract_start
    I am interested in knowing the transition probabilities between different states for households when they change their contracts. What is the probability of observing this or that switch in contracted powers ("kW_power_p1"), in tariffs ("tariff_ekon_id"), etc?
    I ran for example the code below and obtained the following message in red:

    Code:
    · xttrans kW_power_p1 if !missing(powers_tariff2_less_15000w )
    no observations
    
    · xttrans product_classification_encod if !missing(powers_tariff2_less_15000w )
    no observations
    
    · xttrans tariff_ekon_id_encod if !missing(powers_tariff2_less_15000w )
    no observations
    Does anyone know why I obtained this message?
    Thank you in advance.

    Best,
    Michael

  • #2
    I tried to do this code:

    Code:
    xttrans tariff_ekon_id_encod
    i() required
    r(198);
    But gives me this error. I don't know how to proceed.
    Best,
    Michael

    Comment


    • #3
      Michael:
      you should -xtset- your dataset first as in the following non-sensical toy-example:
      Code:
      . xtset id date_contract_start
      
      Panel variable: id (weakly balanced)
       Time variable: date_contract_start, 05jan2016 to 08mar2016
               Delta: 1 day
      
      . xttrans tariff_ekon_id_encod
      no observations
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Hi,

        Thank you so much for your feedback. The dataex on #1 does not contain some of my repeated ids. Sorry about that.
        I obtain the following error in my "true" dataset:

        Code:
        . xtset id date_contract_start
        repeated time values within panel
        r(451);
        Here is an updated -dataex- which seems more realistic:


        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(power_p1 tariff_ekon_id_encod product_classification_encod)
        1001    1001  9200 18887 21700 4600 1 1
        1001  451697  9200 21701 22431 4600 2 1
        1001 1236132  9200 22432 22645 4600 4 1
        1001 1730454  9200 22646 22676 4600 4 1
        1001 2082075  9200 22677 22735 4600 4 1
        1001 2172904  9200 22736 23010 4600 4 1
        1001 2872183  9200 23011 23069 4600 4 1
        1001 3107888  9200 23070     . 4600 4 4
        1005    1005 48600 18800 21639 3300 1 1
        1005  420392 48600 21640 21651 3300 1 1
        end
        format %td date_contract_start
        format %td date_contract_end
        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
        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

        Thank you again.
        Best regards,
        Michael

        Comment


        • #5
          date_contract_start date_contract_end are not given on a daily basis.
          Rather, they are rather scattered, and I don't know how to deal with this.
          • Is this why it keeps giving me "no observation"?
          Because looking at my dataex in the post #4, we can clearly see that we are observing a change in tariffs (from 1 to 2) for id 1001 between May 31, 2019 and June 1, 2019 (contract end: 21700. contract start: 21701) for example.
          Best,
          Michael

          Comment


          • #6
            MIchael:
            if you gìhave repeated time values within panel, you can -xtset- your dataset with -panelid- only.
            Unfortunately, this fix does not allow you to use-xttrans-.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Hi Lazzaro,

              Thank you for your helpful feedback!
              That's a pity.

              I wish you a wonderful day.
              Best,

              Michael

              Comment

              Working...
              X