0

To compare two models using anova in R, I can simply use anova(model1,model2) and conclude whether they are significantly different or not based on the p-value returned. However, currently I have data such that:

Cities     Localities     x1     x2     y1
City1           .          .      .      .
City1           .          .      .      .
City2           .          .      .      .
City2           .          .      .      .
City2           .          .      .      .
City3           .          .      .      .
City4           .          .      .      .
City4           .          .      .      .
City4           .          .      .      .

and so on. I want to show that there is variability between cities as groups without comparing the models for each subgroup pairwise. What can I do?

Will anova(models) where models=c(model1,model2,...) vector of fitted models corresponding to each city work? Or should I perform anova on the full dataset. In that case, how do I define the subdivisions?

Quinten
  • 35,235
  • 5
  • 20
  • 53
zaira
  • 153
  • 1
  • 7
  • 1
    Fit two models, identical except that one includes `Cities` as a factor. Then `anove` gives you what you want. – Limey Oct 09 '22 at 06:40
  • @Limey Oh! so `model1: y1~x1+x2` and `model2: y1~x1+x2+Cities`? – zaira Oct 09 '22 at 06:47
  • 1
    Yes. As you indicate yourself in your question. Note that this is valid if and only if `model1` is contained in `model2`. – Limey Oct 09 '22 at 07:50
  • @Limey it is. although, `Cities` does not have numeric entries and the model i'm using quantile regression to fit the models. – zaira Oct 09 '22 at 09:08

0 Answers0