I have a huge database and I need to run different regressions with conditional statements.
So I see to options to do it: 1) in the regression include the command data subset (industrycodes==12) and 2) I don't obtain the same results as if cut the data to the values when furniture==12. And they should be the same.
Could somebody help me with the codes, I think I have a problem with this.
I put an example very basic to explain it.
ID roa employees industrycodes
1 0,5 10 12
2 0,3 20 11
3 0,8 15 12
4 0,2 12 12
5 0,7 13 11
6 0,4 8 12
so first I create the subdatabase to compare (when the industry code is 12)
data2<-data1[data1$industrycodes==12,]
and here I run the regressions:
1) for the whole data taking only industrycodes==12 --> here I have the 6 observations
summary(lm(data1$roa~data1$employees, data=subset(data1,industrycodes==12)))
2) cutting the sample when the industrycode==12 --> here of course I have 4 observations
summary(lm(data2$roa~data2$employees),data=data2)
Any ideas of what can be wrong?? Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…