Skip to content

Commit 7acc9b7

Browse files
Adding locfit in cf_data
1 parent a0cbcad commit 7acc9b7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

R/cf_data.R

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cf_data <- function(x, y=NULL, z=NULL,
5454
if (fit == "mlegp") {
5555
co <- capture.output(mod <- mlegp::mlegp(X=data.frame(x,y),Z=z,verbose=0))
5656
pred.func <- function(xx) {mlegp::predict.gp(mod,xx)}
57-
} else {
57+
} else if (fit %in% c("lagp", "")) {
5858
X <- data.frame(x, y)
5959
da <- laGP::darg(list(mle=TRUE), X=X)
6060
ga <- laGP::garg(list(mle=TRUE), y=z)
@@ -64,6 +64,16 @@ cf_data <- function(x, y=NULL, z=NULL,
6464
dab=da$ab, gab=ga$ab, verb=0, maxit=1000)
6565

6666
pred.func <- function(xx) {laGP::predGPsep(mod1, xx, lite=TRUE)$mean}
67+
} else if (fit == "locfit") {
68+
# browser()
69+
X <- data.frame(x, y, z)
70+
lfmod <- locfit::locfit(z ~ x + y, data=X)
71+
pred.func <- function(xx) {
72+
# browser()
73+
predict(lfmod, data.frame(x=xx[,1], y=xx[,2]))
74+
}
75+
} else {
76+
stop(paste0("fit is unknown"))
6777
}
6878

6979
minx <- min(x);maxx <- max(x);miny <- min(y);maxy <- max(y)
@@ -76,4 +86,4 @@ cf_data <- function(x, y=NULL, z=NULL,
7686
} else {
7787
cf_func(fn0 = pred.func,xlim=xlim,ylim=ylim, pts=cbind(x,y), batchmax=500, ...)
7888
}
79-
}
89+
}

0 commit comments

Comments
 (0)