Dimitri Liakhovitski
2010-Mar-04 15:47 UTC
[R] Analogue to SPSS regression commands ENTER and REMOVE in R?
I am not sure if this question has been asked before - but is there a procedure in R (in lm or glm?) that is equivalent to ENTER and REMOVE regression commands in SPSS? Thanks a lot! -- Dimitri Liakhovitski Ninah.com Dimitri.Liakhovitski at ninah.com
Ista Zahn
2010-Mar-04 16:14 UTC
[R] Analogue to SPSS regression commands ENTER and REMOVE in R?
Hi Dimitri, It works a bit differently: ## The SPSS way: compute dum1 = 0. compute dum2 = 0. if(grp = "b") dum1 = 1. if(grp = "c") dum2 = 1. exe. regression /var = y x1 x2 z1 z2 grp /des = def /sta = def zpp cha tol f /dep = y /met = enter x1 x2 /met = enter z1 z2 /met = enter dum1 dum2. ## The R way: contrasts(Dat$grp) <- contr.treatment(n=3, base=1) m.x <- lm(y ~ x1 + x2, data=Dat) m.xz <- update(m.x, . ~ . + z1 + z2) m.xzg <- update(m.xz, . ~ . + grp) anova(m.x, m.xz, m.xzg) Hope it helps, Ista On Thu, Mar 4, 2010 at 10:47 AM, Dimitri Liakhovitski <ld7631 at gmail.com> wrote:> I am not sure if this question has been asked before - but is there a > procedure in R (in lm or glm?) that is equivalent to ENTER and REMOVE > regression commands in SPSS? > Thanks a lot! > > -- > Dimitri Liakhovitski > Ninah.com > Dimitri.Liakhovitski at ninah.com > > ______________________________________________ > 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. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
Michael Conklin
2010-Mar-04 16:14 UTC
[R] Analogue to SPSS regression commands ENTER and REMOVE in R?
I bet you stirred the pot here because you arre asking about stepwise procedures. Look at step, or stepAIC in the MASS library. \Mike On Thu, 4 Mar 2010 07:47:34 -0800 Dimitri Liakhovitski <ld7631 at gmail.com> wrote:> I am not sure if this question has been asked before - but is there a > procedure in R (in lm or glm?) that is equivalent to ENTER and REMOVE > regression commands in SPSS? > Thanks a lot! >
Ista Zahn
2010-Mar-04 16:15 UTC
[R] Analogue to SPSS regression commands ENTER and REMOVE in R?
Oops, forgot the example data used in previous post: set.seed(133) Dat <- data.frame(y=rnorm(10), x1=rnorm(10), x2=rnorm(10), z1=rnorm(10), z2=rnorm(10), grp = factor(c(rep("a", 3), rep("b", 4), rep("c", 3))) ) On Thu, Mar 4, 2010 at 11:14 AM, Ista Zahn <istazahn at gmail.com> wrote:> Hi Dimitri, > It works a bit differently: > > ## The SPSS way: > compute dum1 = 0. > compute dum2 = 0. > if(grp = "b") dum1 = 1. > if(grp = "c") dum2 = 1. > exe. > > regression > ?/var = y x1 x2 z1 z2 grp > ?/des = def > ?/sta = def zpp cha tol f > ?/dep = y > ?/met = enter x1 x2 > ?/met = enter z1 z2 > ?/met = enter dum1 dum2. > > ## The R way: > contrasts(Dat$grp) <- contr.treatment(n=3, base=1) > > m.x <- lm(y ~ x1 + x2, data=Dat) > m.xz <- update(m.x, . ~ . + z1 + z2) > m.xzg <- update(m.xz, . ~ . + grp) > anova(m.x, m.xz, m.xzg) > > Hope it helps, > Ista > > On Thu, Mar 4, 2010 at 10:47 AM, Dimitri Liakhovitski <ld7631 at gmail.com> wrote: >> I am not sure if this question has been asked before - but is there a >> procedure in R (in lm or glm?) that is equivalent to ENTER and REMOVE >> regression commands in SPSS? >> Thanks a lot! >> >> -- >> Dimitri Liakhovitski >> Ninah.com >> Dimitri.Liakhovitski at ninah.com >> >> ______________________________________________ >> 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. >> > > > > -- > Ista Zahn > Graduate student > University of Rochester > Department of Clinical and Social Psychology > http://yourpsyche.org >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
David Winsemius
2010-Mar-04 16:29 UTC
[R] Analogue to SPSS regression commands ENTER and REMOVE in R?
On Mar 4, 2010, at 10:47 AM, Dimitri Liakhovitski wrote:> I am not sure if this question has been asked before - but is there a > procedure in R (in lm or glm?) that is equivalent to ENTER and REMOVE > regression commands in SPSS? > Thanks a lot!I haven't used SPSS for 25 years (excluding a brief session where I talked an inexperienced SPSS user through creating a multi-way table of mortality ratios a couple of years ago) but my memory is that those operations drop or add terms to a model formula and produced voluminous paper output as a result. Looking at the "lm" function help page, I guessed that I might find more information at the anova.lm help page and sure enough, there at the bottom of the page was "drop1". My vague memory that there was a matching "add1" was rewarded with confirmation when I followed the "drop1" link. I generally just make another call to lm().> > -- > Dimitri Liakhovitski > Ninah.com > Dimitri.Liakhovitski at ninah.com >-- David Winsemius, MD Heritage Laboratories West Hartford, CT