Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. N <- 100;id <- 1:N;id <- c(id,id);gid <- 1:(N/2);
  2. gid <- c(gid,gid,gid,gid);T <- rep(0,N);T = c(T,T+1)
  3. a <- qnorm(runif(N),mean=0,sd=0.005)
  4. gp <- qnorm(runif(N/2),mean=0,sd=0.0005)
  5. u <- qnorm(runif(N*2),mean=0,sd=0.05)
  6. a <- c(a,a);gp = c(gp,gp,gp,gp)
  7. Ylatent <- -0.05*T + a + u
  8. Data <- data.frame(
  9. Y = ifelse(Ylatent > 0, 1, 0),
  10. id = id,gid = gid,T = T
  11. )
  12. library(clubSandwich)
  13. library(plm)
  14. fe.fit <- plm(formula = Y ~ T, data = Data, model = "within", index = "id",effect = "individual", singular.ok = FALSE)
  15. vcovCR(fe.fit,cluster=Data$id,type = "CR2") # doesn't work, but I can run this by not specifying cluster as in the next line
  16. vcovCR(fe.fit,type = "CR2")
  17. vcovCR(fe.fit,cluster=Data$gid,type = "CR2") # I ultimately want to run this
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement