Stata and R results not matched in Logistic Regression with two categorical predictors and their interaction [closed]

StackOverflow https://stackoverflow.com/questions/7047159

  •  21-12-2020
  •  | 
  •  

Question

I am getting confused when i am trying to compare the results of Stata and R. I am using example given on the webpage http://www.ats.ucla.edu/stat/stata/webbooks/logistic/chapter2/default.htm First run the following command in Stata

use http://www.ats.ucla.edu/stat/stata/webbooks/logistic/apilog, clear

and then use following commands given in the section (2.2.2 A 2 by 2 Layout with Main Effects and Interaction)

generate cred_ed = cred_hl*pared_hl
logit hiqual cred_hl pared_hl cred_ed

These two command will produce the results given on the webpage.

And then i have used following R code to reproduce same example

Data<- read.csv("Book1.csv",header=T)
data.glm<-glm(hiqual~cred_hl + pared_hl + cred_hl*pared_hl,family=binomial,  data=Data)
summary(data.glm)

But results are not matched!

Data file for R can be download from following link

https://spreadsheets.google.com/spreadsheet/ccc?key=0Ajt182RLsguldFlLQmd6Z1ZoczJCenJIdmREUkhxTFE&hl=en_US

Note: Results for model with only main effects are matched but when we include interaction, it is not matched.

Thanks in Advance.

Was it helpful?

Solution

They give the same results to me (using ucla's data).

library(foreign)
d1 <- read.dta('http://www.ats.ucla.edu/stat/stata/webbooks/logistic/apilog.dta')
m1 <- glm(hiqual~cred_hl + pared_hl + cred_hl*pared_hl,family=binomial,  data=d1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top