File: bayesresiduals.R

package info (click to toggle)
r-cran-learnbayes 2.15-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,064 kB
  • sloc: sh: 16; makefile: 1
file content (14 lines) | stat: -rw-r--r-- 269 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)
}