tailieunhanh - Computational Statistics Handbook with MATLAB phần 9
. Chúng tôi lần đầu tiên hình thành các tỷ lệ khả năng cho mỗi quan sát mục tiêu bằng cách sử dụng qua xác nhận, năng suất một phân phối của các tỷ lệ khả năng cho các lớp mục tiêu. Đối với mỗi ngưỡng nhất định, chúng ta có thể xác định số lượng các quan sát mục tiêu rằng | We will generate 500 iterations of the chain. n 5000 numchain 4 Set up the vectors to store the samples. This is 4 chains 5000 samples. X zeros numchain n This is 4 sequences rows of summaries. nu zeros numchain n Track the rhat for each iteration rhat zeros 1 n Get the starting values for the chain. Use over-dispersed starting points. X 1 1 -10 X 2 1 10 X 3 1 -5 X 4 1 5 The following implements the chains. Note that each column of our matrices X and nu is one iteration of the chains and each row contains one of the chains. The X matrix keeps the chains and the matrix nu is the sequence of scalar summaries for each chain. Run the chain. for j 2 n for i 1 numchain Generate variate from proposal distribution. y randn 1 sig X i j-1 Generate variate from uniform. u rand 1 Calculate alpha. alpha normpdf y 0 1 normpdf X i j-1 0 1 if u alpha Then set the chain to the y. X i j y else X i j X i j-1 end end Get the scalar summary - means of each row. nu j mean X 1 j rhat j csgelrub nu 1 j end The function csgelrub will return the estimated R for a given set of sequences of scalar summaries. We plot the four sequences for the summary statistics of the chains in Figure . From these plots we see that it might be reasonable to assume that the sequences have converged since they are 2002 by Chapman Hall CRC getting close to the same value in each plot. In Figure we show a plot of R for each iteration of the sequence. This seems to confirm that the chains are getting close to convergence. Our final value of R at the last iteration of the chain is . One of the advantages of the Gelman-Rubin method is that the sequential output of the chains does not have to be examined by the analyst. This can be difficult especially when there are a lot of summary quantities that must be monitored. The Gelman-Rubin method is based on means and variances so it is especially useful for statistics that approximately follow the normal distribution. Gelman et al. 1995 recommend that in
đang nạp các trang xem trước