Announcement

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

  • Fastest way to collect values of regression coefs

    I want the values of only 160 of the god knows how many coefficients in my regression.

    I am using reghdfejl but things are not much faster. Is there any stata command or method where I can simply obtain the values of the coefficients for the variables I want? I do not even need the SEs as I will bootstrap them. (this is for a program)

  • #2
    Park:
    welcome to this forum.
    Did you take a look at -statsby-?
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Park:
      welcome to this forum.
      Did you take a look at -statsby-?
      I don't think this would preserve the point estimates. You see, I am estimating this model with a bunch of fixed effects and controls....

      reghdfejl y [coefs of interst varying by town] control vector, absorb(lots of FEs), cluster(id)

      is what I am doing

      Comment


      • #4
        Have you tried regsave?

        Code:
        sysuse auto, clear
        reghdfe price mpg displacement, absorb(foreign)
        regsave
        list
        
             +----------------------------------------------------+
             |          var       coef     stderr    N         r2 |
             |----------------------------------------------------|
          1. |          mpg   -98.8856   63.17063   74   .4631095 |
          2. | displacement   22.40416   4.634239   74   .4631095 |
          3. |        _cons   3850.973   2070.066   74   .4631095 |
             +----------------------------------------------------+
        Associate Professor of Finance and Economics
        University of Illinois
        www.julianreif.com

        Comment


        • #5
          Hi Park
          if you are "absorbing" too many fixed effects, that will most likely increase the number of iterations, thus time needed, to estimate all required coefficients.
          for example 1 fixed effects requires only 1 pass to demean the data
          2 sets would require (in my experience) about 10-40 passes before the demean is ready (within margins of errors)
          with 3 or more, this would increase even more.

          So, better alternative. Choose which FE have few enough cases, and add them as controls, rather than fixed effects.
          Or rethink about your model specificaiton
          F

          Comment


          • #6
            Originally posted by FernandoRios View Post
            Hi Park
            if you are "absorbing" too many fixed effects, that will most likely increase the number of iterations, thus time needed, to estimate all required coefficients.
            for example 1 fixed effects requires only 1 pass to demean the data
            2 sets would require (in my experience) about 10-40 passes before the demean is ready (within margins of errors)
            with 3 or more, this would increase even more.

            So, better alternative. Choose which FE have few enough cases, and add them as controls, rather than fixed effects.
            Or rethink about your model specificaiton
            F
            I run this routine, and all processes exit with errors

            HTML Code:
            cap program drop investment_rat3
            program define investment_rat3, eclass
            global main_restrictions slead1_k1<50 & i_rate<10 & rel_year>=-5 & rel_year<5
            global main_restrictions2 slead1_w<10 & rel_year>=-5 & rel_year<5
            global main_restrictions3a pgrowth>-2.621353 & pgrowth<2.114623 & rel_year>=-5 & rel_year<5
            global fixed_effects i t i.t#c.praz ///
            i.sector2#c.GDP_growth i.score#c.size_pctile1 ///
            i.t#c.GDP_growth
            ****************************************************************************
            * 2c. First regression to obtain lambdas
            ****************************************************************************
            preserve
            reghdfejl cas pc_trib_N*  STUFF, absorb(STUFF) compact
            restore
            preserve
            ****************************************************************************
            * 2d. Calculate lambda_pre and lambda_post based on regression
            ****************************************************************************
            gen lambda_pre = .
            gen lambda_post = .
            forval i = 1/160 {
            cap scalar lambda_`i' = _b[pc_trib_N`i']
            replace lambda_pre = lambda_`i' if trib_N_pre == `i'
            replace lambda_post = lambda_`i' if trib_N_post == `i'
            }
            gen lambda_diff = lambda_post - lambda_pre
            gen post_treatment = lambda_diff * (rel_year>=0) if dataset1==0
            cap drop lambda_*
            ****************************************************************************
            * 2e. Final regression of interest
            ****************************************************************************
            reghdfejl STUFF post_treatment slead1_k1 if $main_restrictions & dataset1==0, ///
            absorb($fixed_effects) vce(cl codice_f)
            /*
            Post the coefficient vector into e(b). We also post the estimation
            sample for bootstrap to know which observations were used.
            */
            matrix b = e(b)
            // 2. Post them as e(b) and e(V)
            ereturn post b
            restore
            end

            Comment

            Working...
            X