Open kennchua opened 1 year ago
Possible duplicate of #295.
Hey, @kennchua @grantmcdermott @lrberge @vincentarelbundock I am facing the same issue here. I used the function as suggested in #295 to extract the variance-covariance matrix, but I wasn't sure how to aggregate it and incorporate it into the marginaleffects::hypotheses
function.
marginaleffects::hypotheses(res_sunab, hypothesis = "mean(c(
year::0,
year::1,
year::2,
year::3)) = 0")
After running the code above, the coefficient is -2.91 and everything else is NAs, along with 19 warnings saying In names(model[["coefficients"]]) == names(coefs) : longer object length is not a multiple of shorter object length
. It seems to suggest that the coefficients included in the test is shorter than the original model.
Therefore, I tried to do what was suggested in the previous post - including the variance-covariance matrix to match the length of the coefficients.
sunab_beta_vcv(res_sunab)$sigma[9:12, 9:12]
However, I don't know how to include this into the function. When I did the following, I got errors:
marginaleffects::hypotheses(res_sunab, hypothesis = "mean(c(
year::0,
year::1,
year::2,
year::3)) = 0", vcov = sunab_beta_vcv(res_sunab)$sigma[9:12, 9:12])
Error: The jacobian does not match the variance-covariance matrix. In addition: There were 19 warnings (use warnings() to see them)
In the package example for two-way fixed effects and sunab(), we can get the ATT as follows:
How would one approach getting the ATT for a subset of the periods (e.g. 0-3)? I tried the following for TWFE regressions:
But it just returns the estimates for each period rather than an aggregate.
I think it's possible to use something like the
marginaleffects::hypotheses()
command.But in order to do this for output of
sunab()
, I would need the aggregated variance-covariance matrix.Would appreciate any leads on how to aggregate effects for a range of post-treatment periods particularly for sunab() regressions.