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

st: Re: using coefficients from model

From   "Martin Weiss" <>
To   <>
Subject   st: Re: using coefficients from model
Date   Mon, 30 Mar 2009 22:00:34 +0200


sysuse auto, clear
reg price weight rep tr
g y=_b[_cons]+_b[weight]*weight+_b[rep78]*rep+_b[trunk]*trunk
*compare to built-in solution
predict pred
compare pred y

----- Original Message ----- From: "Chris Witte" <>
To: <>
Sent: Monday, March 30, 2009 9:55 PM
Subject: st: using coefficients from model

I am using stata 9.2. I would like to know how to call the coefficients from the estimation results matrix e(b) and use them in an equation. For example, if my matrix e(b) has values for "_cons" and coefficient "test", I would like to calculate the answer to an equation y = [_cons] + x*[test]. How can I do this?

The reason why I want to do this is because I am trying to find the value _fracpoly_ adjusts its estimates by. If I use this output from my _fracpoly_ estimation:

study1twsg Coef. Std. Err. t P>t [95% Conf. Interval]
Itemp__1 15093.12 4454.121 3.39 0.012 4560.802 25625.45
Itemp__2 -10666.18 3136.84 -3.40 0.011 -18083.63 -3248.734
Itemp__3 1945.114 569.9302 3.41 0.011 597.4436 3292.785
_cons .0053322 .0008244 6.47 0.000 .0033828 .0072815
Deviance: -113.24. Best powers of temp among 164 models fit: -2 -2 -2.

and I plug in these coefficients with my 'x' having a value of 25, my linear regression equation for predicting y is:


However, this equation does not yield the same value as _predict_ (or _fracpred_), and this is because fracpoly secretly adjusts its constant. If I can calculate the answer to this equation and put it into a variable, I can then find the difference between this variable and the value that _fracpred_ gives.

Thank you for your help. Hopefully this isn't too confusing.


*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2021 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index