[S] (simple?) problem with lm()

Claus Dethlefsen (dethlef@math.auc.dk)
Wed, 4 Mar 1998 08:05:35 -0500


Dear S+ - users

I have a problem with lm() using S-Plus 3.4 on a SUN SPARC station.
I have an ANCOVA analysis with 2 factors (A with 3 levels, B with 2
levels) and a covariate (x). The response is Y

I simply want to fit the model
Y ~ -1 + A:B + x:A:B,
i.e. a straight line for each of the 6 groups.

I tried it using S-Plus 3.4 in which case this failed. However, using
R on a PC worked.

Please, check the included transcripts and any help will be
appreciated greatly.

Regards,

Claus
----------------------------------------------------------------------
S-PLUS : Copyright (c) 1988, 1996 MathSoft, Inc.
S : Copyright AT&T.
Version 3.4 Release 1 for Sun SPARC, SunOS 5.3 : 1996
Working data will be in .Data
> options(contrasts="contr.treatment","contr.poly")
> Y <- rnorm(30)
> A <- as.factor(rep(1:3,c(10,10,10)))
> B <- as.factor(rep(rep(1:2,c(5,5)),3))
> x <- 1:30
> lm( Y ~ -1 + A:B + x:A:B)
Error in model.matrix.default: Invalid dim attribute: lengths do not match: structure(..
Dumped
> cbind(Y,A,B,x)
Y A B x
[1,] 0.0086292430 1 1 1
[2,] -0.0382391091 1 1 2
[3,] -1.0168024543 1 1 3
[4,] -0.1324462528 1 1 4
[5,] -0.3603491998 1 1 5
[6,] -0.0337469778 1 2 6
[7,] -1.8831606111 1 2 7
[8,] 0.3368386818 1 2 8
[9,] -0.0003541437 1 2 9
[10,] 1.2066770747 1 2 10
[11,] -0.0204049459 2 1 11
[12,] -1.0119328923 2 1 12
[13,] 0.9163081264 2 1 13
[14,] -1.3829848791 2 1 14
[15,] -0.4695526978 2 1 15
[16,] -0.8035892599 2 2 16
[17,] 0.9026407992 2 2 17
[18,] -1.1558698525 2 2 18
[19,] 0.1049802819 2 2 19
[20,] 0.2302154933 2 2 20
[21,] 2.3956811151 3 1 21
[22,] 0.0824999817 3 1 22
[23,] -0.0248816697 3 1 23
[24,] 0.7525617816 3 1 24
[25,] -1.1078423455 3 1 25
[26,] -2.2280610717 3 2 26
[27,] 1.2261521170 3 2 27
[28,] 1.5603970547 3 2 28
[29,] -0.5243234682 3 2 29
[30,] 0.4177975871 3 2 30
>
>
> q()

Process S+3 finished at Wed Mar 4 13:47:00 1998

# OUTPUT FROM R (run on a PC)

R : Copyright 1997, Robert Gentleman and Ross Ihaka
Version 50.0 Beta (Sept 1, 1997)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type "license()" for details.

Call:
lm(formula = Y ~ -1 + A:B + x:A:B)

Coefficients:
A1.B1 A2.B1 A3.B1 A1.B2 A2.B2 A3.B2
0.58375295 2.53212630 -13.36049902 1.46785900 -2.85621120 0.81703570
A1.B1.x A2.B1.x A3.B1.x A1.B2.x A2.B2.x A3.B2.x
-0.11634048 -0.20816568 0.56576782 -0.08660883 0.17863653 -0.00280760

-- 
-------------------------------------------------------------------------------
Claus Dethlefsen, mailto:dethlef@math.auc.dk, http://www.math.auc.dk/~dethlef
Dpt. of Mathematics, Aalborg University, Fr. Bajers Vej 7E, 9220 Aalborg East
Denmark
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news