Skip to content

Commit 22f97f6

Browse files
committedDec 28, 2020
essai03
1 parent 75a5fa0 commit 22f97f6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎inst/essais/essai03.R

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
library(gfilogisreg)
2+
3+
ilogit <- function(a) exp(a) / (1+exp(a))
4+
5+
set.seed(666L)
6+
n <- 51L
7+
x <- seq(-3, 3, length.out = n)
8+
group <- gl(3L, 17L)
9+
beta <- c(0, 1, 2, 3)
10+
probs <- ilogit(model.matrix(~ 0 + x + group) %*% beta)
11+
dat <- data.frame(
12+
group = group,
13+
y = rbinom(n, size = 1L, prob = probs)
14+
)
15+
gf <- gfilogisreg(y ~ 0 + x + group, data = dat, N = 3000L)
16+
gfiSummary(gf, conf = 0.9)
17+
18+
glm(y ~ 0 + x + group, data = dat, family = binomial())
19+
20+
# stan ####
21+
library(rstanarm)
22+
options(mc.cores = parallel::detectCores())
23+
24+
bglm <- stan_glm(y ~ 0+x+group, family = binomial(), data = dat,
25+
iter = 10000)
26+
27+
posterior_interval(bglm)

0 commit comments

Comments
 (0)
Please sign in to comment.