Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Estimate Probit models and ability to change default standard errors. #28

Closed
dlindzee opened this issue Jul 7, 2020 · 2 comments

Comments

@dlindzee
Copy link

dlindzee commented Jul 7, 2020

The fixest package is great and has improved my workflow and saved me a lot of computation time. But I was wondering if there is any way to estimate a probit binary response model? At the moment I am using the R package bife. But it would be nice to be able to do this using fixest, as I can do with logit models.

Furthermore, I was wondering if it was possible to change the default standard errors when estimating a model. For example

set.seed(12)
Bond = runif(100, 0, 0.55)
Day = runif(100, 0, 1.45)
Intervention = round(Day)
Type = round(Bond)
Agency = round(Bond + Day)

Data <- data.table(Agency, Bond, Day, Intervention, Type)

feols(Agency ~ Bond + Day | Intervention + Type , Data)

Gives the following output

OLS estimation, Dep. Var.: Agency
Observations: 100 
Fixed-effects: Intervention: 2,  Type: 2
Standard-errors: Clustered (Intervention) 
     Estimate Std. Error t value Pr(>|t|)    
Bond 1.339600   0.324546  4.1276 0.000079 ***
Day  0.956392   0.269115  3.5538 0.000593 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Log-likelihood: -13.21   Adj. R2: 0.65434 
                       R2-Within: 0.52428 

Where the standard errors are clustered at the intervention level . However, with this is not what I necessarily want. In large datasets it also would seem to have a large effect on the computation time relative to the usual standard errors. Could you provide a way of overriding this behavior so I can calculate only the usual standard errors?

@dlindzee
Copy link
Author

dlindzee commented Jul 8, 2020

Sorry I realized that the one can estimate a probit model. But the other comment stands.

@lrberge
Copy link
Owner

lrberge commented Jul 8, 2020

Hello and thanks for using! :-)

Yes it's possible to estimate probit with feglm and a probit family. Note that there is no bias correction though. I don't publicize it too much because of the incidental parameter problem that applies there. Good that you found out!

On your other comment, it's actually something that I planned to do but never have done because I didn't know if people would use it in the end. Thanks to you, I now have implemented it.

The code below should work with the dev version of the package.

data(base_did)
est_no_FE  = feols(y ~ x1, base_did)
est_one_FE = feols(y ~ x1 | id, base_did)
est_two_FE = feols(y ~ x1 | id + period, base_did)

etable(est_no_FE, est_one_FE, est_two_FE)
#>                               est_no_FE          est_one_FE          est_two_FE
#> (Intercept)           1.989*** (0.1492)
#> x1                  0.9831*** (0.05012) 0.9615*** (0.04808) 0.9779*** (0.04579)
#> Fixed-Effects:      ------------------- ------------------- -------------------
#> id                                   No                 Yes                 Yes
#> period                               No                  No                 Yes
#> ___________________ ___________________ ___________________ ___________________
#> Observations                      1,080               1,080               1,080
#> S.E. type                      Standard           1-way: id           1-way: id
#> R2                              0.26304             0.38715             0.48696
#> Within R2                            --             0.26507             0.30776

# Changing the default standard-errors
setFixest_se(no_FE = "white", one_FE = "standard", two_FE = "twoway")
etable(est_no_FE, est_one_FE, est_two_FE)
#>                               est_no_FE          est_one_FE          est_two_FE
#> (Intercept)            1.989*** (0.149)
#> x1                  0.9831*** (0.05102) 0.9615*** (0.05138) 0.9779*** (0.03453)
#> Fixed-Effects:      ------------------- ------------------- -------------------
#> id                                   No                 Yes                 Yes
#> period                               No                  No                 Yes
#> ___________________ ___________________ ___________________ ___________________
#> Observations                      1,080               1,080               1,080
#> S.E. type                         White            Standard  2-way: id & period
#> R2                              0.26304             0.38715             0.48696
#> Within R2                            --             0.26507             0.30776

# Reseting the defaults
setFixest_se()

Note that you need to specify the default for three different cases: without fixed-effects, with one, and with two or more fixed-effects.

Thanks again!

@lrberge lrberge closed this as completed Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants