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

# Re: st: using estimates coefficients

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: using estimates coefficients Date Thu, 22 Mar 2012 08:52:39 +0000

```You note that to use the mean age it is sufficient to -generate- a
variable containing the mean age.

True, but that is certainly not necessary.

Consider this code (assuming _b[age] is available):

su age, meanonly
gen meanage = r(mean)
gen x = _b[age] * meanage

But you can do this instead

su age, meanonly
gen x = _b[age] * r(mean)

What I also see (a lot) is something like

egen meanage = mean(meanage)

This probably looks natural enough, but it is very inefficient.

But you could go further: as _b[age] * r(mean)  is yet another
constant, it can be manipulated as such; there is no need to put it in
a variable.

I've not got a good grasp on your overall problem but it seems that it
may reduce to looping over models and just keeping track of _b[age]
from -regress- and r(mean) from -summarize- without needing to
calculate that many variabes at all.

Nick

On Thu, Mar 22, 2012 at 8:41 AM, Chiara Mussida <cmussida@gmail.com> wrote:

> The proper way of dealing with sum and products of coefficients across
> different model saved by "estimate save" it is to compute the sum
> and/or product in each model separately, as for example:
>
> ge x= _b[age]* meanage, where mean age is the mean value of age in my dataset.
>
> this will be done for each of the 7 model. At the end I will sum the
> variables obtained across each model stored. I hope I will be able to
> save the variables of interest into the same file.
>
> Chiara
>
>
>
> On 21/03/2012, Muhammad Anees <anees@aneconomist.com> wrote:
>> Althoug I am not sure, I have tried this and it has worked;
>>
>> regress dv1=in1 in2 in3 in4
>> display _b[in1]
>> gen agea=-.00036117
>> regress dv1=in1 in2 in3 in4
>> display _b[in1]
>> gen ageb=-.00036117
>> gen sumab=agea+ageb
>> display sumab
>>
>> and so on to include other coefficients from other models.
>>
>> I Hope this may be of help
>>
>> Anees
>>
>> On Wed, Mar 21, 2012 at 9:24 PM, Chiara Mussida <cmussida@gmail.com> wrote:
>>> Dear All,
>>> I run (7) different equations, simple reg command. I now have to play
>>> with the coefficient estimates of each equation, _b[name]
>>>
>>> Each of the 7 estimates have been carried out and stored with diffrent
>>> names (model1,..., model7). I now must sum the coefficients of each
>>> regressors of the different models, like the sum of _b[age] for all
>>> the 7 models.
>>>
>>> How should I compute (manually) this sum across all the models?
>>> _b[age] model1 + _b[age] model2 + ... + _b[age] model7
>>>
>>> I will have also to include the mean values of each characteristics,
>>> but for this it is enough to gen an ad hoc variable for each case.
*
*   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/
```