Note that there are some explanatory texts on larger screens.

plurals
  1. POsimple Stata program
    primarykey
    data
    text
    <p>I am trying to write a simple program to combine coefficient and standard error estimates from a set of regression fits. I run, say, 5 regressions, and store the coefficient(s) and standard error(s) of interest into vectors (Stata matrix objects, actually). Then, I need to do the following:</p> <ol> <li>Find the mean value of the coefficient estimates.</li> <li>Combine the standard error estimates according to the formula suggested for combining results from "multiple imputation". The formula is the square root of the formula for "T" on page 6 of <a href="http://support.sas.com/rnd/app/papers/multipleimputation.pdf" rel="nofollow noreferrer">this document</a>.</li> </ol> <p>I have written Stata code that does this once, but I want to write this as a function (or "program", in Stata speak) that takes as arguments the vector (or matrix, if possible, to combine multiple estimates at once) of regression coefficient estimates and the vector (or matrix) of corresponding standard error estimates, and then generates 1 and 2 above. Here is the code that I wrote:</p> <p>(breg is a 1x5 vector of the regression coefficient estimates, and sereg is a 1x5 vector of the associated standard error estimates)</p> <pre><code>mat ones = (1,1,1,1,1) mat bregmean = (1/5)*(ones*breg’) scalar bregmean_s = bregmean[1,1] mat seregmean = (1/5)*(ones*sereg’) mat seregbtv = (1/4)*(breg - bregmean#ones)* (breg - bregmean#ones)’ mat varregmi = (1/5)*(sereg*sereg’) + (1+(1/5))* seregbtv scalar varregmi_s = varregmi[1,1] scalar seregmi = sqrt(varregmi_s) disp bregmean_s disp seregmi </code></pre> <p>This gives the right answer for a single instance. Any pointers would be great!</p> <p>UPDATE: I completed the code for combining estimates in a kXm matrix of coefficients/parameters (k is the number of parameters, m the number of imputations). Code can be found <a href="http://www.columbia.edu/~cds81/docs/methods/micombine.do" rel="nofollow noreferrer">here</a>.</p> <p>Thanks to Tristan and Gabi for the pointers.</p> <hr> <p>UPDATE: I completed the code for combining a kXm matrix of coefficients/parameters, where k is the number of coefficients/parameters, and m is the number of imputations. You can find it <a href="http://www.columbia.edu/~cds81/docs/methods/micombine.do" rel="nofollow noreferrer">here</a>.</p> <p>Thanks to Tristan and Gabi for the hints.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload