Dear R users,
I want to run nested fixed-factor Anova in R on different experiments.
In this toy example I have 3 levels of the main factor x1 and 7 levels
of the nested factor z1
x1 and continuous response variable y1.
x1
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2
2 2 2 2
[38] 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3 3 3 3
[75] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
z1
[1] 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3
3 3 3 3
[38] 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
5 5 5 5
[75] 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7.
When I run lm on using nested design anov1=lm(c(as.vector(y1))
~as.factor(x1)+ as.factor(x1)/as.factor(z1)) I get a warning
summary(anov1)
Coefficients: (14 not defined because of singularities). I get
interaction between factors that should not be included because of the
nested design.
Why R includes them? This is becomes a problem when you apply similar
concept to large datasets having, i.e. 100 and 500 main and nested
factor levels - the computations become prohibitively slow?
Many thanks for your help in advance!
Coefficients: (14 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.1759 0.3226 -0.545 0.5869
as.factor(x1)2 -0.1276 0.4473 -0.285 0.7762
as.factor(x1)3 0.6461 0.4785 1.350 0.1802
as.factor(x1)1:as.factor(z1)2 0.1049 0.4473 0.234 0.8151
as.factor(x1)2:as.factor(z1)2 NA NA NA NA
as.factor(x1)3:as.factor(z1)2 NA NA NA NA
as.factor(x1)1:as.factor(z1)3 NA NA NA NA
as.factor(x1)2:as.factor(z1)3 1.1520 0.4473 2.575 0.0116 *
as.factor(x1)3:as.factor(z1)3 NA NA NA NA
as.factor(x1)1:as.factor(z1)4 NA NA NA NA
as.factor(x1)2:as.factor(z1)4 NA NA NA NA
as.factor(x1)3:as.factor(z1)4 NA NA NA NA
as.factor(x1)1:as.factor(z1)5 NA NA NA NA
as.factor(x1)2:as.factor(z1)5 NA NA NA NA
as.factor(x1)3:as.factor(z1)5 -0.6841 0.4181 -1.636 0.1052
as.factor(x1)1:as.factor(z1)6 NA NA NA NA
as.factor(x1)2:as.factor(z1)6 NA NA NA NA
as.factor(x1)3:as.factor(z1)6 -0.6713 0.4562 -1.472 0.1445
as.factor(x1)1:as.factor(z1)7 NA NA NA NA
as.factor(x1)2:as.factor(z1)7 NA NA NA NA
as.factor(x1)3:as.factor(z1)7 NA NA NA NA
----------------------------------------------
Sergii Ivakhno
PhD student
Computational Biology Group
Cancer Research UK Cambridge Research Institute
Li Ka Shing Centre
Robinson Way
Cambridge CB2 0RE
England
+44 (0)1223 404293 (O)
+44 (0)1223 404128 (F)
http://www.compbio.group.cam.ac.uk <http://www.compbio.group.cam.ac.uk/>
/
This communication is from Cancer Research UK. Our website is at
www.cancerresearchuk.org. We are a charity registered under number 1089464 and a
company limited by guarantee registered in England & Wales under number
4325234. Our registered address is 61 Lincoln's Inn Fields, London WC2A 3PX.
Our central telephone number is 020 7242 0200.
This communication and any attachments contain information which is confidential
and may also be privileged. It is for the exclusive use of the intended
recipient(s). If you are not the intended recipient(s) please note that any
form of disclosure, distribution, copying or use of this communication or the
information in it or in any attachments is strictly prohibited and may be
unlawful. If you have received this communication in error, please notify the
sender and delete the email and destroy any copies of it.
E-mail communications cannot be guaranteed to be secure or error free, as
information could be intercepted, corrupted, amended, lost, destroyed, arrive
late or incomplete, or contain viruses. We do not accept liability for any such
matters or their consequences. Anyone who communicates with us by e-mail is
taken to accept the risks in doing so.
[[alternative HTML version deleted]]