[R] Help with replicating an old SPSS GLM analysis

Andrew Perrin andrew_perrin at unc.edu
Thu Feb 7 20:00:18 CET 2002


John,

Thanks for responding. After I wrote my message, I figured out that lm
would have been the better model than glm. I reran the following code:

lm(formula = N.DIFFPT ~ AGE.I + INC.I + JOIN.I + WORK.I + EDUC.I + 
    GIVE.I + CS.I + EFF.I + AGE.A + INC.A + JOIN.A + WORK.A + 
    EDUC.A + GIVE.A + CS.A + EFF.A + AGE.I * AGE.A + INC.I * 
    INC.A + JOIN.I * JOIN.A + WORK.I * WORK.A + EDUC.I * EDUC.A + 
    GIVE.I * GIVE.A + CS.I * CS.A + EFF.I * EFF.A, data = acps.df, 
    weights = WT2517)

and, while the results were not exactly the same (perhaps the result of
the difference in interaction terms treatment in your point (3) below),
they're in the same direction and of the same orders of magnitude and
significance. That's enough for my needs for now -- I mainly wanted to be
sure I hadn't forgotten some key step of the process, since it's now been
a few years since I worked with these data.

Thanks again for your detailed response.

----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin
 Assistant Professor of Sociology, U of North Carolina, Chapel Hill
      269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA


On Thu, 7 Feb 2002, John Fox wrote:

> Dear Andrew,
> 
> It's difficult to know from your description what the nature of the model 
> is that you're trying to fit, and (2) what the problem is -- that is, what 
> is the difference between the SPSS and R output: coefficients, sums of squares?
> 
> But the following points might help:
> 
> (1) GLM in SPSS fits linear models, so it is closer to lm in R than to glm, 
> which fits *generalized* linear models.
> 
> (2) Because the predictors in the SPSS GLM procedure follow the keyword 
> WITH they are (I assume) covariates rather than factors. What is the nature 
> of these variables?
> 
> (3) The asterisks in the R model specification do not have the same meaning 
> as in SPSS. In R, the asterisks produce an interaction plus all effects 
> marginal to the interaction. With covariates, the interactions will just be 
> products.
> 
> (4) Despite these problems, I don't see why the coefficient estimates 
> should differ: Because you leave the family unspecified in the call to R 
> glm, you'll get a linear model; specifying the terms marginal to the 
> interactions in the model is redundant but not wrong.
> 
> If you supply some more information, maybe I or someone else can figure out 
> what's wrong.
> 
> John
> 
> At 09:18 PM 2/6/2002 -0500, Andrew Perrin wrote:
> 
> >I'm trying to replicate an analysis I did a few years ago, then in SPSS,
> >using the SPSS GLM command:
> >
> >GLM
> >   n_diffpt  WITH age_i inc_i join_i work_i educ_i  give_i cs_i
> >   eff_i age_a inc_a join_a work_a educ_a give_a cs_a eff_a
> >   /METHOD = SSTYPE(3)
> >   /INTERCEPT = INCLUDE
> >   /PRINT  = PARAMETER ETASQ RSSCP GEF
> >   /CRITERIA = ALPHA(.05)
> >   /DESIGN =
> >         age_i*age_a inc_i*inc_a join_i*join_a work_i*work_a
> >           educ_i*educ_a give_i*give_a cs_i*cs_a eff_i*eff_a
> >         age_i inc_i join_i work_i educ_i give_i cs_i eff_i
> >         age_a inc_a join_a work_a educ_a give_a cs_a eff_a .
> >
> >The results are consistent when run in SPSS; however, I tried the simple
> >version of recoding it in R (after using read.spss to bring in the data),
> >and got entirely different results. I'm assuming there are significant
> >differences in what I'm doing, but I can't find enough documentation of
> >the SPSS GLM procedure to figure out what. Can anyone offer insights?
> >
> >The code I tried under R was:
> >
> >glm.mean <- glm(N.DIFFPT ~ AGE.I + INC.I + JOIN.I + WORK.I + EDUC.I +
> >GIVE.I +
> >         CS.I + EFF.I + AGE.A + INC.A + JOIN.A + WORK.A + EDUC.A + GIVE.A +
> >         CS.A + EFF.A + AGE.I*AGE.A + INC.I*INC.A + JOIN.I*JOIN.A +
> >         WORK.I*WORK.A + EDUC.I*EDUC.A + GIVE.I*GIVE.A + CS.I*CS.A +
> >         EFF.I*EFF.A,
> >         data=acps.df)
> 
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list