tags:

views:

115

answers:

3

I'm trying to replicate my SAS work in R, but I get slightly different results -- differences that can't be explained by rounding error.

Here's my SAS code:

proc qlim data=mydata;
   model y = x1 x2 x3/ discrete(d=probit);
   output out=outdata marginal;
   title "just ran QLIM model";
run;
quit;

And here's my R code:

mymodel <- glm(y ~ x1 + x2 + x3, family=binomial(link="probit"), data=mydata)

I'm not really sure why I'd get the different results, and would greatly appreciate an explanation.

EDIT Here's my data:

2.66 20 0 0 2.89 22 0 0 3.28 24 0 0 2.92 12 0 0 4.00 21 0 1 2.86 17 0 0 2.76 17 0 0 2.87 21 0 0 3.03 25 0 0 3.92 29 0 1 2.63 20 0 0 3.32 23 0 0 3.57 23 0 0 3.26 25 0 1 3.53 26 0 0 2.74 19 0 0 2.75 25 0 0 2.83 19 0 0 3.12 23 1 0 3.16 25 1 1 2.06 22 1 0 3.62 28 1 1 2.89 14 1 0 3.51 26 1 0 3.54 24 1 1 2.83 27 1 1 3.39 17 1 1 2.67 24 1 0 3.65 21 1 1 4.00 23 1 1 3.1 21 1 0 2.39 19 1 1

And here's my estimated coefficients (std errors in parantheses):

SAS: -7.452320 (2.542536) 1.625810 (0.693869) 0.051729 (0.083891) 1.426332 (0.595036) R: -7.25319 (2.50977) 1.64888 (0.69427) 0.03989 (0.07961) 1.42490 (0.58347)

A: 

I'm an R newbie, but I have a suggestion.

Try running the probit using another R package...try Zelig.

mymodel <- zelig(y ~ x1 + x2 + x3, model="probit", data=mydata)
summary(mymodel)

Are the regression coefficients different in this model?

ATMathew
`zelig` uses `glm` to fit probit models, so there should be no difference.
brentonk
+3  A: 

It is possibly in the contrast matrix used by default. R uses treatment contrasts while SAS uses it's own. Look up contrasts and contr.SAS in the help. If you're using SAS contrasts a lot you might want to just set the options to that.

options(contrasts=c("contr.SAS", "contr.poly"))

To get an idea how this affects things observe the difference in treatment and SAS contrast matrices

contr.treatment(4)
  2 3 4
1 0 0 0
2 1 0 0
3 0 1 0
4 0 0 1

contr.SAS(4)
  1 2 3
1 1 0 0
2 0 1 0
3 0 0 1
4 0 0 0
John
A: 

This is a great source http://sas-and-r.blogspot.com/

Dirk Nachbar