Announcement

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

  • Alternatives to bysort when dealing with multiple imputations in panel

    Hello everyone,
    I have a panel with 345 observations and six variables. My cross-sectional variable is Panel_bland (15 groups) and my time-series variable is Panel_year (23 years). I xtreg a correlated random effect model with a translog functional form, and imputed missing values (mi) for two variables (fsize and capint).
    I got my results and tried to run my commands by using bysort to identify and compare the coefficients of the individual groups (Panel_bland).

    Code:
     mi estimate: bysort panel_bland xtreg ln_NUE ln_rain ln_fsize ln_capint ln_soil ln_crpr ln_irrig mean_rain mean_fsize mean_capint rain2 fsize2 capint2 soil2 crpr2 irrig2 raca raso racr rafs rair fsca fsso fscr fsir crca crir crso cair caso soir, re
    I got the error: bysort may not be used in this context.
    Reading through Statalist, I tried some alternatives and used the forvalues command with the -if- qualifier but did not manage to make it work. I tried different variations and feel like I am doing a basic mistake when running the commands. Can you help me to find an appropriate alternitive to bysort and/or help me detect the mistake I am doing when running it?
    Thank you in advance. Your help is very much appreciated.

    Code:
    forvalues i= 1(1)15 {
    display "CRE for federal states" `i'
    mi estimate :xtreg ln_NUE ln_rain ln_fsize ln_capint ln_soil ln_crpr ln_irrig mean_rain mean_fsize mean_capint rain2 fsize2 capint2 soil2 crpr2 irrig2 raca raso racr rafs rair fsca fsso fscr fsir crca crir crso cair caso soir if Panel_bland==`i', re
    }
    I got the error: insufficient observations an error occurred when mi estimate executed xtreg on m=1

    Many thanks in advance.

  • #2
    You cannot estimate the random effects model using xtreg on a single cross section. It's a panel data estimator.
    Last edited by Andrew Musau; 19 Feb 2020, 08:27.

    Comment


    • #3
      Dear Andrew,
      thank you for your comment.Are you saying that there is no way to further look at the coefficients of each group of my panel, or is there an alternative?
      I want to assess if the coefficients between the groups differ in their magnitude.
      Is there a way of doing this?

      Originally posted by Andrew Musau View Post
      You cannot estimate the random effects model using xtreg on a single cross section. It's a panel data estimator.

      Comment


      • #4
        Unless you run OLS. See below an example.

        Code:
        webuse grunfeld
        *TIME SERIES (1 COMPANY, 20 YEARS)
        xtreg invest kstock mvalue if company==1, re
        *CROSS SECTION (10 COMPANIES, 1 YEAR)
        xtreg invest kstock mvalue if time==1, re
        Res.:

        Code:
        . webuse grunfeld
        
        . *TIME SERIES (1 COMPANY, 20 YEARS)
        
        . xtreg invest kstock mvalue if company==1, re
        insufficient observations
        r(2001);
        
        . *CROSS SECTION (10 COMPANIES, 1 YEAR)
        
        . xtreg invest kstock mvalue if time==1, re
        insufficient observations
        r(2001);

        Comment


        • #5
          Dear Andrew,
          thank you for your response.
          I found a "solution" by creating groups and including interaction effects to make the results comparable.

          Comment


          • #6
            Thanks for the closure. You should post your solution for the benefit of others who may have a similar problem in the future.

            Comment

            Working...
            X