mjskay / tidybayes

Bayesian analysis + tidy data + geoms (R package)
http://mjskay.github.io/tidybayes
GNU General Public License v3.0
710 stars 59 forks source link

Vignette: Extracting and visualizing tidy residuals from Bayesian models - improper link function? #283

Closed Famondir closed 3 years ago

Famondir commented 3 years ago

New title: Is assuming a Student t distribution for residuals valid?

New question/issue: Do you use the qnorm() to get from .p_residuals to .z_residuals because you assume the residuals to be normally distributed (without outlieres)? And with the plot we then check for normality with stats::qnorm as well?

Could we - if we assume the data has some outliers - model the residuals with a Student t distribution than instead and use this to transform th .p_residuals in .z_residuals and in the geom_qq distribution argument? (We could estimate df with a model: .p_residuals ~ 1 with brms and the student familiy.) Or does the cumulative model account for these anormal distribution in the first place and using a Student t on residuals would be unproper?

What is about the leave one out strategy you mentiond? Can you link me a paper for that?

After some simulations and tests I think I can drop my former issue which was:

Working through some papers on surrogate residuals (starting from your supreme vignette) for cumulative models I wondered if your "use at own risk" function and your example for the ordinal model have a minor mistake. So minor that you'ld probably won't see the change in the plots. But I am a little bit unsure if I got Liu and Zhangs papers statements right.

You are using the cumulative function without specifying the link. Since it is the logit-link. But then you use the qnorm() function to get the z_residuals. Wouldn't it be correct to use the brms::logit_scaled() function instead? (Yeah I know, probit and logit are super close related. But it seems that your function could be genralized to way more link functions this way and we can do some nice model checks.)

Reason: You are using the jitter approch (type B (?)) and therefore it is already usable on a wide range of functions without need to know the specific link function. Also I now realised that the qnorm probably is used because normal error distribution is assumed.

mjskay commented 3 years ago

The qnorm function is used to translate the residuals into z scores for folks more used to seeing quantile-quantile plots instead of probability-probability plots. You are right that the response distribution is not normal, but for the purposes of that transformation it does not matter. Perhaps staying on the probability scale would be clearer, though I think sometimes the visual patterns one is looking for are a bit easier to see in terms of z scores than probabilities.

Re: leave-one-out stuff, see the loo package (https://mc-stan.org/loo/) and citations therein