On 9 Oct 2003 at 11:38, Michele Grassi wrote: Here is one way of doing it:
> x <- rnorm(1000) > beta <- 1 > p <- 1/(1+exp(-beta*x)) > o <- order(x) > plot( x[o], p[o], ylim=c(0,1), type="l") > y <- rbinom(1000, 1, prob=p) > model <- glm(y ~ x , family=binomial) > summary(model) . . . > B <- 1000 # number of simulation replications > coefs <- matrix(0, B, 2) > for (i in 1:B) { + coefs[i, ] <- coef(glm(rbinom(1000,1,prob=p) ~ x, family=binomial)) + } > hist( coefs[,1]) > hist(coefs[,2]) > plot(coefs) Kjetil Halvorsen 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. ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help