# The law of large numbers mediates predictor-outcome relation, what to do?

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!

• Does that mean that all the people who stayed for 40 days were in sunless conditions the whole time? That does not seem very plausible. – mdewey Nov 21 '17 at 16:40
• The length of stay (LOS) is acquired by determining the predicted LOS value per case for all cases with 0 sunlight hours by dropping these cases down the random forrest. Subsequently these predicted LOS values are averaged per unique sunlight value to determine the mean prediction for, e.g., all '0 sunlight cases'. The LOS is measured in hours btw, so the 40 hours is an average of all patients the were in sunless condition the whole time. – FtD Nov 21 '17 at 18:16