# Why is the trend of using percentiles to divide the Logit model different from the trend of using percentiles as the knots’ restricted cubic spline?

I am trying to analyze the effect of air pollutant on health. First, I used the restricted cubic spline with three knots which were 25th, 50th, 75th percentiles of the pollutant and the result was Figure1: it looks a linear relationship. And then, I divided the data set into four parts by the 25th, 50th, 75th percentiles of the pollutant, and conducted logsitic regression for each part, the result was Figure2.

I am confused that why the trend in Figure2 is not a ascending line? Because in my opinion, it should be the same as Figure1.

And the restricted cubic spline model is :

k <- with(Data, quantile(Pollutant, c(.25, .50,.75)))

model_rcs <- lrm(disease~rcs(Pollutant,k)+temperature+humidity+age+gender+job,data=Data)

the logistic model is:

model_log <-glm(disease~Pollutant+temperature+humidity+as.factor(age)+as.factor(gender)+as.factor(job),family = binomial() ,data=Data_Q1) (or Data_Q2\Data_Q3\Data_Q4)

• Presumably you have many other predictors too. The scope for those other predictors complicating or confusing results is enormous. If I understand this correctly, your second graph is a compilation of results from quite different model fits that don't know about each other. But in essence, it is hard to comment helpfully without more details. The limiting form "Why are my results puzzling?" is a question we all have from time to time but it's hard to answer. – Nick Cox Nov 5 '20 at 12:01
• Thanks for your answer. Yes, your understand is right, in my model there are other covariates excluding the pollutant variables. And I added a detailed model to the problem. Then I think you mean these covariates made a difference. But I used the same covariates in two models, and they may have a consistent effect.I still don't understand. – KK HH Nov 5 '20 at 12:32
• Sure, it's the same covariates but what you estimate as the effects of pollution depends on those covariates too, and your models are not the same. Imagine a simpler case: relating people's weights to height, first overall and then in quantile bins of their height -- in a case where e.g. adults and children are mixed so height is confounded with age. You'll see different results with quite different models on the dataset and on subsets. – Nick Cox Nov 5 '20 at 13:08
• Thank you for the clear example. I seem to understand. In your example, age is the key variable for height and weight, then if I find the crucial variable for pollutant, though the whole is divided, maybe the result will be better than now, is that so? – KK HH Nov 5 '20 at 15:57
• And I read some researches that devided air pollutants into Levels by their percentiles, and the concentration gradually rise as from the Level1 to Level4, then reserchers will conduct logistic regression for every dataset respectively, and result shows the higher Level, the greater OR. In my figure2, the result shows lower pollutant concentration has higher OR(Q1~Q2), this can not be explained, but in my figuer1, it can be explained.So I asked this question – KK HH Nov 5 '20 at 15:58

The second graph is misleading because it assumes a discontinuous relationship when the true relationship is continuous. Possibly even more problematic: you are constructing intervals from quartiles. Quartiles tell us about the distribution of X and are completely disconnected from the shape of the relationship between X and Y. How many points are near a given X=x should not inform us of how X relates to Y at x.

The knots in splines should not be confused with points of discontinuity in the estimated values of Y. In a cubic spline function, the knots are points of discontinuity in the third derivative ("jolt") of the function. The human eye cannot see discontinuities in the third derivative. It can only see discontinuities in the function and in its first derivative (slope). Details about this along with an graph illustrating the derivatives may be found in my RMS course notes.

• Thanks for your answer. I will study this note. – KK HH Nov 5 '20 at 16:01
• 1. Are many / most splines currently used cubic splines for the above smoothness property? 2. Do you have any guidance for choosing how many knots to use (three above)? – Single Malt Nov 13 '20 at 14:31
• hbiostat.org/rms see course notes – Frank Harrell Nov 13 '20 at 20:48

A few things to note. Most obvious, but probably least important, you model age as a continuous linear predictor in the first model but as a factor in the second model.

Second, note that your second model is actually a set of 4 separate models done on 4 different subsets the data. The effects of temperature, humidity, age, gender, and job are modeled separately within each subset, rather than all together as they are in the first model. That could certainly lead to this type of result. (That's pretty much what Nick Cox is saying in a comment that appeared as I was writing this.)

Third, the results from the separation into 4 models will differ depending on the distributions of the Pollutant values within each of the quartiles. For example, if for one or more quartiles they are bunched near one of the edges of the quartile cutoffs, comparing the results against the continuous fit could be quite misleading. (That's related to what Frank Harrell says in the first paragraph of his answer.)