simple question:
Can I extract the final degrees of freedom after a feols
estimation using the fixest
package?
res = feols(Sepal.Length ~ Sepal.Width Petal.Length | Species, iris)
summary(res)
I know that there are many fancy ways to specify the df in fixest, but I'd just want the result (depending on which option I choose).
For example in the lfe
package using felm
, I can do so easily like this:
res = felm(Sepal.Length ~ Sepal.Width Petal.Length | Species | 0 | 0, iris)
res$df
Thanks!
CodePudding user response:
There is a degrees_freedom
> degrees_freedom(res, type = "k")
[1] 3
> degrees_freedom(res, type = "resid")
[1] 147
> degrees_freedom(res, type = "t")
[1] 2
By changing the type
, can get different degrees of freedom i.e ?degrees_freedom
shows
type - Character scalar, equal to "k", "resid", "t". If "k", then the number of regressors is returned. If "resid", then it is the "residuals degree of freedom", i.e. the number of observations minus the number of regressors. If "t", it is the degrees of freedom used in the t-test. Note that these values are affected by how the VCOV of x is computed, in particular when the VCOV is clustered.
Or may use
fitstat(res, "g", simplify = TRUE)
Or could be
unname(res$fixef_sizes)
CodePudding user response:
We may find them after summary
in the attr
ibutes of the scaled covariance matrix, check str(summary(res))
.
attr(summary(res)$cov.scaled, 'dof.K')
# [1] 3