File: regtest-fixest.R

package info (click to toggle)
multcomp 1.4-29-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,444 kB
  • sloc: sh: 28; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 958 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

### fixed effects models
### methods and tests contributed by Grant McDermott (@grantmcdermott)

library("multcomp", quietly = TRUE)

fixestOK <- require("fixest", quietly = TRUE)
if (fixestOK) {
    lmod  <- lm(Sepal.Length ~ Sepal.Width + as.factor(Species), iris)
    fmod  <- feols(Sepal.Length ~ Sepal.Width + as.factor(Species), iris)  
    fmod2 <- feols(Sepal.Length ~ Sepal.Width | Species, iris, vcov = "iid") ## see next model too
    fmod3 <- feols(Sepal.Length ~ Sepal.Width | Species, iris) ## default vcov is clustered by Species

    glmod  <- glht(lmod, "Sepal.Width==0")
    gfmod  <- glht(fmod, "Sepal.Width==0")
    gfmod2 <- glht(fmod2, "Sepal.Width==0")
    gfmod3 <- glht(fmod3, "Sepal.Width==0", vcov = "iid")
    stopifnot(all.equal(confint(glmod)$confint, confint(gfmod)$confint))
    stopifnot(all.equal(confint(glmod)$confint, confint(gfmod2)$confint))
    stopifnot(all.equal(confint(glmod)$confint, confint(gfmod3)$confint))
}