Skip to content

Commit

Permalink
fixed bw type options
Browse files Browse the repository at this point in the history
  • Loading branch information
rajitachandak committed Mar 20, 2024
1 parent bdfdc18 commit e420322
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 22 deletions.
18 changes: 1 addition & 17 deletions R/lpcde/R/lpbwcde.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/lpcde/R/lpcde.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions R/lpcde/tests/testthat/test-lpbwcde.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down

0 comments on commit e420322

Please sign in to comment.