Does adding a grouping variable to a model help or hamper? Imagine I have a dataset of people where I can find the city and country they live in. The data is such that, given the city, there is only one possible country. For example, given Madrid as a city, the country the person lives at can only be Spain, and if I say London, the person can only live in England.
So one can say that the information of which country the person lives in is already contained in the city variable.
Given this situation, is it any better to fit a generalized linear model using both country and city variables instead of only city? Does this change if the model is non-linear? Does it depend on the specific kind of model I use (regression, SVM, trees...)?
 A: If your number of cities is really large you should read Principled way of collapsing categorical variables with many levels?  (and posts linked there!).  Apart from that, you have what we can call a hierarchical variable, and how you code it depends on what interpretations you want.  If you are interested in country effects, you can make a Country variable, and then a City variable. This variables of course cannot be crossed, since they have a hierarchical structure. So in effect you are modeling first a country effect, and then a city effect as a deviation from that city's country.  Or you can do with only a City variable, in which case you model the city effect directly.  These two ways of modeling will give the same fitted values, the only difference lies in parameter interpretation.  These comments do not really depend on which class of model you are fitting, at least within a class of regression-like models.
Alternatively, you could also use a random (or mixed) effects model. It depends on the question you are asking from the data, see Should "City" be a fixed or a random effect variable?.
