Skip to content

Small sample adjustment changes for vcov="hetero" with fixest 0.13? #611

@s3alfisc

Description

@s3alfisc

Hi fixest team,

I am currently aligning pyfixest with the new fixest defaults shipped with 0.13 and I struggle to replicate small sample adjustments for heteroskedastic error. My tests fail! 😅

It appears to me that with the new version, some default ssc adjustment have changed?

I do not find any reference in the changelog.

Changes I spot:

  • The G.adj arg seems no longer applied for heteroskedastic errors. This makes a lot of sense to me and is in line with the ssc / standard error vignette ✅
  • The K.adjlogic for hetero errors is switched from (N-1) / (N - df.k) to n/(n - df.k)).

Can you confirm? I suppose this is intentional but thought I'd better flag it, as I did not see a reference in the changelog.

Should I open a PR to clarify the ladder point in the docs and changelog?

Thanks!

Under 0.13.2, I find:

> fixest:::vcov_hetero_internal
function (bread, scores, sandwich, nthreads, ssc, n, K, ...) 
{
    if (!sandwich) {
        vcov_mat = cpp_crossprod(scores, 1, nthreads)
    }
    else {
        vcov_mat = cpp_crossprod(cpp_matprod(scores, bread, nthreads), 
            1, nthreads)
    }
    if (ssc$K.adj) {
        adj = n/(n - K)
        vcov_mat = vcov_mat * adj
    }
    vcov_mat
}
<bytecode: 0x11b2e4048>
<environment: namespace:fixest>
> fixest:::vcov_iid_internal
function (bread, ssc, object, n, K, ...) 
{
    if (ssc$K.adj) {
        adj = (n - 1)/(n - K)
        bread = bread * adj
    }
    bread
}
<bytecode: 0x139ea59a8>
<environment: namespace:fixest>

Under fixest 0.12, I found

> fixest:::vcov_hetero_internal
function (bread, scores, sandwich, ssc, nthreads, ...) 
{
    if (!sandwich) {
        vcov_noAdj = cpp_crossprod(scores, 1, nthreads)
    }
    else {
        n = nrow(scores)
        adj = ifelse(ssc$cluster.adj, n/(n - 1), 1)
        vcov_noAdj = cpp_crossprod(cpp_matprod(scores, bread, 
            nthreads), 1, nthreads) * adj
    }
    vcov_noAdj
}
<bytecode: 0x13b31a6a0>
<environment: namespace:fixest>
> fixest:::vcov_iid_internal
function (bread, ...) 
{
    bread
}
``

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