高校数学の質問スレ(医者・東大卒専用) Part438 (893レス)
上下前次1-新
841: 05/23(金)10:58 ID:or+7Cxzr(1) AAS
#
"
Construct a Monte Carlo study that investigates how the probability of coverage depends on the sample size and true proportion value. In the study, let n be 10, 25, 50, and 100 and let p be .05, .25, and .50. Write an R function that has three inputs, n, p, and the number of Monte Carlo simulations m,and will output the estimate of the exact coverage probability.
Implement your function using each combination of n and p and m = 1000 simulations.
Describe how the actual probability of coverage of the traditional interval depends on the sample size and true proportion value.
"
f = \(n,p,m=1000){
y=rbinom(m,n,p)
phat=y/n
se=sqrt(phat*(1-phat)/n)
lo=phat - qnorm(0.975)*se
up=phat + qnorm(0.975)*se
mean(lo < p & p < up)
}
f=Vectorize(f)
n_values = c(10, 25, 50,100)
p_values = c(0.05, 0.25, 0.5)
set.seed(123)
outer(n_values,p_values,f)
上下前次1-新書関写板覧索設栞歴
あと 52 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.016s