Announcement

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

  • Run Bivariate regressions for different groups quickly

    Hi folks,

    I'm looking to see how employment specialisation effects national GVA. I've 35 different groups and rather than running 35 different regressions I was hoping to use a continuous method.

    I have my data set up as panel data, with id 1=Aerospace Industry 2=Pharma Industry and so on.

    Is anyone aware of a command in STATA which would allow me to run a bivariate regression for each of these panels?

    Originally I tried,

    Code:
    forvalues I=1(1)35{
    regress GVA Employment Spec if id=`i'
    {
    However, this code doesn't seem to work. Does anyone have any alternatives, please?

    Kind regards,
    Sean

  • #2

    You should tell in which way the code "doesn't seem to work". But perhaps is it because you used an uppercase I in the first line and a lowercase `i' in the second line.

    Comment


    • #3
      Apologises, I actually used a lower case i. Running it this way provides the following error.

      Code:
      forvalues id=1(1)66{regress rgdpl ki if id =`i'}
      program error:  code follows on the same line as open brace
      r(198);
      Running it this way provides no estimation.

      Code:
      . forvalues i=1(1)66{
       
      regress rgdpl ki if id`i'
       {
      Does anyone know what the issue might be, or can they offer an alternative solution?

      Comment


      • #4
        In your second attempt, you used { as the closing brace. It should be }.

        Comment


        • #5
          Code:
            
          bysort id: regress rgdpl ki
          Also check out statsby

          Comment

          Working...
          X