amrei-stammann / alpaca

An R-package for fitting glm's with high-dimensional k-way fixed effects
43 stars 6 forks source link

getAPEs with more than 2 high-dimensional fixed effects #11

Open tcsimmons opened 4 years ago

tcsimmons commented 4 years ago

While using getAPEs to calculate the fixed effects of the model, I've noticed that "getAPEs' currently only supports logit and probit models" error always shows up whenever I have more than 2 high-dimensional fixed effects in the model. I looked through the code and found that this is indeed part of the function. You can see from the following code, copied directly from the function, that any model with "lvls.k" not equal to 2 will throw an error:

if (panel.structure == "classic") { if (object[["family"]][["family"]] != "binomial" | !(object[["family"]][["link"]] %in% c("logit", "probit")) | length(object[["lvls.k"]]) != 2L) { stop(paste("'getAPEs' currently only supports logit and probit models.")

Maybe I just don't understand the background here, but I was also reading in the package reference manual and found the following line which suggests that the function should apply for all covariates in the model and never stipulates the limitation on number:

"getAPEs is a post-estimation routine that can be used to estimate average partial effects with respect to all covariates in the model and the corresponding covariance matrix."

Can you help me understand why there's a limitation on calculating average partial effects with respect to the number of covariates placed in the model?

amrei-stammann commented 4 years ago

Hi,

getAPEs() currently only works for logit and probit models, either with two-way fixed effects (in a classical panel structure, see https://cran.r-project.org/web/packages/alpaca/vignettes/howto.html) or with three-way fixed effects (in a network panel structure, see https://cran.r-project.org/web/packages/alpaca/vignettes/trade.html). You are right, the error message should be more informative. The limitation is mainly due to the computation of the standard errors. We are currently working on extensions.

Best, Amrei

tcsimmons commented 4 years ago

This makes sense. Thank you for your reply!

-Trent

From: Amrei Stammann notifications@github.com Sent: Tuesday, July 21, 2020 1:27 AM To: amrei-stammann/alpaca alpaca@noreply.github.com Cc: Trent Simmons Trent.Simmons@doj.ca.gov; Author author@noreply.github.com Subject: Re: [amrei-stammann/alpaca] getAPEs with more than 2 high-dimensional fixed effects (#11)

Hi,

getAPEs() currently only works for logit and probit models, either with two-way fixed effects (in a classical panel structure, see https://cran.r-project.org/web/packages/alpaca/vignettes/howto.htmlhttps://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dproject.org_web_packages_alpaca_vignettes_howto.html&d=DwMCaQ&c=uASjV29gZuJt5_5J5CPRuQ&r=-line2TQISaNSw8moqUIlTGqExYKtqVIQI-szQBNvJ8&m=8B_xlbqjZiTXeqKA1I4n8YZdApfA7BIU4M24W5C2wKg&s=OGv-9zsxZCfrosH25W-6EGJhHUjshLLmH4GVc5FPsA0&e=) or with three-way fixed effects (in a network panel structure, see https://cran.r-project.org/web/packages/alpaca/vignettes/trade.htmlhttps://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dproject.org_web_packages_alpaca_vignettes_trade.html&d=DwMCaQ&c=uASjV29gZuJt5_5J5CPRuQ&r=-line2TQISaNSw8moqUIlTGqExYKtqVIQI-szQBNvJ8&m=8B_xlbqjZiTXeqKA1I4n8YZdApfA7BIU4M24W5C2wKg&s=ykTFV6-7KqYpHvVr0UZufveTexRgIp6y30Aj4l01Yq8&e=). You are right, the error message should be more informative. The limitation is mainly due to the computation of the standard errors. We are currently working on extensions.

Best, Amrei

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_amrei-2Dstammann_alpaca_issues_11-23issuecomment-2D661713475&d=DwMCaQ&c=uASjV29gZuJt5_5J5CPRuQ&r=-line2TQISaNSw8moqUIlTGqExYKtqVIQI-szQBNvJ8&m=8B_xlbqjZiTXeqKA1I4n8YZdApfA7BIU4M24W5C2wKg&s=fdDYpRPfvUlUqsD2dwIfX_u88ZgafbfBrESfxDd8iiw&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AOHGCV47RC5KHXKREVKA3B3R4VGMDANCNFSM4PCMGWBA&d=DwMCaQ&c=uASjV29gZuJt5_5J5CPRuQ&r=-line2TQISaNSw8moqUIlTGqExYKtqVIQI-szQBNvJ8&m=8B_xlbqjZiTXeqKA1I4n8YZdApfA7BIU4M24W5C2wKg&s=Jvs_24QbhnQG09wte8NvubCJuBHCmxo1h0VwdBNBie0&e=.

CONFIDENTIALITY NOTICE: This communication with its contents may contain confidential and/or legally privileged information. It is solely for the use of the intended recipient(s). Unauthorized interception, review, use or disclosure is prohibited and may violate applicable laws including the Electronic Communications Privacy Act. If you are not the intended recipient, please contact the sender and destroy all copies of the communication.