Description Usage Arguments Value Author(s) Examples
Internal function to -2LL
1 2 3 | Gibbs_4PNO(Y, mu_xi, Sigma_xi_inv, mu_theta, Sigma_theta_inv, alpha_c,
beta_c, alpha_s, beta_s, burnin, cTF, sTF, gwg_reps,
chain_length = 10000L)
|
Y |
A N by J |
mu_xi |
A two dimensional |
Sigma_xi_inv |
A two dimensional identity |
mu_theta |
The prior mean for theta. |
Sigma_theta_inv |
The prior inverse variance for theta. |
alpha_c |
The lower asymptote prior 'a' parameter. |
beta_c |
The lower asymptote prior 'b' parameter. |
alpha_s |
The upper asymptote prior 'a' parameter. |
beta_s |
The upper asymptote prior 'b' parameter. |
burnin |
The number of MCMC samples to discard. |
cTF |
A J dimensional |
sTF |
A J dimensional |
gwg_reps |
The number of Gibbs within Gibbs MCMC samples for marginal distribution of gamma. Values between 5 to 10 are adequate. |
chain_length |
The number of MCMC samples. |
Samples from posterior.
Steven Andrew Culpepper
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # Simulate small 4PNO dataset to demonstrate function
J = 5
N = 100
# Population item parameters
as_t = rnorm(J,mean=2,sd=.5)
bs_t = rnorm(J,mean=0,sd=.5)
# Sampling gs and ss with truncation
gs_t = rbeta(J,1,8)
ps_g = pbeta(1-gs_t,1,8)
ss_t = qbeta(runif(J)*ps_g,1,8)
theta_t <- rnorm(N)
Y_t = Y_4pno_simulate(N,J,as=as_t,bs=bs_t,gs=gs_t,ss=ss_t,theta=theta_t)
# Setting prior parameters
mu_theta=0
Sigma_theta_inv=1
mu_xi = c(0,0)
alpha_c=alpha_s=beta_c=beta_s=1
Sigma_xi_inv = solve(2*matrix(c(1,0,0,1),2,2))
burnin = 1000
# Execute Gibbs sampler
out_t = Gibbs_4PNO(Y_t,mu_xi,Sigma_xi_inv,mu_theta,
Sigma_theta_inv,alpha_c,beta_c,alpha_s,
beta_s,burnin,rep(1,J),rep(1,J),
gwg_reps=5,chain_length=burnin*2)
# Summarizing posterior distribution
OUT = cbind(apply(out_t$AS[,-c(1:burnin)],1,mean),
apply(out_t$BS[,-c(1:burnin)],1,mean),
apply(out_t$GS[,-c(1:burnin)],1,mean),
apply(out_t$SS[,-c(1:burnin)],1,mean),
apply(out_t$AS[,-c(1:burnin)],1,sd),
apply(out_t$BS[,-c(1:burnin)],1,sd),
apply(out_t$GS[,-c(1:burnin)],1,sd),
apply(out_t$SS[,-c(1:burnin)],1,sd) )
OUT = cbind(1:J,OUT)
colnames(OUT) = c('Item', 'as', 'bs', 'gs', 'ss', 'as_sd', 'bs_sd',
'gs_sd', 'ss_sd')
print(OUT, digits = 3)
|
Item as bs gs ss as_sd bs_sd gs_sd ss_sd
[1,] 1 2.82 1.055 0.0563 0.0808 0.654 0.431 0.0345 0.0697
[2,] 2 2.81 0.647 0.1141 0.0566 0.603 0.489 0.0582 0.0472
[3,] 3 2.80 -0.340 0.2325 0.0598 0.990 0.738 0.1443 0.0400
[4,] 4 2.19 0.682 0.2171 0.1477 0.715 0.522 0.0814 0.0873
[5,] 5 2.95 0.124 0.0489 0.0372 0.731 0.334 0.0427 0.0318
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.