Thank you all for the advice.
So, to confirm: If I have
data.0 <- data.frame(y, x1, x2) levels(data.0$x1) <- c('one', 'two', 'three') ### three levels
fm1 <- glm(cbind(y, 20 - y) ~ x1 * x2, family = binomial, data = data.0)
then, what I need to do is merge the last two factors to one:
data.0 <- data.1 levels(data.1$x1) <- c('one', 'two', 'two') ### two levels for factor
fm2 <- glm(cbind(y, 20 - y) ~ x1 * x2, family = binomial, data = data.1) anova(fm2, fm1, test = 'Chisq')
Although I understand it achieves the same result, I am not sure what numbers to plug into the contrast. The constrat, as it currently stands, is
contrasts(data.0$x1) <- matrix(c(0, 0, 1, 0, 0, 1), ncol = 2, byrow = T)
Andrew
Prof Brian Ripley wrote:
On Fri, 5 Mar 2004, Andrew Criswell wrote:
I have a binomial model with one covariate, x1, treated as a factor with 3 levels. The other covariate is measured x2 <- 1:30. The response, y, is the proportion of successes out of 20 trials.
glm(cbind(y, 20 - y) ~ x1 * x2, family = binomial)
Now, I would like to constrain the cofficients on 2 levels of the factor, x1, to be identical and test the difference between these models by a likelihood ratio test.
How can I get glm() to constrain the coefficients on 2 levels to be the same?
Merge the levels of the factor: see ?levels.
You could also set up a custom contrasts matrix: either way the natural S approach is to reparametrize rather than constrain.
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html