I am conducting a random forest analysis in which a predictor is naturally correlated to the outcome. That is, the predictor is the amount of sunlight a patient received during his admission in a hospital, the outcome is the length of stay in the hospital. The longer the length of stay, the more sunlight the patient received. To determine the average amount of received sunlight for each patient I divided sunlight by the number of daylight hours during their admission.
My goal is to determine the 'shape' of the relationship between sunlight and length of stay (using partial dependence plots), and to compare this relationship between different patientgroups. However I keep ending up with this inverted U shape relationship between sunlight and length of stay (see partial dependence plot below), which I suspect to.
My guess is that this is due to the law of large numbers. Patients with a longer length of stay, the sunlight value is the mean of a larger subsample which tends to move towards the mean of the total sample. Therefore the high and low sunlight cases tend to be patients with a shorter length of stay.
My question is, is there anything I can do to prevent this effect? Any other type of transformation rather than averaging? Any suggestions or considerations are welcome!