R/bayesresiduals.R

bayesresiduals=function(lmfit,post,k)
{
ehat=lmfit$residuals
h=hat(model.matrix(lmfit))

prob=0*ehat
for (i in 1:length(prob))
{
z1=(k-ehat[i]/post$sigma)/sqrt(h[i])
z2=(-k-ehat[i]/post$sigma)/sqrt(h[i])
prob[i]=mean(1-pnorm(z1)+pnorm(z2))
}
return(prob)
}

Try the LearnBayes package in your browser

Any scripts or data that you put into this service are public.

LearnBayes documentation built on May 1, 2019, 7:03 p.m.