Hi all,

I am trying to create simulated data for exploring reclassfication measures in a logistic setting with two continuous predictors and I would like to set the average population probability of outcome rather than the logistic beta0. Is there a way to find a beta0 that will generate the desired average population probability of outcome given x,y and their odds ratios?
#Here is an outline of what I would like to do:
   pop.d=0.1
  xvar=rnorm(5000,0,0.5)
  yvar=rnorm(5000,0,0.5)
   orx=16
   ory=2

#find beta0
beta0=f(x,y,orx,ory,pop.d)
#actual function pop.d=Integral(exp(beta0 + log(orx)*x + log(ory)*y)/(1 + exp(beta0 + log(orx)*x + log(ory)*y))dx dy)

   #create linear log odds functions for the outcome with x and y
   log.odds.xy = beta0 + log(orx)*xvar + log(ory)*yvar
   #create outcome variable based on x only and on x and y
   out =rbinom(5000,1,plogis(log.odds.xy))

#where E[mean(out)]=pop.d

Thanks,
Nina


The information transmitted in this electronic communica...{{dropped:16}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to