R: [R] simulate binary data from a logistic regression model

Vito Muggeo vito.muggeo at giustizia.it
Thu Oct 9 13:44:39 CEST 2003


You can use the followings:

lp<- -5+..... #linear predictor
y<-rbinom(length(lp), size, plogis(lp))

Note that size means your "denominator" in proportions to be simulated. For
instance, if you want binary data use size=1.


best,
vito



----- Original Message -----
From: Michele Grassi <grassi at psico.univ.trieste.it>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, October 09, 2003 11:38 AM
Subject: [R] simulate binary data from a logistic regression model


> Hi.
> How can i simulate a binary data set from a logistic
> regression model?I need to manipulate parameters and so
> obtain my set of data.
> I want to show the improve in analyzing binary data
> with GLM(binomial) model instead of classical ANOVA or
> NON-MODELS procedures(relative risk-odds ratio-Pearson
> test of godness of fit...)
> Can you say me what is the right function to use?
> Do you know any interesting simulation in the web?
>
> Thank you.
> Michele.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list