Alain Reymond wrote:
> Dear R-list members,
>
> I have been a user of SPSS for a few years and quite new to R. I read
> the documentation and tried samples but I have some problems to obtain
> results for a logistic regression under R.
>
> The following SPSS script
>
> LOGISTIC REGRESSION vir
> /METHOD = FSTEP(LR) d007 d008 d009 d010 d011 d012 d013 d014 d015
> d016 d017 d018 d069 d072 d073
> /SAVE = PRED COOK SRESID
> /CLASSPLOT
> /PRINT = GOODFIT CI(95)
> /CRITERIA = PIN(.10) POUT(.10) ITERATE(40) CUT(.5) .
>
> predicts vir (value 0 or 1) according to my parameters d007 to d073. It
> gives me the parameters to retain in the logistic equation and the
> intercept.
> The calculation is made from a set of values of about 1.000 cases.
>
> I have been unable to translate it with success under R. I would like to
> check if I can obtain the same results than with SPSS. Can someone help
> me translate it under R ? I would be most grateful.
If all the variables you mention are available in a data frame, e.g.
virdf, than you can fit a logistic regression model by
mymodel <- glm(vir ~ d007 + d008 + d009 + d010 + d011 + d012 + d013 +
d014 + d015 + d016 + d017 + d018 + d069 + d072 + d073, data = virdf,
family = binomial)
or
mymodel <- glm(vir ~ ., data = virdf, family = binomial)
if there are no variables other than those mentioned above in the
virdf data frame.
Contrary to SPSS you need not specify in advance what you would like
as output. Everything useful is stored in the model object (here:
mymodel) which can then be used to further investigate the model in
many ways:
summary(mymodel)
anova(mymodel, test = "Chisq")
plot(mymodel)
See ?summary.glm, ?anova.glm etc.
For stepwise variable selection (not necessarily corresponding to
STEP(LR)), see ?step or ?add1 to do it `by hand'.
HTH,
Tobias
P.S. You can find an introduction to R specifically targeted at (SAS
and) SPSS users here:
http://oit.utk.edu/scc/RforSAS&SPSSusers.pdf
--
Tobias Verbeke - Consultant
Business & Decision Benelux
Rue de la r?volution 8
1000 Brussels - BELGIUM
+32 499 36 33 15
tobias.verbeke at businessdecision.com