# [R] solving for beta0 in a logsitic regression

Nina Paynter npaynter at PARTNERS.ORG
Thu Sep 25 22:03:55 CEST 2008

```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}}

```