At 06:45 PM 1/18/2013, daniel56061-stata@yahoo.de wrote:
Hello,
when i use indicator i with selecting level of a factor variable
like i1.varname to run a regression I get strange results.
For example:
sysuse blong,clear
regress bp i.sex i.when c.patient i.when#c.patient
regress bp i1.sex i.when c.patient i.when#c.patient
regress bp i0.sex i.when c.patient i.when#c.patient
This regression is wihout sense but theoretically it should
estimate the same model and should give same results except for
variable sex cause all I do is demand an indicator for a different
level of a 2-level variable sex.
But if I run these lines I get three regressions with three
different coefficients for the variable "when" and "patient" even I
didnt change anything that should be related to these variables.
Whats wrong here?
regards
Daniel
First off, I think you mean bplong.
Second, it seems to work fine for me. Are you leaving something out?
Could your version of Stata be corrupted or out of date? I'm sure the
problem is at your end because everything seems ok on mine. I'll just
go ahead and give all the output below.
. sysuse bplong.dta, clear
(fictional blood-pressure data)
. regress bp i.sex i.when c.patient i.when#c.patient
Source | SS df MS Number of obs = 240
-------------+------------------------------ F( 4, 235) = 21.29
Model | 10881.7115 4 2720.42787 Prob > F = 0.0000
Residual | 30031.0843 235 127.791848 R-squared = 0.2660
-------------+------------------------------ Adj R-squared = 0.2535
Total | 40912.7958 239 171.183246 Root MSE = 11.305
--------------------------------------------------------------------------------
bp | Coef. Std. Err. t P>|t| [95%
Conf. Interval]
---------------+----------------------------------------------------------------
1.sex
| -24.86705 2.919115 -8.52 0.000 -30.61803 -19.11608
2.when
| -4.519608 2.937149 -1.54 0.125 -10.30611 1.266899
patient
| .3029286 .0471077 6.43 0.000 .2101214 .3957359
|
when#c.patient |
2 | -.0094555 .0421309 -0.22 0.823 -.092458
.0735469
|
_cons
| 150.5563 2.20753 68.20 0.000 146.2073 154.9054
--------------------------------------------------------------------------------
. regress bp i1.sex i.when c.patient i.when#c.patient
Source | SS df MS Number of obs = 240
-------------+------------------------------ F( 4, 235) = 21.29
Model | 10881.7115 4 2720.42787 Prob > F = 0.0000
Residual | 30031.0843 235 127.791848 R-squared = 0.2660
-------------+------------------------------ Adj R-squared = 0.2535
Total | 40912.7958 239 171.183246 Root MSE = 11.305
--------------------------------------------------------------------------------
bp | Coef. Std. Err. t P>|t| [95%
Conf. Interval]
---------------+----------------------------------------------------------------
1.sex
| -24.86705 2.919115 -8.52 0.000 -30.61803 -19.11608
2.when
| -4.519608 2.937149 -1.54 0.125 -10.30611 1.266899
patient
| .3029286 .0471077 6.43 0.000 .2101214 .3957359
|
when#c.patient |
2 | -.0094555 .0421309 -0.22 0.823 -.092458
.0735469
|
_cons
| 150.5563 2.20753 68.20 0.000 146.2073 154.9054
--------------------------------------------------------------------------------
. regress bp i0.sex i.when c.patient i.when#c.patient
Source | SS df MS Number of obs = 240
-------------+------------------------------ F( 4, 235) = 21.29
Model | 10881.7115 4 2720.42787 Prob > F = 0.0000
Residual | 30031.0843 235 127.791848 R-squared = 0.2660
-------------+------------------------------ Adj R-squared = 0.2535
Total | 40912.7958 239 171.183246 Root MSE = 11.305
--------------------------------------------------------------------------------
bp | Coef. Std. Err. t P>|t| [95%
Conf. Interval]
---------------+----------------------------------------------------------------
0.sex
| 24.86705 2.919115 8.52 0.000 19.11608 30.61803
2.when
| -4.519608 2.937149 -1.54 0.125 -10.30611 1.266899
patient
| .3029286 .0471077 6.43 0.000 .2101214 .3957359
|
when#c.patient |
2 | -.0094555 .0421309 -0.22 0.823 -.092458
.0735469
|
_cons
| 125.6893 4.214552 29.82 0.000 117.3862 133.9924
--------------------------------------------------------------------------------
.
-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: Richard.A.Williams.5@ND.Edu
WWW: http://www.nd.edu/~rwilliam
*
* 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/