- If you want 200 copies of each of 5 levels in a polytomous variable in random order, then do this instead
If you want 200 copies of each of 5 levels in a polytomous variable in random order, then do this instead:
x <- sample(rep(paste0('pict', 1:5), 200))
If you want to control for overall prevalence of a specific outcome, then you must choose which
beta
you will fudge. I usually dobeta0
.MM <- model.matrix(~x) betas <- rnorm(4) prevTarget <- 0.3 prevDiff <- function(beta0) prevTarget - mean(binomial()$linkinv(MM%*%c(beta0, betas))) beta0 <- uniroot(prevDiff, c(-100, 100))$root mean(binomial()$linkinv(MM%*%c(beta0, betas)))
x <- sample(rep(paste0('pict', 1:5), 200))
- If you want to control for overall prevalence of a specific outcome, then you must choose which
beta
you will fudge. I usually dobeta0
.
MM <- model.matrix(~x)
betas <- rnorm(4)
prevTarget <- 0.3
prevDiff <- function(beta0)
prevTarget - mean(binomial()$linkinv(MM%*%c(beta0, betas)))
beta0 <- uniroot(prevDiff, c(-100, 100))$root
mean(binomial()$linkinv(MM%*%c(beta0, betas)))