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

misleading error message when r=0 and method=gsynth #43

Open
MatthieuStigler opened this issue Oct 15, 2024 · 0 comments
Open

misleading error message when r=0 and method=gsynth #43

MatthieuStigler opened this issue Oct 15, 2024 · 0 comments

Comments

@MatthieuStigler
Copy link

I am facing an error when using fect(..., CV = TRUE, r = 0) :

Cross validation cannot be performed since available pre-treatment records of treated units are too few. So set r.cv = 0.

But it seems this has nothing to do with the pre-treatment periods, but with how r is specified, since setting r = c(0, 5) will work with the same dataset?

Also, the help file says:

r: an integer specifying the number of factors. If CV = TRUE, the cross validation procedure will select the optimal number of factors from r to 5.

But it seems it is rather a range of integers with CV=TRUE?

Thanks!

reprex

library(fect)
#> Registered S3 method overwritten by 'GGally':
#>   method from   
#>   +.gg   ggplot2

data(fect)

out_fect <- fect(Y ~ D + X1 + X2, data = simdata1, 
                 index = c("id","time"), force = "two-way", method="gsynth",
                 CV = TRUE, r = 0) 
#> Cross-validating ...
#> Criterion: Mean Squared Prediction Error
#> Interactive fixed effects model...
#> Cross validation cannot be performed since available pre-treatment records of treated units are too few. So set r.cv = 0.
#> 
out_fect <- fect(Y ~ D + X1 + X2, data = simdata1, 
                 index = c("id","time"), force = "two-way", method="gsynth",
                 CV = TRUE, r = c(0, 5)) 
#> Cross-validating ...
#> Criterion: Mean Squared Prediction Error
#> Interactive fixed effects model...
#> Cross-validating ...
#> 
#>  r = 0; sigma2 = 7.60975; IC = 2.34653; PC = 7.31406; MSPE = 8.91717
#> 
#>  r = 1; sigma2 = 4.52459; IC = 2.13439; PC = 5.15203; MSPE = 6.31714
#> 
#>  r = 2; sigma2 = 3.99766; IC = 2.31368; PC = 5.26402; MSPE = 4.81494
#> *
#> 
#>  r = 3; sigma2 = 3.86501; IC = 2.57837; PC = 5.77993; MSPE = 5.07864
#> 
#>  r = 4; sigma2 = 3.74818; IC = 2.84146; PC = 6.27705; MSPE = 5.33708
#> 
#>  r = 5; sigma2 = 3.63198; IC = 3.09908; PC = 6.73553; MSPE = 5.70602
#> 
#> 
#>  r* = 2
#> 

Created on 2024-10-15 with reprex v2.1.1

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

1 participant