ngreifer / fwb

fwb: Fractional Weighted Bootstrap
https://ngreifer.github.io/fwb/
6 stars 0 forks source link

Difference to `sandwich` implementation #3

Open statzhero opened 2 years ago

statzhero commented 2 years ago

I see that sandwich::vcovBS() supports the fractional type since version 3.1.0. Is the implementation essentially the same as in fwb? Just getting a sense when to use what. Thank you!

ngreifer commented 2 years ago

I believe it is the same (or similar) implementation. I released fwb before Achim had implemented the weighted bootstrap in sandwich. He and I had a conversation about it right after I released fwb, and he told me it was going into sandwich, which I agreed was a good idea. I told him that once the change goes through, I might set fwb::vcovFWB() to just be a wrapper for vcvoBS(., type = "fractional"). I can't see the source code for sandwich 3.1.0, so I don't know if the implementation is exactly the same. I will say I built all of the code in fwb::vcovFWB() using variations of the vcovBS() internals, so I can't imagine there would be much of a difference. One difference is that fwb::vcovFWB() can produce a progress bar and use parallel computation, whereas sandwich::vcovBS() cannot do either.

statzhero commented 2 years ago

Thanks! You’re using ‘rexp(rate = 1)’ correct? It’s unclear to me if one can use any distribution related to the exponential family and whether some have an advantage. The article proposes Dirichlet from my very cursory reading; ‘sandwich’ presumably doesn’t say more in their docs either?

ngreifer commented 2 years ago

There was another article that found that there other ways to draw the weights, but the Dirichlet performed the best. I'm sure it's cited in Xu et al. In fwb, I do generate using rexp(rate = 1), but I divide all the weights in a sample by their mean so that they have an average of 1. This is equivalent to drawing from a uniform Dirichlet distribution. Regression is invariant to scaling of the weights, so sandwich might not take the additional step of scaling and just uses the random exponential variates. vcovFWB() applies the scaling factor to be consistent with fwb(), but in practice it doesn't make a difference and would save a fraction of second otherwise.

statzhero commented 2 years ago

I'm not a 100% sure it scales the same way but if you ever run into issues, you can try dqrng. Not affiliated with the package, so no endorsement on quality either.