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: Mlogit estimated coefficients
From
Joerg Luedicke <[email protected]>
To
[email protected]
Subject
Re: st: Mlogit estimated coefficients
Date
Wed, 8 May 2013 21:50:08 -0400
On Wed, May 8, 2013 at 12:56 PM, Ekim Cem Muyan <[email protected]> wrote:
<snip>
> I couldn't figure out how STATA stores the
> estimations results from a mlogit regression.
Like other eclass commands, -mlogit- stores results in -e()-. After
fitting a model, type -ereturn list- to see what's available. For
example,
mat li e(b)
returns a vector with the estimated coefficients. You can then
use/rearrange these results to your liking. For example, the following
code creates a 2 x k matrix with coefficients, with k being the number
of predictors in the model (including constants):
*---------------------------------------
// Toy data
clear
sysuse auto
replace rep78 = rep78 - 2 if rep78 > 2
// -mlogit- fit
mlogit rep78 price mpg headroom trunk, b(1)
// Create a 2 x k matrix, where k is the
// number of predictors in the model,
// for an arbitrary number of predictors
qui levelsof `e(depvar)', loc(level)
loc base = e(baseout)
loc rowlab = regexr("`level'","`base'","")
loc np = e(k)
mat b = e(b)
mat b1 = b[1, `=`np'/2+1'..`np']
mat b2 = b[1, `=`np'+1'..`=`np'+`np'/2']
mat bmat = b1\b2
mat rownames bmat = `rowlab'
mat li bmat
*---------------------------------------
This could further be automated, for example to allow for arbitrary
base outcomes and number of outcome categories.
Joerg
On Wed, May 8, 2013 at 12:56 PM, Ekim Cem Muyan <[email protected]> wrote:
> Hi! I am having trouble storing my estimated 'mlogit' coefficients in a matrix.
>
> Essentially, I have three categories and five explanatory variables. I
> want to store my coefficients in a 2x5 matrix so that I can transfer
> them to MATLAB automatically. (I will have to do this for many times,
> so I'd rather not copy). I couldn't figure out how STATA stores the
> estimations results from a mlogit regression.
>
> I'd appreciate any feedback. Thanks a lot!
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/