pedrohcgs / CS_RR

MIT License
27 stars 12 forks source link

I am having issues while trying to run honest did #1

Open taiwoakinyemi opened 2 years ago

taiwoakinyemi commented 2 years ago

When I input the code for honest_did, I receive the error below. Error in seq.default(from = 0, to = Mub, length.out = 10) : 'to' must be a finite number In addition: Warning message: In n * n : Error in seq.default(from = 0, to = Mub, length.out = 10) : 'to' must be a finite number Kindly help out, I can't figure why this is happening

taiwoakinyemi commented 2 years ago

Kindly revisit my earlier question. Thanks

taiwoakinyemi commented 2 years ago

I have been able to resolve this.

davidmacolisa commented 1 year ago

Hi Taiwo, how did you resolve this? I am having a similar issue. Thanks for your help.

jonathandroth commented 1 year ago

Hi, thanks for the message! Can you please provide a minimal working example of the code you ran that produced this error. Thank you.

davidmacolisa commented 1 year ago

Hi Jon,

Thanks for your reply. The steps I took:

Step 1: house.attgt <- ghsm_solar %>% att_gt( yname = 'own_house', tname = 'year', idname = 'UqNr', gname = 'solar.first.treat', xformla = controls, data = ., panel = F, control_group = 'nevertreated', anticipation = 2, weightsname = 'House_wgt', bstrap = T, cband = T, biters = 1000, clustervars = 'UqNr', est_method = "reg", base_period = "universal", print_details = F, )

Step2: agg.es.house.attgt <- aggte(house.attgt, type = 'dynamic', min_e = -Inf, max_e = Inf, na.rm = T)

Step 3: I ran the honest_did and honest_did.AGGTEobj functions

Step 4: hd.smooth.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "smoothness") hd.rm.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "relative_magnitude")

hd.smooth.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "smoothness") hd.rm.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "relative_magnitude")

None of the codes in step 4 worked.

#####################

THE ERRORS

#####################

hd.smooth.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "smoothness") Warning in n * n : NAs produced by integer overflow

Error in seq.default(from = 0, to = Mub, length.out = 10) (solar.R#1587): 'to' must be a finite number Show stack trace

hd.rm.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "relative_magnitude") Warning in n * n : NAs produced by integer overflow

Error in { (solar.R#1571): task 1 failed - "non-conformable arguments" Show stack trace

hd.smooth.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "smoothness") Warning in n * n : NAs produced by integer overflow

Error in seq.default(from = 0, to = Mub, length.out = 10) (solar.R#1587): 'to' must be a finite number Show stack trace

hd.rm.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "relative_magnitude") Warning in n * n : NAs produced by integer overflow

Error in { (solar.R#1571): task 1 failed - "non-conformable arguments" Show stack trace

jonathandroth commented 1 year ago

Thanks! @Mauricio Caceres Bravo @.***> can you try to track this down

On Sun, May 7, 2023, 8:17 PM Davidmac O. Ekeocha @.***> wrote:

Hi Jon,

Thanks for your reply. The steps I took:

Step 1: house.attgt <- ghsm_solar %>% att_gt( yname = 'own_house', tname = 'year', idname = 'UqNr', gname = 'solar.first.treat', xformla = controls, data = ., panel = F, control_group = 'nevertreated', anticipation = 2, weightsname = 'House_wgt', bstrap = T, cband = T, biters = 1000, clustervars = 'UqNr', est_method = "reg", base_period = "universal", print_details = F, )

Step2: agg.es.house.attgt <- aggte(house.attgt, type = 'dynamic', min_e = -Inf, max_e = Inf, na.rm = T)

Step 3: I ran the honest_did and honest_did.AGGTEobj functions

Step 4: hd.smooth.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "smoothness") hd.rm.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "relative_magnitude")

hd.smooth.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "smoothness") hd.rm.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "relative_magnitude")

None of the codes in step 4 worked.

##################### THE ERRORS

#####################

hd.smooth.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "smoothness") Warning in n * n : NAs produced by integer overflow

