[英]How can I extract data from mcmc RJAGS
I'm running the following model where I got a measurement for each polling week. 我正在运行以下模型,其中每个投票周都有一个度量值。 Which produce more than 100 alpha vectors for each party.
每一方产生100多个alpha向量。 May question is, how could I stockpile them in a way I could draw a line graph?
可能的问题是,我该如何以绘制折线图的方式来存放它们?
model{
## measurement
for(i in 1:NPOLLS){
p1[i] ~ dnorm(alpha1[WoY[i]] + pollster1[org[i]], prec1[i])
p2[i] ~ dnorm(alpha2[WoY[i]] + pollster2[org[i]], prec2[i])
p3[i] ~ dnorm(alpha3[WoY[i]] + pollster3[org[i]], prec3[i])
}
## transition
for(i in 2:NPERIODS){
alpha1[i] ~ dnorm(alpha1[i-1],phi1)
alpha2[i] ~ dnorm(alpha2[i-1],phi2)
alpha3[i] ~ dnorm(alpha3[i-1],phi3)
}
pollster1[1] <- -sum(pollster1[2:NPOLLSTERS])
pollster2[1] <- -sum(pollster2[2:NPOLLSTERS])
pollster3[1] <- -sum(pollster3[2:NPOLLSTERS])
## priors
phi1 ~ dgamma(5000,1)
alpha1[1] ~ dunif(.2,.4)
phi2 ~ dgamma(5000,1)
alpha2[1] ~ dunif(.2,.4)
phi3 ~ dgamma(10000,1)
alpha3[1] ~ dunif(.1,.3)
for(i in 2:NPOLLSTERS){
pollster1[i] ~ dnorm(0,.01);
pollster2[i] ~ dnorm(0,.01);
pollster3[i] ~ dnorm(0,.01);
} }
jags function provid a mmcm.list object with a summary
generic function for this class of object. jags函数为mmcm.list对象提供此类对象的
summary
通用函数。 Use str
and name
functions on your new object return by the jags
function and you need to find something like mcmc
. 在
jags
函数返回的新对象上使用str
和name
函数,您需要找到类似mcmc
东西。 The mcmc
sub-object is a matrix of class mcmc.list
containing the posteriors with n row
the number of iterartion and n col
the estimated parameters. mcmc
子对象是mcmc.list
类的矩阵, mcmc.list
包含mcmc.list
其中n row
表示迭代次数, n col
表示估计参数。 So you can extract what you want. 这样您就可以提取所需的内容。 The length of the
mcmc
object is equal to the number of chains. mcmc
对象的长度等于链数。 They also have a generic plot.mcmmc
funcion to draw the posterior density. 它们还具有通用的
plot.mcmmc
来绘制后密度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.