[過去ログ] 臨床統計もおもしろいですよ、その1 [無断転載禁止]©2ch.net (747レス)
上下前次1-新
このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
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.
257: 2017/11/17(金)12:56 ID:nii6SWM6(1/3) AAS
# randam numbers by inverse culmutive density function
RandICDF <- function(ICDF,PDF,...){
U=runif(10000)
rand=ICDF(U,...)
hist(rand,freq=FALSE,breaks=30,
col=sample(colors(),2),main='')
curve(PDF(x,...),add=TRUE,lwd=2)
invisible(rand)
}
par(mfrow=c(2,2))
省5
258: 2017/11/17(金)13:24 ID:nii6SWM6(2/3) AAS
# randam numbers following PDF by Jhon von Neuman's method
vonNeumann <- function(PDF,xmin=0,xmax=1){
N=10000
ymax=max(PDF(seq(xmin,xmax,length=N+1)))
Ux=runif(N,xmin,xmax)
Uy=runif(N,0,ymax)
Rand=Ux[which(Uy<=PDF(Ux))]
hist(Rand,xlim=c(xmin,xmax),freq=FALSE,breaks=30,col=sample(colors(),2),main='')
curve(PDF,add=TRUE,lwd=2)
invisible(Rand)
省9
259: 2017/11/17(金)16:06 ID:nii6SWM6(3/3) AAS
Golgo Script will be reduced as follows:
N shoots with z hits
Nz <- function(N,z,...){
curve(dbeta(x,1+z,1+N-z),xlab='Probability of Hit',
ylab=paste('Probabilty of',z,'Hits out of ',N,'Shoots'),...)
hdi=HDInterval::hdi(qbeta,shape1=1+z,shape2=1+N-z)
print(hdi,digits=4)
}
260: 2017/11/18(土)10:52 ID:V/eIhsOZ(1) AAS
modelString =
'model {
z ~ dbin(0.5,N)
N ~ dpois(lambda)
p=z/N
}
'
writeLines(modelString , con="TEMPmodel.txt" )
f <- function (lambda){
dataList=list(lambda=lambda)
省10
上下前次1-新書関写板覧索設栞歴
あと 487 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.066s*