Error in seq.default(from = 0, to = Mub, length.out = 10) (solar.R#1587): 'to' must be a finite number Show stack trace

hd.rm.never <- honest_did(es = agg.es.house.attgt, e = 0, type = "relative_magnitude") Warning in n * n : NAs produced by integer overflow

Error in { (solar.R#1571): task 1 failed - "non-conformable arguments" Show stack trace

hd.smooth.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "smoothness") Warning in n * n : NAs produced by integer overflow

Error in seq.default(from = 0, to = Mub, length.out = 10) (solar.R#1587): 'to' must be a finite number Show stack trace

hd.rm.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "relative_magnitude") Warning in n * n : NAs produced by integer overflow

Error in { (solar.R#1571): task 1 failed - "non-conformable arguments" Show stack trace

— Reply to this email directly, view it on GitHub https://github.com/pedrohcgs/CS_RR/issues/1#issuecomment-1537520993, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6EXFGSOC6B2LWYNTXJ2NDXE7YL5ANCNFSM5MV4ERLA . You are receiving this because you commented.Message ID: @.***>

mcaceresb commented 1 year ago

@jonathandroth In the snippet here, shouldn't betahat=beta instead of beatahat=es$att.egt?

jonathandroth commented 1 year ago

Yes that looks right to me

On Sun, May 7, 2023, 11:21 PM Mauricio Caceres Bravo < @.***> wrote:

@jonathandroth https://github.com/jonathandroth In the snippet here https://github.com/pedrohcgs/CS_RR#auxiliary-functions, shouldn't betahat=beta instead of beatahat=es$att.egt?

— Reply to this email directly, view it on GitHub https://github.com/pedrohcgs/CS_RR/issues/1#issuecomment-1537553228, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6EXFDEAZ2Q3XYN3ZLCKELXFAN7FANCNFSM5MV4ERLA . You are receiving this because you were mentioned.Message ID: @.***>

jonathandroth commented 1 year ago

Ps this appears to be what we have on the honestdid readme

https://github.com/asheshrambachan/HonestDiD

On Sun, May 7, 2023, 11:26 PM Jonathan Roth @.***> wrote:

Yes that looks right to me

On Sun, May 7, 2023, 11:21 PM Mauricio Caceres Bravo < @.***> wrote:

@jonathandroth https://github.com/jonathandroth In the snippet here https://github.com/pedrohcgs/CS_RR#auxiliary-functions, shouldn't betahat=beta instead of beatahat=es$att.egt?

— Reply to this email directly, view it on GitHub https://github.com/pedrohcgs/CS_RR/issues/1#issuecomment-1537553228, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6EXFDEAZ2Q3XYN3ZLCKELXFAN7FANCNFSM5MV4ERLA . You are receiving this because you were mentioned.Message ID: @.***>

mcaceresb commented 1 year ago

@davidmacolisa You can use the functions as defined here instead.

@jonathandroth See #4

pedrohcgs commented 1 year ago

I will double check but the function we created there seems to eliminare the reference period within the function.

On Sun, May 7, 2023 at 18:20 Mauricio Caceres Bravo < @.***> wrote:

@davidmacolisa https://github.com/davidmacolisa You can use the functions as defined here https://github.com/asheshrambachan/HonestDiD#staggered-timing instead.

@jonathandroth https://github.com/jonathandroth See #4 https://github.com/pedrohcgs/CS_RR/pull/4

— Reply to this email directly, view it on GitHub https://github.com/pedrohcgs/CS_RR/issues/1#issuecomment-1537565202, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABE7347WBXYVHWKMAX3UMPLXFAU37ANCNFSM5MV4ERLA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

--

Pedro H. C. Sant'Anna https://psantanna.com https://psantanna.com

davidmacolisa commented 1 year ago

Hi @pedrohcgs , @jonathandroth, @mcaceresb,

Thanks so much for your help so far. However, the error persists with a new error emerging in the "relative_magnitude" test.

#############

THE ERROR

#############

hd.smooth.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "smoothness") Warning in n * n : NAs produced by integer overflow

Error in seq.default(from = 0, to = Mub, length.out = 10) (solar.R#1577): 'to' must be a finite number Show stack trace

hd.rm.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "relative_magnitude", Mbarvec = seq(from = 0.5, to = 2, by = 0.5)) Warning in n * n : NAs produced by integer overflow

Error in { (solar.R#1563): task 1 failed - "'from' must be a finite number" Show stack trace

davidmacolisa commented 1 year ago

Hi @pedrohcgs , @jonathandroth, @mcaceresb,

Is the function "honest_did.AGGTEobj" restricted to only event study object from a panel data DF?

I replicated your exact codes, but when I adapted them to my data (repeated cross-sections) and variables, the function still returned the above error using my event study object.

I suspect it may be from the DF structure from which the ES object comes. Is it possible to modify the "honest_did.AGGTEobj" function to such objects (from repeated cross-sections DF)?

Otherwise, what alternatives do you suggest I follow?

Thanks for all your help.

mcaceresb commented 1 year ago

@davidmacolisa Some debugging advice:

davidmacolisa commented 1 year ago

Hi @mcaceresb ,

I have attached the link to the sample data https://drive.google.com/file/d/1TYhMB5SxLTZX4Zm9J6Whs0hv10VXYdDZ/view?usp=share_link. It's a repeated cross-section. Please, see if you can conduct this test. It's obvious I'm missing something. The code I ran is this https://github.com/pedrohcgs/CS_RR/issues/1#issuecomment-1537520993, with the new one as follows: hd.smooth.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "smoothness", Mbarvec = seq(from = 0.5, to = 2, by = 0.5)) hd.rm.never <- honest_did.AGGTEobj(es = agg.es.house.attgt, e = 0, type = "relative_magnitude", Mbarvec = seq(from = 0.5, to = 2, by = 0.5))

Thanks so much.

mcaceresb commented 1 year ago

@davidmacolisa EDIT: Never-mind. Had a brief lapse; debugging.

davidmacolisa commented 1 year ago

The non-controls are UqNr, solar.first.treat, House_wgt, and year. All other variables in the sample data are controls.

mcaceresb commented 1 year ago

@davidmacolisa TIL that R only has native support for 32-bit integers, which is pretty shocking tbh. Anyway, you can replace

V <- t(es_inf_func) %*% es_inf_func / (n*n)

with

V <- t(es_inf_func) %*% es_inf_func / n / n

and it would work.

@jonathandroth Apparently doing powers (e.g. n^2) automagically upgrades the type to a double, which goes up to 2^53 instead of 2^31

davidmacolisa commented 1 year ago

Thanks so much @pedrohcgs , @jonathandroth , and especially @mcaceresb. You've saved a soul today. Cheers mates.

jonathandroth commented 1 year ago

Mauricio saves several souls on a daily basis ;-)

On Mon, May 8, 2023 at 5:11 PM Davidmac Ekeocha @.***> wrote:

Thanks so much @pedrohcgs https://github.com/pedrohcgs , @jonathandroth https://github.com/jonathandroth , and especially @mcaceresb https://github.com/mcaceresb. You've saved a soul today. Cheers mates.

— Reply to this email directly, view it on GitHub https://github.com/pedrohcgs/CS_RR/issues/1#issuecomment-1538664884, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE6EXFAOYNUOYATJBJ6YTI3XFELJ5ANCNFSM5MV4ERLA . You are receiving this because you were mentioned.Message ID: @.***>