# [R] Problems with lm()

Christoph Scherber Christoph.Scherber at agr.uni-goettingen.de
Thu Jun 19 10:47:26 CEST 2008

```Dear Hsin-Ya Lee,

The problem seems to be that every subject always only received one sequence:

sequence
subject 1 2
1  0 2
2  2 0
3  0 2
4  2 0
5  0 2
6  2 0
7  0 2
8  2 0
9  0 2
10 2 0
11 0 2
12 2 0
13 0 2
14 2 0

You should try to use a design where each subject receives each of the two sequences. Otherwise
obviously the interactions will be not available.

Best wishes
Christoph

leeznar schrieb:
> Dear R-users:
>
> I am a new R-user and I have a question about lm
> function.  Here is my data.
> a<-c(1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14)
> b<-c(1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2)
> c<-c(2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2)
> d<-c(2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1)
> e<-c(1739,1633,1481,1837,1780,2073,1374,1629,1555,1385,1756,1522,1566,1643,1939,1615,1475,1759,1388,1483,1127,1682,1542,1247,1235,1605,1598,1718
> )
> Data<-data.frame(subject=as.factor(a),
> drug=as.factor(b), period=as.factor(c),
> sequence=as.factor(d), Max=e)
>
> lm3<- lm(Max ~subject*sequence + sequence + period +
> drug, data=Data)
> print(lm3)
> anova(lm3)
>
> When I use lm to fit the data, there are some problems
> in "subject*sequence".   I have use GLM in SPSS to
> fit the same data, and it seems there is no problem.
>
> I don't know where my problem is.  How can I get the
> same result with SPSS? How can I do?
>
> Best regards,
> Hsin-Ya Lee
>
>
>
>
>       ______________________________________________________________________________________________________
> [[elided Yahoo spam]]
> Content-Type: application/msword; name="Result_SPSS.doc"
> Content-Transfer-Encoding: base64
> Content-Description: 3367377201-Result_SPSS.doc
> Content-Disposition: attachment; filename="Result_SPSS.doc"
>
> AAAAAAAAAAAA
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help