Skip to content

Parameter "subset" throws errors in feols() when used with clustered SEs #129

@noahmbuckley

Description

@noahmbuckley

Hello, thank you for the excellent package! Very useful and powerful. I've been running some boring, typical feols() regressions with two-way fixed effects and associated clustered SEs. I'm used to being able to subset my data in the regression itself when I use lm() or lmer() or other common functions. When I try that here, I get a variety of errors. Currently I mostly get this error:

Error in vcov.fixest(object, se = se, cluster = cluster, dof = dof, forceCovariance = forceCovariance, :
The length of the clusters (310017) does not match the number of observations in the estimation (149218).

The function call I'm using is of this sort:
mod <- feols(outcome ~ x1 + x2 | fe1 + fe2, data=dat, cluster=c("fe1", "fe2"), subset=(x3==4))

I could send you some data and code if that would help. It happens whether I define a vector (vec <- x3==4) and then include that with subset=vec or whether I do the subsetting right in the feols() call. I think that before I was getting different errors too when I was subsetting directly in the function, although I can't reproduce that right now for some reason.

Thank you!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions