# Setting contrasts for 10-level categorical variable

I have survey data on income and support for environmental protection. Income is a continuous variable that I have broken up into deciles. I have a hypothesis that support for protection ('Agree') will be concentrated not in the very top of the income spectrum, but in the second and third decile. So my question is how should I set the contrasts. In my mind I should compare the value of each decile to the average of all the (other?) deciles? Comparing each decile to the lowest, highest or middle won't capture what I am looking for. Helmert contrasts will get close, I think, but it would compare the first decile to the average of all below it, including the second and third, and I don't think I want that.

This is partially a question about modelling strategy and partially a question about how to implement contrasts in R. A plot of my real data is shown below the code to generate the sample data.

var1<-sample(c('A', 'B'), replace=T, size=10000)
var2<-as.factor(sample(seq(1,10,1), replace=T, size=10000))
df<-data.frame(var1=var1, var2=var2)


• What is your hypothesis? The support is higher for the average between 2nd and 3rd decile than for the average of the remaining deciles? – Sven Hohenstein Sep 12 '17 at 7:58
• That is basically it, yes. – spindoctor Sep 12 '17 at 14:51

library(splines)

maybe replacing binomial with quasibinomial or some other family function.
There are alternatives like gam's (generalized additive models). A plot of estimated probability of Agree against Income (or of the estimated spline function) would be instructive. I am less sure about formal inference.