Announcement

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

  • Regression outputs

    Hi Stata Users

    I have been working on a event study which involved the following two phases:

    1) Calculating the AR and CAR for a number of event windows
    2) Regressing my CAR on a number of variables

    I have appended the CAR to a file using the following:

    Code:
    keep in 1/1
    append using 6day_car
    save 6day_car, replace
    restore
    My question is how to I export the results of my regressions from (1) to an excel / word file where I am left with only the AR / CAR, t-statistics and the significance levels.

    I would like to have the same for part (2) where I am left with the beta, t-statistics and the significance levels. I have the used the following code to get my results to excel:

    Code:
    forvalues i = 1/1324 {
    preserve
    keep if obs == `i'
    eststo: quietly regress car `var'
    esttab using regresults.csv, replace
    restore
    }
    My problem is that it gives me the following error:

    matsize too small
    You have attempted to create a matrix with too
    many rows or columns or attempted to fit a model
    with too many variables. You need to increase
    matsize; it is currently 400. Use set matsize;
    see help matsize.

    If you are using factor variables and included an
    interaction that has lots of missing cells, either
    increase matsize or set emptycells drop to reduce
    the required matrix size; see help set emptycells.

    If you are using factor variables, you might have
    accidentally treated a continuous variable as a
    categorical, resulting in lots of categories. Use
    the c. operator on such variables.
    I have not been able to find a way to get all results on excel since.

    Would really appreciate if someone could help me. Its the final stage of my work...exporting the file, building my tables and explain the results.

    Thank you guys in advance for your help!
    Last edited by Parvesh Seeballack; 14 Jul 2017, 04:50.

  • #2
    You didn't get a quick answer. You have a difficult question to follow - following the FAQ on asking question might help.

    First, you seem to want to keep some material from estimating the CARs. That's fine, but we'd need to see the code that did the CAR estimates to suggest how you'd keep what you want to keep. You can generally export results using estout or outreg2 - they have many options.

    You need to identify where the problem occurs. Entering set trace on before the loop will help you understand where exactly your "matsize too small" error is appearing. Normally, this occurs when you have piles of variables. The simplest thing would be to increase the matsize. Did you try this?

    I also wonder about
    esttab using regresults.csv, replace Why wouldn't this just replace the file every time it runs? Don't you want to append? Also, it is seldom good practice to run a pile of regressions with one dv and differing iv's.

    Comment


    • #3
      Hi Phil

      Thank you for replying.

      Well here is my code for calculating the CAR:

      Code:
      use eventsdates, clear
      drop date_id
      forvalues i = 1/1324 {
      preserve
      keep if obs == `i'
      joinby nnn using marketdata
      sort date
      drop date_id
      g date_id = _n
      gen day_cnt = date_id
      gen target_day = day_cnt if date==event_date
      egen max_target_day = max(target_day)
      gen evday = day_cnt-max_target_day
      drop day_cnt target_day max_target_day
      sort evday
      gen evt_window=1 if evday>=0 & evday<=6
      gen est_window=1 if evday<=-11 & evday>=-30
      drop if evt_window==. & est_window==.
      foreach var of local vars {
      reg return_`var' returnmarket if est_window==1
      gen rmse_`var' = e(rmse)
      predict phat_`var'
      gen ar_`var' = return_`var' - phat_`var' if evt_window==1
      drop phat_`var'
      }
      drop if evt_window==.
      drop est_window nnn
      ***************************************************
      *Display the CAR and its Test Statistic
      foreach var of local vars {
      egen car_`var' = sum(ar_`var')
      gen tstat_`var' = car_`var'/(rmse_`var'*sqrt(_N))
      drop return_`var' rmse_`var' ar_`var'
      }
      drop returnmarket date_id evday evt_window date
      * DO EVENT analysis, generate CAR in 1/1
      keep in 1/1
      append using 6day_car
      save 6day_car, replace
      restore
      }
      use 6day_car, clear
      Actually I'd like to be able to send the CAR, tstat and confidence interval, i.e. the stars, on one excel sheet.
      Last edited by Parvesh Seeballack; 17 Jul 2017, 14:51.

      Comment


      • #4
        Some folks like appending. I tend to not do this - a matter of taste.

        One way to solve your problem to create four variables with missing values before the - one string and the other three numerical and a counter. Then in the loop, write the values into the appropriate variables in a given observation.

        Something like:
        g car=.
        g tstat=.
        g var=" "
        local i=1
        foreach var of local vars {
        su ar_`var'
        replace car=r(mean) in `i'/`i'
        local i=`i'+1
        }
        At the end, you can export these variables.

        Comment


        • #5
          Hi everyone

          I have been able to get my tables in excel with your help!

          Thanks so much for the advice guys.

          Regards
          Parvesh

          Comment

          Working...
          X