[R] Generating logistic regression data for specific ORs

Denis Aydin Denis.Aydin at unibas.ch
Wed Aug 12 14:27:13 CEST 2009


Dear R-users

I want to generate data for a logistic regression for an epidemiological 
simulation.

First, I created a "disease-vector" containing a "1" if a subject is a 
cases (i.e. has the disease) and a "0" if a subject is a control. E.g.:


 > disease <- as.factor( c(rep(1, n.cases), rep(0, n.controls)) )


Then, I want to generate two lognormally distributed exposure vectors, 
one for cases and one for controls.
The parameters of the distributions should be chosen in a way that a 
logistic regression model has a specific OR (or beta1) for the exposure. 
Something like that:


 > exp.cases <- lnorm(n.cases, mean.cases, sd.cases)
 > exp.contr <- lnorm(n.controls, mean.controls, sd.controls)
 > exposure <- c(exp.cases, exp.controls)
 > model <- glm(disease ~ exposure, family = binomial)


Unfortunately, I don't know how to generate the exposure vectors in a 
way that the logistic regression has a specific beta1 or OR.
In particular, I want the control over the parameters of the exposure 
distributions of cases and controls.

Could anyone help me on that?

Any help is appreciated.

Denis
-- 
Denis Aydin
Institute of Social and Preventive Medicine at Swiss Tropical Institute 
Basel
Associated Institute of the University of Basel
Steinengraben 49 – 4051 Basel – Switzerland
Phone: +41 (0)61 270 22 04
Fax:   +41 (0)61 270 22 25
denis.aydin at unibas.ch
www.ispm-unibasel.ch




More information about the R-help mailing list