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

cgr not working when BIC don't change for given lambda values #14

Open
mattocci27 opened this issue Dec 8, 2020 · 1 comment
Open

Comments

@mattocci27
Copy link

When BIC (or AIC) don't change for given lambda values (like below),

r$> sparse_fits$BIC
 [1] 221.1714 202.8500 202.8500 202.8500 202.8500 202.8500 202.8500 202.8500 202.8500 202.8500 202.8500

ecoCopula/R/cgr.R

Lines 101 to 108 in 277ab69

#then find the sweet spot by removing the 5 largest of the 10 values above
if(method=="BIC"){
sub_lam=lambda[sparse_fits$BIC<kth_largest(sparse_fits$BIC,5)]
}else if (method=="AIC"){
sub_lam=lambda[sparse_fits$AIC<kth_largest(sparse_fits$AIC,5)]
}else{
stop("lambda selection method can only be \"AIC\" or \"BIC\" ")
}

the above lines do not return sub_lam (i.e., sub_lam will be numeric(0)), and subsequent codes will not work properly. This happened some of my datasets.

Currently, I put large lambda values and make completely sparse matrices (identity matrix) for those bad estimates. Because most of the case, the target matrix become completely sparse at the beginning of changing lambda.
https://github.com/mattocci27/ecoCopula/blob/4439a2f1575bcd486b641a9562780a9445932bee/R/cgr.R#L113-L116

I would be willing to start on a PR if maintainers support the idea. I would also appreciate if you could implement a more efficient way to search lambda values.

@gordy2x
Copy link
Owner

gordy2x commented Dec 15, 2020

Thanks, I will look at it when I come back to work in mid Jan.

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