Guest User

Untitled

a guest
Dec 11th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #load package
  2. library(rms)
  3.  
  4. #make df
  5. x <- rpois(1000, 0.5)
  6. y <- sample(c(1:100),1000, replace=TRUE)
  7. z <- factor(sample(c(1:25), 1000, replace=TRUE))
  8. df <- data.frame(y,x,z)
  9.  
  10. #set datadist
  11. dd <- datadist(df)
  12. options(datadist='dd')
  13.  
  14. #works when cluster variable isn't included as fixed effect in regression
  15. reg <- Glm(x ~ y, df, x=TRUE, y=TRUE, family=poisson())
  16. reg_clus <- bootcov(reg, df$z)
  17. summary(reg_clus)
  18.  
  19. #doesn't work when cluster variable included as fixed effect in regression
  20. reg2 <- Glm(x ~ y + z, df, x=TRUE, y=TRUE, family=poisson())
  21. reg_clus2 <- bootcov(reg2, df$z)
  22. summary(reg_clus2)
Add Comment
Please, Sign In to add comment