-1
這可能是一個荒謬的問題,但我對R(3周前開始)非常陌生,但我運行的是Gibbs採樣器,並且我從非共軛分佈中繪製。它被設置爲Yi | mu〜N(1,4^2),mu〜N(0,1)和sig^2〜IG(2,1)。我有采樣部分編碼,但我無法編碼後驗分佈以創建要採樣的數據。我至今是:在R中編碼後驗分佈
dev.new() #####Posterior predictive density (ppd[1:lx])for data on the grid x (new line)
#
lx = 200 (new line)
x = seq(min(yy) - .1*(max(yy) - min(yy)),
max(yy) + .1*(max(yy) - min(yy)), len = lx)
dev.new()
hist(yy, prob=T)
ppd = rep(0, lx)
for(ii in 1:lx)
{
##### enter the code here,
### ppd[ ii ] = mean(dnorm(.....
}
lines(x, ppd, col=2, lwd=2)