s3alfisc / fwildclusterboot

Fast Wild Cluster Bootstrap Inference for Regression Models / OLS in R. Additionally, R port to WildBootTests.jl via the JuliaConnectoR.
https://s3alfisc.github.io/fwildclusterboot/
GNU General Public License v3.0
23 stars 4 forks source link

`plm` support #31

Open tappek opened 2 years ago

tappek commented 2 years ago

Is there a specific reason why package plm is not supported by fwildclusterboot? Shall there be questions about plm objects maybe I could help.

s3alfisc commented 2 years ago

Hi @tappek, thanks for raising this, adding a plm method is definitely on my to-do list! The reason for why plm is not yet supported is a) that I am not too familiar with the package and would need some time to explore its functionalities and b) that onboarding a new method is quite labour intensive (I'll have to write a lot of tests). Thanks for your kind offer to help, I will definitely get back to that :) As a timeline, I am currently integrating functionality of WildBootTests.jl into fwildclusterboot , which will approximately take two more weeks. I'll start looking into plm support right after.

s3alfisc commented 2 years ago

Hi @tappek, I have started to investigate plm objects - I think that all methods supported by plm::plm() except for the random effects model (which I am not too familiar with) are suitable for fwildclusterboot. So just to give you a heads up - plm support has now moved from "planned features" to "work in progress" :) .

I already have a first question: if I wanted to retain all "index" names from a plm object, what would be the best way to do so? Is it even possible based on the plm object only? With "index" names, I try to refer to a) all index values set in a pdata.frame or b) all variables not specified in the model formula, but implicitly used in the estimation.

Currently, I can only think of running something like

library(plm)
data("Grunfeld", package="plm")
Grunfeld2 <- pdata.frame(Grunfeld, index=c("firm","year"))

plm_object <- plm(inv~value+capital, data = Grunfeld2, model = "within")
names(index(Grunfeld2))

Is it possible to get these two names based on the plm_object without referring to the pdata.frame?

tappek commented 2 years ago

yes, it is simply names(index(plm_object$model))

tappek commented 2 years ago

Oh, I just realised, we even supply an index method for model objects. So you could also use the bit shorter version names(index(plm_object)).

s3alfisc commented 2 years ago

I have opened a development branch for plm support. So far, it is quite 'barebone' - boottest() works with plm() and "pooling".

tappek commented 1 year ago

Hi there, I did not realized there is a branch for plm meanwhile. I have just checked and package build for the plm branch fails due to dependecy package Matrix.utils not being available anymore on CRAN (archived).

As we recently had some plm users asking us for fwildclustersupport, I thought I stop by with a motivating thumbs up for working on this!

s3alfisc commented 1 year ago

Hi @tappek - nice to hear that there are plm users with interest in fwildclusterboot! This is exactly the type of feedback I needed. I will get back to it =) The plm branch has been stale for quite a while now, and I will have to set up a new one. I cannot promise to get back to it tomorrow, but will try to open a proper PR by the end of next month.

s3alfisc commented 1 year ago

The key part to support plm is to implement a preprocess method customized to plm. Browsing the code, I have just recalled that I have reorganized this part a while back, and it should be actually fairly straightforward to add a boottest.plm method after I familiarize myself with plm post-processing tools =)

s3alfisc commented 1 year ago

I have opened a new branch and a new pull request. This is much less work than I had anticipated, so really, thanks for pinging me! =) I might actually be able to add support by tomorrow/the end of the weekend, minus unit tests.

s3alfisc commented 1 year ago

I think I have finalized basic support for model = "within" and model = "pooling". If you have 10-20 minutes to spare, would you mind playing around with boottest.plm to spot any potential bugs I might have overseen @tappek?

tappek commented 1 year ago

Wow, that was quick! I gave it a quick test drive and it runs on my end.

I used this code, which also uses sandwich::vcovBS and is based on input from plm users with fwildclusterboot: https://gist.github.com/tappek/4cb65ab25d64f019ec629df5d11bd2bc

The issue with dropped observations (discovered and reported by the plm users) in the gist seems to be a plm issue which I have not fully analysed yet, but registered here https://github.com/ycroissant/plm/issues/44.

For others to replicate:

remotes::install_github(repo = "s3alfisc/fwildclusterboot", ref = "plm-new") # fwildclusterboot with initial plm support
remotes::install_github("ycroissant/plm") # recent development version of plm