I have created two generalised linear models as follows:
glm1 <-glm(Y ~ X1 + X2 + X3, family=binomial(link=logit))
glm2 <-glm(Y ~ X1 + X2, family=binomial(link=logit))
I then use the anova
function:
anova(glm2,glm1)
but get an error message:
"Error in anova.glmlist(c(list(object),dotargs), dispersion = dispersion, :
models were not all fitted to the same size of dataset"
What does this mean and how can I fix this? I have attach
ed the dataset at the start of my code so both models are working off of the same dataset.
attach()
. – Townshipglm(Y~X1...)
and not just(Y~X1...)
? And why do you have commas separating the variables? – Townshipattach
could definitely cause that problem. – Townshipdata=YourData
in theglm
, and you can't use commas to separate variables like that. – Townshipanova(glm1,glm2,test="Chisq")
is what you want – Jamboree