"Gorjanc Gregor" <[EMAIL PROTECTED]> writes: > Hello! > > I would like to use constrain to sum coeficients of a factor to 0 instead > of classical corner contraint i.e. I would like to fit a model like > > lm(y ~ 1 + effectA + effectB) > > and say get parameters > > intercept > effectA_1 > effectA_2 > effectB_1 > effectB_2 > effectB_3 > > where effectA_1 represents deviation of level A_1 from intercept and > sum(effectA_1, effectA_2) = 0 and the same for factor B. > > Is this possible to do?
This is what contr.sum does. There are multiple ways to set this instead of the default contr.treatment: (a) options(contrast=....) (b) contrasts(effectA) <- contr.sum (c) lm(y~C(effectA,contr.sum)+.....) Notice though that you only get parameters for a linearly independent subset of groups (i.e. the first n-1 of them). The last one is defined as -sum(the other levels). -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ R-help@stat.math.ethz.ch 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.