Clinical PK/PD

被験者背景シミュレーション

最終更新:

hks

- view
だれでも歓迎! 編集
# n = 19 (nonsmoker)
# n = 49 (former smoker)
# n = 32 (smoker)
smoke.num <- c(rep(1, 19), rep(2, 49), rep(3, 32))
label.smoke <- c("Nonsmoker","Former smoker","Smoker")
smoke <- factor(smoke.num, levels=1:3, labels=label.smoke)

mu <- mean(log(smoke.num))
sg <- sqrt(var(log(smoke.num)))

# Empirical distribution
Pi <- cumsum(as.numeric(table(smoke)) / length(smoke))
Pi <- Pi[-length(Pi)]

# Continuous critical value
CrV <- exp(mu + sg * qnorm(Pi))

# Simulation
set.seed(27011)
nsim <- 1000
smoke.sim.continuous <- exp(rnorm(nsim, mean=mu, sd=sg))
smoke.sim <- cut(smoke.sim.continuous, breaks=c(0,CrV,max(smoke.sim.continuous)), labels=label.smoke)

table(smoke.sim)

# Plot
hist(smoke.sim.continuous, freq=F, xlab='Smoke', main='')
lines(density(smoke.sim.continuous))
abline(v=CrV, col=4)

タグ:

R
+ タグ編集
  • タグ:
  • R

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

目安箱バナー