Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(ResourceSelection)
- n <- 500; chisqs <- c()
- for (i in 1:10000) {
- x <- rnorm(n)
- p <- plogis(0.1+0.5*x)
- y <- rbinom(n,1,p)
- x2 <- hoslem.test(y,p)$statistic
- chisqs <- cbind(chisqs,x2);
- }
- h <- hist(chisqs,50)
- xs <- seq(0,25,0.01)
- ys <- dchisq(xs,df=10)
- lines(xs,ys*h$counts/h$density)
- library(ResourceSelection)
- n <- 500; chisqs <- c()
- for (i in 1:10000) {
- x <- rnorm(n)
- p <- plogis(0.1+0.5*x)
- y <- rbinom(n,1,p)
- fit <- glm(y~x)
- x2 <- hoslem.test(y,fitted(fit))$statistic
- chisqs <- cbind(chisqs,x2);
- }
- h <- hist(chisqs,50)
- xs <- seq(0,25,0.01)
- ys <- dchisq(xs,df=8)
- lines(xs,ys*h$counts/h$density)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement