Hi, I have a dichotomous variable (Q1) whose answers are Yes or No. Also I have 2 categorical explanatory variables (V1 and V2) with two levels each. I used logistic regression to determine whether there is an effect of V1, V2 or an interaction between them. I used the R and SAS, just for the conference. It happens that there is disagreement about the effect of the explanatory variables between the two softwares. R: q1 = glm(Q1~grau*genero, family=binomial, data=dados) anova(q1, test="Chisq") Df Deviance Resid. Df Resid. Dev P(>|Chi|) NULL 202 277.82 grau 1 4.3537 201 273.46 0.03693 * genero 1 1.4775 200 271.99 0.22417 grau:genero 1 0.0001 199 271.99 0.99031 SAS: proc logistic data=psico; class genero (param=ref ref='0') grau (param=ref ref='0'); model Q1 = grau genero grau*genero / expb; run; Type 3 Analysis of Effects Wald Effect DF Chi-Square Pr > ChiSq grau 1 1.6835 0.1945 genero 1 0.7789 0.3775 genero*grau 1 0.0002 0.9902 The parameters estimates are the same for both. Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) 0.191055 0.310016 0.616 0.538 grau 0.562717 0.433615 1.298 0.194 genero -0.355358 0.402650 -0.883 0.377 grau:genero 0.007052 0.580837 0.012 0.990 What am I doing wrong? Thanks, -------------------------------------- Silvano Cesar da Costa Departamento de Estat?stica Universidade Estadual de Londrina Fone: 3371-4346
Hi Silvano, this is FAQ 7.17 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-does-the-output-from-anova_0028_0029-depend-on-the-order-of-factors-in-the-model_003f hth. Silvano schrieb:> Hi, > > I have a dichotomous variable (Q1) whose answers are Yes or No. > Also I have 2 categorical explanatory variables (V1 and V2) with two > levels each. > > I used logistic regression to determine whether there is an effect of > V1, V2 or an interaction between them. > > I used the R and SAS, just for the conference. It happens that there > is disagreement about the effect of the explanatory variables between > the two softwares. > > R: > q1 = glm(Q1~grau*genero, family=binomial, data=dados) > anova(q1, test="Chisq") > > Df Deviance Resid. Df Resid. Dev P(>|Chi|) > NULL 202 277.82 > grau 1 4.3537 201 273.46 0.03693 * > genero 1 1.4775 200 271.99 0.22417 > grau:genero 1 0.0001 199 271.99 0.99031 > > SAS: > proc logistic data=psico; > class genero (param=ref ref='0') grau (param=ref ref='0'); > model Q1 = grau genero grau*genero / expb; > run; > Type 3 Analysis of Effects > Wald > Effect DF Chi-Square Pr > ChiSq > > grau 1 1.6835 0.1945 > genero 1 0.7789 0.3775 > genero*grau 1 0.0002 0.9902 > > The parameters estimates are the same for both. > Coefficients: > Estimate Std. Error z value Pr(>|z|) > (Intercept) 0.191055 0.310016 0.616 0.538 > grau 0.562717 0.433615 1.298 0.194 > genero -0.355358 0.402650 -0.883 0.377 > grau:genero 0.007052 0.580837 0.012 0.990 > > What am I doing wrong? > > Thanks, > > -------------------------------------- > Silvano Cesar da Costa > Departamento de Estat?stica > Universidade Estadual de Londrina > Fone: 3371-4346 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
On Apr 1, 2010, at 8:19 AM, Silvano wrote:> Hi, > > I have a dichotomous variable (Q1) whose answers are Yes or No. > Also I have 2 categorical explanatory variables (V1 and V2) with two > levels each. > > I used logistic regression to determine whether there is an effect > of V1, V2 or an interaction between them. > > I used the R and SAS, just for the conference. It happens that there > is disagreement about the effect of the explanatory variables > between the two softwares.Not really. You are incorrectly interpreting what SAS is reporting to you, although in your defense I think it is SAS's fault, and that what SA is reproting is nonsensical.> > R: > q1 = glm(Q1~grau*genero, family=binomial, data=dados) > anova(q1, test="Chisq") > > Df Deviance Resid. Df Resid. Dev P(>|Chi|) > NULL 202 277.82 > grau 1 4.3537 201 273.46 0.03693 * > genero 1 1.4775 200 271.99 0.22417 > grau:genero 1 0.0001 199 271.99 0.99031 > > SAS: > proc logistic data=psico; > class genero (param=ref ref='0') grau (param=ref ref='0'); > model Q1 = grau genero grau*genero / expb; > run; > Type 3 Analysis of Effects > Wald > Effect DF Chi-Square Pr > ChiSq > > grau 1 1.6835 0.1945 > genero 1 0.7789 0.3775 > genero*grau 1 0.0002 0.9902I'm having difficulty figuring our how "type 3" analysis makes any sense in this situation. Remember that "type 3" analysis supposedly gives you an estimate for a covariate that is independent of its order of entry. How could you sensible be adding either of those "main effects" terms to a model that already had the interaction and the other covariate in it already? The nested model perspective offered by R seems much more sensible. -- David> > The parameters estimates are the same for both. > Coefficients: > Estimate Std. Error z value Pr(>|z|) > (Intercept) 0.191055 0.310016 0.616 0.538 > grau 0.562717 0.433615 1.298 0.194 > genero -0.355358 0.402650 -0.883 0.377 > grau:genero 0.007052 0.580837 0.012 0.990 > > What am I doing wrong? > > Thanks, > > -------------------------------------- > Silvano Cesar da Costa > Departamento de Estat?stica > Universidade Estadual de Londrina > Fone: 3371-4346 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.