Dear list, I have the following anova that I want to fit in R:
y_{ijk} = \mu + \alpha_i + \beta_{j(i)} + \epsilon_{ijk} This is an application in biology, in which we are measuring a certain (continuous) characteristic of a group of cells. Hence y_{ijk} corresponds to the measurement on cell k of type i in batch j. Batch is nested in type, meaning that we have multiple batches for each cell type and each batch contains only cells of a given type. To complicate things, the design is unbalanced. I can "manually" fit the model, with the following constraints: \sum_{i=1}^m \alpha_i = 0 and \sum_{j=1}^{n_i} \beta_{j(i)} = 0. This gives me m + 1 constraints, where m is the number of types. A minimal (toy) example in R is: a <- as.factor(c(rep(1, 4), rep(2, 6))) b <- as.factor(rep(1:5, each=2)) y <- rnorm(10) fit <- lm(y ~ a + b) This call to lm will fit the wrong model, using two constraints (with the "contr.sum" specification), \sum_{i=1}^m \alpha_i = 0 and \sum_{j=1}^{n} \beta_{j} = 0, and resulting in a singular design matrix. Is there a way to specify the right constraints in lm? Thanks in advance for any help, davide -- Davide Risso, PhD Post Doctoral Scholar Division of Biostatistics School of Public Health University of California, Berkeley 344 Li Ka Shing Center, #3370 Berkeley, CA 94720-3370 E-mail: davide.ri...@berkeley.edu [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.