[R] Analogue to SPSS regression commands ENTER and REMOVE in R?

Ista Zahn istazahn at gmail.com
Thu Mar 4 17:15:24 CET 2010


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



More information about the R-help mailing list