Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: how to convert regression coefficients into variables


From   Kevin Geraghty <[email protected]>
To   [email protected]
Subject   Re: st: how to convert regression coefficients into variables
Date   Tue, 29 Mar 2011 18:34:12 -0700 (PDT)

naturally, since after you run any sort of regression or other e-class estimation command the results are available in various scalars, matrices, and macros. Run an estimation command and type "ereturn list" to see the totality of what is available to you.


In a regression context the estimated coefficient vector is available as the matrix e(b), and individual coefficients can be referenced as elements of the vector_b. If for example you regress y on x then _b[x] has the x cofficient value, and you can save it in some spot and continue with your regressions.

for example, you have a cumulating file called mycoefs and the variable "x" in mycoefs stores coefficient values for x. 

regress y x
preserve
    use mycoefs, clear
    local nplus = _N +1   
    set obs `nplus' 
    replace x = _b[x] in last
    replace spec = "myregspecdesc" in last
    save mycoefs, replace
restore


you get the idea. This is a pretty common task. There may be a more elegant way to to the above, but the above approach would certainly work.








----- "Steve Martin" <[email protected]> wrote:

> I am using -cnsreg- to estimate a constrained regression model in
> Stata 11.
> 
> 
> I am interested in how the coefficient (call this b2) on one
> particular
> regressor changes as I change the constraints (call the values of
> these b3
> and b4) on two of the other regressors.  
> 
> At the moment the results for each regression are written to a
> spreadsheet.
> 
> However, it would be useful if I could save the values of b2, b3 and
> b4 from
> each regression (eg by writing to a file) with a view to plotting b2,
> b3 and
> b4 from the 30 or so regressions I estimate.
> Is this possible?
> 
> Thanks.
> 
> Steve
> 
> 
> 
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index