[過去ログ] 臨床統計もおもしろいですよ、その1 [無断転載禁止]©2ch.net (747レス)
1-

このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
237: 2017/11/11(土)16:51 ID:AQmX3Wf1(3/8) AAS
#-----------------------------------------------------------------------------
# RUN THE CHAINS
parameters = c( "theta") # The parameters to be monitored
adaptSteps = 500 # Number of steps to adapt the samplers
burnInSteps = 500 # Number of steps to burn-in the chains
nChains = 4 # nChains should be 2 or more for diagnostics
thinSteps = 1
nIter = ceiling( ( numSavedSteps * thinSteps ) / nChains )
# Create, initialize, and adapt the model:
jagsModel = jags.model( "TEMPmodel.txt" , data=dataList , inits=initsList ,
省15
238: 2017/11/11(土)19:06 ID:AQmX3Wf1(4/8) AAS
library("rstan")
library("rstudioapi")
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())

G1314model='
data{// Golgo13.14.stan
int N13; // 100
int N14; //10
int<lower=0,upper=1> G13[N13];
int<lower=1,upper=2> G14[N14];
省16
239: 2017/11/11(土)19:15 ID:AQmX3Wf1(5/8) AAS
N13=100
N14=10
G13=rep(1,N13)
G14=rep(1,N14)
data=list(N13=N13,N14=N14,G13=G13,G14=G14)
G1314.model=stan_model('G1314.stan')
saveRDS(G1314.model,file='G1314.model.rds')
# G1314.model=readRDS('G1314.model.rds')
fitG1314 <- sampling(G1314.model, data=data, seed=1234)
fitG1314
省10
240: 2017/11/11(土)19:25 ID:AQmX3Wf1(6/8) AAS
画像リンク[png]:i.imgur.com
241: 2017/11/11(土)20:30 ID:AQmX3Wf1(7/8) AAS
Golgo13 vs Golgo14
Let's MCMC with JAGS.
I set the ROPE ( Range of Practical Equivalence ) as -0.01 to 0.01

> smryMCMC( mcmcCoda2 , compVal=NULL ,ropeDiff = c(-0.01,0.01))
Mean Median Mode HDIlow HDIhigh CompVal PcntGtCompVal
Diff 0.07384483 0.05247579 0.01267166 -0.02478474 0.2345431 0 90.18
PcntLtROPE PcntInROPE PcntGtROPE
Diff 3.07 15.66 81.27

It'll be illustrated as follows.
画像リンク[png]:i.imgur.com
省18
242: 2017/11/11(土)23:28 ID:AQmX3Wf1(8/8) AAS
0/5 vs 1/20

画像リンク[png]:i.imgur.com
243: 2017/11/12(日)16:15 ID:OKdyWAPj(1) AAS
posterior ∝ likelihood * prior

画像リンク[png]:i.imgur.com
244: 2017/11/13(月)10:06 ID:9LmqAQrY(1/3) AAS
K=12
omega1=0.25
omega2=0.75
a1 = omega1*(K-2)+1
b1 = (1-omega1)*(K-2)+1
a2 = omega2*(K-2)+1
b2 = (1-omega2)*(K-2)+1

curve(dbeta(x,a1,b1))
curve(dbeta(x,a2,b2))
curve(dbeta(x,a1,b1)+dbeta(x,a2,b2))
省16
245: 2017/11/13(月)10:07 ID:9LmqAQrY(2/3) AAS
prior=matrix(NA,n,n) # with outer ERROR!
for(i in 1:n){
for(j in 1:n){
prior[i,j]=h(theta[i],omega[j])
}
}
image(theta,omega,prior,col = heat.colors(12,0.5))
contour(theta,omega,prior,add=TRUE)
persp(theta,omega,prior,col='skyblue',theta = 30)
library(rgl)
省15
246: 2017/11/13(月)12:14 ID:9LmqAQrY(3/3) AAS
ド底辺シリツ医大は裏口入学と学力で入った例外入学がいるとする。
高卒レベルの基礎学力テストをしたところ裏口入学は不合格率の最頻値が0.75、例外者のそれは0.25であった。
いずれの分布も形状母数和が12のベータ分布に従っていた。

ド底辺シリツ医大でテストしたところ6人が不合格、3人が合格であったとき、ド底辺シリツ医大の裏口入学者の割合を推測せよ。
247: 2017/11/13(月)20:42 ID:JnL2ZVyT(1/4) AAS
omega1=0.25
omega2=0.75
K=12

modelString='
model {
f o r(ii n1 : N){
y[i] ~ dbern( theta )
}
theta ~ dbeta( omega[m]*(kappa-2)+1 , (1-omega[m])*(kappa-2)+1 )
omega[1] <-
省16
248: 2017/11/13(月)20:51 ID:JnL2ZVyT(2/4) AAS
# in debug

y= c(1,1,1,1,1,1,0,0,0)
N=length(y)
omega1=0.25
omega2=0.75
K=12

modelString='
model {
for(i n1:N){
y[i] ~ dbern( theta )
省18
249
(1): 2017/11/13(月)21:18 ID:JnL2ZVyT(3/4) AAS
# in debug
y= c(1,1,1,1,1,1,0,0,0)
N=length(y)
omega1=0.25
omega2=0.75
kappa1=12
kappa2=12

modelString='
model {
for (i in 1:N){
省18
250: 2017/11/13(月)21:51 ID:JnL2ZVyT(4/4) AAS
P(Uraguchi|Wrong) = P(Wrong|Uraguchi)*P(Uraguchi)/(P(Wrong|Uraguchi)*P(Uraguchi)+P(Wrong|Square)*P(Square))

Uraguchi: Buying the way to Do-Teihen, unfair matriculation
Wrong: Writing Wrong English
Square: fair matriculation
P(Square) = 1 - P(Uraguchi)
P(Wrong|Uraguchi) = 1
P(Wrong|Square)=0.001
P(Uraguchi) ~ dunif(0,1)

P(U|W)=1*P(U)/(1*P(U)+0.001*(1-P(U)))

modelString='
省3
251: 2017/11/14(火)07:16 ID:kN15uX//(1) AAS
>>249

> js=as.matrix(codaSamples)
> boxplot(theta~m)
> tapply(theta,m,length)
1 2
8778 41222
> sum(m==2)/length(m)
[1] 0.82444
252: 2017/11/14(火)11:23 ID:/SJKjWLk(1/2) AAS
require(rjags)
JmodelString='
model {
puw = 1 * pu /(1 * pu + 0.001*(1-pu))
pu ~ dunif(0,1)
}
'
writeLines( JmodelString , con="TEMPmodel.txt" )
jagsModel = jags.model( file="TEMPmodel.txt")
update( jagsModel)
省6
253: 2017/11/14(火)13:59 ID:/SJKjWLk(2/2) AAS
# Stan for Uraguchi
modelString='
parameters{
real<lower=0,upper=1> pu;
}
transformed parameters{
real puw = 1 * pu /(1 * pu + 0.001*(1-pu));
}
model{
pu ~ uniform(0,1);
省6
254: 2017/11/14(火)18:44 ID:Njwo3HI0(1) AAS
ド底辺シリツ医大は裏口入学と学力で入った例外入学がいるとする。
高卒レベルの基礎学力テストをしたところ裏口入学は不合格率の最頻値が0.75、例外者のそれは0.25であった。
いずれの分布も形状母数和が12のベータ分布に従っていた。

あるド底辺シリツ医大でテストしたところ6人が不合格、3人が合格であったとき、このド底辺シリツ医大の裏口入学者の割合を推測せよ。

Suppose there are Uraguchi and non-Uraguchi(irregular) enrollees in the DoTeihen medical school,
they get the achievement test for high school students.
The failing rate of Uraguchi is known to distribute in β distributuion with its mode value ω = 0.75 and sum of shape parameters κ = 12.
The failing rate of irregulars is in β distribution with ω = 0.25 and κ = 12.

At a DoTeihen medical school, 9 alimni had the test, and 6 failed and 3 passed.
Infer the proportion of Uraguchi in this DoTeihen.
255: 2017/11/15(水)10:17 ID:4qVYF7j+(1) AAS
y= c(1,1,1,1,1,1,1,1,1)
N=length(y)
omega1=0.75
omega2=0.25
kappa1=12
kappa2=12

modelString='
model {
for (i in 1:N){
y[i] ~ dbern( theta )
省19
256: 2017/11/15(水)14:20 ID:RUmagzE5(1) AAS
In Bayesian data analysis, evidence is the marginal likelihood (Integrate P(D|Θ)P(Θ)dΘ) which MCMC cannot yield.
1-
あと 491 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.511s*