I have a Bayesian statistics homework question that I'm not sure of:
Running this in R, I got completely flat lines at 0 and 1 so I was thinking this meant that the success probability does not change with this particular prior. Can anyone shed some more light on this problem?
mu0 = 0
sig2_0 = 100
n = 10000
b0 = rnorm(n, mean=mu0, sd=sqrt(sig2_0))
x = seq(from=0, to=10, length.out=100)
res = matrix(0, length(x), 3)
for(i in 1:length(x)){
z = b0
z1 = exp(z) / (1+exp(z))
res[i,] = quantile(z1, c(0.025, 0.5, 0.975))
}
plot( x, res[,2], type='l', ylim=range(res), ylab='Success probability', xlab='Covariate')
lines(x, res[,1], lty=3)
lines(x, res[,3], lty=3)
n=10000 b0=rnorm(n,mean=mu0,sd=sqrt(sig2_0))
x=seq(from=0,to=10,length.out=100) res=matrix(0,length(x),3) for (i in 1:length(x)){ z=b0 z1=exp(z)/(1+exp(z)) res[i,]=quantile(z1,c(0.025,0.5,0.975)) }
plot(x,res[,2],type='l',ylim=range(res),ylab='Success probability',xlab='Covariate') lines(x,res[,1],lty=3) lines(x,res[,3],lty=3)`
– Feb 17 '14 at 04:34_____in R?', or 'what's wrong w/ my r code?' belong on Stack Overflow, not here. Note further that our approach to HW questions is to provide hints only (see the[self-study]tag's wiki). Since I think there is a legitimate statistical question here, I provided hints below. There are also some issues w/ your code, however. 1st, your code doesn't include any covariates. 2nd you generate your pseudorandom data in line 4; each pass through the loop uses the same data. – gung - Reinstate Monica Feb 17 '14 at 05:09