From e4203223d156fdca6346e5bfb6c448b36f2834bd Mon Sep 17 00:00:00 2001 From: Rajita Chandak Date: Wed, 20 Mar 2024 11:53:14 -0400 Subject: [PATCH] fixed bw type options --- R/lpcde/R/lpbwcde.R | 18 +----------------- R/lpcde/R/lpcde.R | 2 +- R/lpcde/tests/testthat/test-lpbwcde.R | 4 ---- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/R/lpcde/R/lpbwcde.R b/R/lpcde/R/lpbwcde.R index af56209..45ad77e 100644 --- a/R/lpcde/R/lpbwcde.R +++ b/R/lpcde/R/lpbwcde.R @@ -198,7 +198,7 @@ lpbwcde <- function(y_data, x_data, x, y_grid=NULL, p=NULL, q=NULL, grid_spacing } else { bw_type = tolower(bw_type) bw_type = bw_type[1] - if (!bw_type%in%c("mse-rot", "imse-rot", "mse-dpi", "imse-dpi")){ + if (!bw_type%in%c("mse-rot", "imse-rot")){ stop("Incorrect bandwidth selection method specified.\n") } } @@ -235,27 +235,11 @@ lpbwcde <- function(y_data, x_data, x, y_grid=NULL, p=NULL, q=NULL, grid_spacing }else if(bw_type == "imse-rot"){ bw = bw_irot(y_data=y_data, x_data=x_data, y_grid=y_grid, x=x, p=p, q=q, mu=mu, nu=nu, kernel_type=kernel_type, regularize=regularize) - }else if(bw_type == "mse-dpi"){ - if(d ==1){ - bw = bw_mse(y_data=y_data, x_data=x_data, y_grid=y_grid, x=x, p=p, q=q, mu=mu, nu=nu, kernel_type=kernel_type) - }else{ - stop("this method is not implementable yet") - } - - }else if(bw_type == "imse-dpi"){ - if(d==1){ - bw = bw_imse(y_data=y_data, x_data=x_data, y_grid=y_grid, x=x, p=p, q=q, mu=mu, nu=nu, kernel_type=kernel_type) - }else{ - stop("this method is not implementable yet") - } - # stop("this method is not implementable yet") }else { stop("Invalid bandwidth selection method provided.") } - # scaling back - # bw = bw BW = matrix(NA, ncol=3, nrow=ng) BW[, 1] = y_grid diff --git a/R/lpcde/R/lpcde.R b/R/lpcde/R/lpcde.R index d3b94ea..2d122ae 100644 --- a/R/lpcde/R/lpcde.R +++ b/R/lpcde/R/lpcde.R @@ -266,7 +266,7 @@ lpcde = function(x_data, y_data, y_grid=NULL, x=NULL, bw=NULL, p=NULL, q=NULL, bw = lpbwcde(y_data=y_data, x_data=x_data, x=x, y_grid=y_grid, p=p, q=q, mu=mu, nu=nu, kernel_type=kernel_type, bw_type=bw_type)$BW[,2] } - if (!bw_type%in%c("mse-dpi", "imse-dpi", "mse-rot", "imse-rot")) { + if (!bw_type%in%c("mse-rot", "imse-rot")) { stop("Incorrect bandwidth selection method specified.\n") } } else if (length(bw) == 1) { diff --git a/R/lpcde/tests/testthat/test-lpbwcde.R b/R/lpcde/tests/testthat/test-lpbwcde.R index d66f831..960ca6c 100644 --- a/R/lpcde/tests/testthat/test-lpbwcde.R +++ b/R/lpcde/tests/testthat/test-lpbwcde.R @@ -14,10 +14,6 @@ test_that("lpbwcde default output", { model1 = lpbwcde(x_data=x_data, y_data=y_data, x=0, bw_type = "mse-rot") expect_equal(model1$opt$bw_type, "mse-rot") - model1 = lpbwcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=0, bw_type = "mse-dpi") - expect_equal(model1$opt$bw_type, "mse-dpi") - model1 = lpbwcde(x_data=x_data, y_data=y_data, y_grid=y_grid, x=0, bw_type = "imse-dpi") - expect_equal(model1$opt$bw_type, "imse-dpi") }) test_that("lpbwcde multivariate default output", {