Skip to content

Instantly share code, notes, and snippets.

@timcdlucas
Created January 18, 2018 19:19
Show Gist options
  • Save timcdlucas/098b86dced909d772f3d40ae9a4863a6 to your computer and use it in GitHub Desktop.
Save timcdlucas/098b86dced909d772f3d40ae9a4863a6 to your computer and use it in GitHub Desktop.
x <- 1:100
n <- sapply(x, function(x) rpois(1, x))
pos <- sapply(1:length(n), function(i) rbinom(1, n[i], plogis(x[i] - 50)))
p <- pos / n
d <- data.frame(p = p, x = x)
m <- glm(p ~ x, data = d, weights = n, family = binomial)
m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment