Combining two secondary datasets, we are interested in finding out the effect of political outcome variables (e.g. mayor's party and percentage of vote) at a low administrative level (e.g. township) on the quality of supply of public goods (e.g. hours of electricity, etc.) at a higher level (e.g. county) in a developing country. There are also control variables such as income at the higher level, and "distance to state capital" or "area to be serviced" at the lower level.

The linear model (written in R code) would be something like:

lm(hours_electricity ~  as.factor(party_t) + majority_t + income_c  + area_t, ...)

with _t denoting township (n = 3141) and _c denoting county (n = 434) arranged in a tidy dataset. The response variable does have a somewhat odd distribution:

  Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   0.00   18.00   24.00   20.73   24.00   24.00 

Regardless of common transformations, it yields, as I feared, horrible-looking residuals plots, which don't help me in finding a solution.

enter image description here

This paper describes a similar problem in psychology research with group-level responses relying on individual-level predictors. However, in our study, there is no latent variable complementing the individual-level variables (i.e. we know the exact scores for all townships as opposed to a sample of them). I understand they suggest a Structural Equation Model would work if scores are known for individuals but they elaborate on their more complex problem with latent variables.

Is a Structural Equation Model what is required here? How should I go about applying that?

Otherwise, what is causing the problems with the residuals and how could it be solved?

Apologies if I'm missing something obvious, I'm out of my depth here. Accordingly, also sorry if I haven't provided enough information to answer properly. Happy to clarify, I'm just mindful of post length! Thank you very much for any pointers!

  • $\begingroup$ What is supply_qual_t and what are it's possible values? Do you have repeated measurements? $\endgroup$ Commented Jan 16, 2019 at 9:02
  • $\begingroup$ Thanks so much for taking the time! I've added the distribution of the response variable that yields the residuals below and renamed it to reflect its actual nature: hours of electricity access per day. On "repeated measurements", that's the crux of my question really. Because hours of electricity are only measured at the county level, the same value is repeated for all townships within each county. I understand "repeated measurements" are often done by design and over time, but I'm not sure if this merger of datasets is creating similar problems with similar solutions? $\endgroup$
    – Fons MA
    Commented Jan 16, 2019 at 10:38
  • $\begingroup$ The residuals are indicative of a fundamental problem in your data, it would appear that one of your independent variables remains constant while your dependent variable changes. A GLM might help here. $\endgroup$ Commented Jan 17, 2019 at 8:44

1 Answer 1


First. I am not sure why you don't need a multilevel model.

However, to your question: It looks like hours of electricity is a count variable with a limited number of levels. You should be using a count regression method such as Poisson or negative binomial regression, not linear regression. But the distribution of hours also is odd, with the median being the same as the maximum. No sensible transformation will help this.

You might want to consider what it is about hours of electricity that interests you. If this is data from some developed country, then a long failure of electricity will be very rare and probably not related to economics but to weather. If it is data from some place where electric outages are, indeed, common, then you might want to consider transforming the data by reversing it (hours missed per day) and then using a zero inflated count model or a hurdle model.

  • $\begingroup$ Thank you very much, Peter! The data is indeed from a developing country and refers to general availability all year-round rather than occasional outages. However, I think your suggestions for transformation and the Poisson regression both sound excellent (I'm afraid I don't know much about negative binomial). Using a multilevel analysis would certainly improve the analysis, it's just not clear to me how to treat our lower level data, given that it's not a sample but the full population (of elected representatives and their various scores). I'd very much appreciate any further insights! $\endgroup$
    – Fons MA
    Commented Jan 16, 2019 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.