Announcement

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

  • "predict" for independent variable

    Dear All

    I have a time-series cross-sectional sample with c. 155,000 observations where I run the following regression: regress NI DR RET RETDR

    The interesting part of the regression is the beta coefficient for RETDR, as it measures the accounting conservatism within the sample. In order to further use the data I would need this coefficient for each firm in period t, i.e. RETDR_FIRM_PER_YEAR.

    I tried to use the "predict" command, however it does no prediction for the beta coefficients, only for e.g. the dependent variable. Furthermore, I tried to use some for, foreach or forval commands in order to generate this new variable, however, it dit not work out.

    Do you have an idea how to solve this issue?

    Thanks in advance!

    Kind regards
    Alex


  • #2
    Many, many threads on this. See for example the concurrent thread https://www.statalist.org/forums/for...-and-residuals

    Comment


    • #3
      Hi Nick,

      thanks for your reply. I managed to create the following code:

      local i=0
      egen group1 = group(IDENT_YR)
      forval i = 1/153890 {
      local i=`i'+1
      regress NI DR RET RETDR if group1 == `i'
      ereturn list
      mat b=e(b)
      svmat double b, n(matrow)
      }

      Unfortunately, I don't get a beta estimate for each observation. I get the error: insufficient observations.

      Do you know how I can resolve this problem?

      Thank you very much for your support!

      Kind regards
      Alex

      Comment


      • #4
        Sorry, but I won't take the bite here myself -- although nothing is binding here on other people.

        You are choosing a lousy way to do this when I've pointed you to better ways as exemplified in another thread (and probably hundreds of times on Statalist).

        Your method is poor not just because it fails with insufficient observations but because each time around the loop you are just going to (try to) overwrite the previous results.

        Comment

        Working...
        X