0
$\begingroup$

I fitted some models using MCMC using different link functions like $$\text{Logit}:\qquad \hat{y_i}=\frac{e^{x_i^T\hat{\beta}}}{1+e^{x_i^T\hat{\beta}}}$$

$$\text{Probit}: \qquad \hat{y_i}=\Phi(x_i^T\hat{\beta})$$ $$\text{Cloglog}:\qquad \hat{y_i}=1-\exp(-\exp(x_i^T\hat{\beta}))$$

How I can get confidence intervals for each prediction? I want to do a plot with observed $y_i$ and fitted values $\hat{y_i}$ with confidence intervals for each fitted value.

How I planning to do:

In this case $y_i$ is a proportion then $y$-axis would be $0-1$ and in $x$-axis I will have the number of each observation and their correspondents $y_i$, $\hat{y_i}$, interval for $\hat{y_i}$

How I can calculate these intervals to do the plot?

EDIT: In this case each $\hat{y_i}$ is a proportion $\hat{p_i}$, I could't do $$\hat{p_i}\pm z\Big(\sqrt{\frac{\hat{p_i}(1-\hat{p_i})}{n}}\Big)$$ ?

EDIT: What I want to do is something like this enter image description here

$\endgroup$
0
$\begingroup$

MCMC provides You with samples $\beta_k$. First compute $y_{ik}$ for each sample of $\beta_k$ and find the scores at percentile $\alpha/2$ and $1-\alpha/2$ for the vector of samples $y_i$. The two scores provide the interval bounds. For instance in Python, the latter step can be easily done with the functionscipy.stats.scoreatpercentile

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy