Skip to content

Commit 3cf6ca5

Browse files
Adding family so binomial works
1 parent fe9f1df commit 3cf6ca5

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

R/cf_data.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#' @param gg If TRUE, will use ggplot2 by calling gcf_func
1616
#' @param show_points Whether the input data points should be shown on the plot.
1717
#' If missing, is TRUE when there are more than 300 points.
18+
#' @param family The distribution/link to be used in fitting. Only available
19+
#' when fit is locfit or mgcv.
1820
#' @param ... passed to cf_func
1921
#' @importFrom utils capture.output
2022
#' @importFrom stats predict
@@ -29,6 +31,7 @@ cf_data <- function(x, y=NULL, z=NULL,
2931
fit="",
3032
gg=FALSE,
3133
show_points,
34+
family="gaussian",
3235
...) {
3336
# Function that creates a contour plot from a data set
3437
# using a Gaussian process interpolation from mlegp
@@ -80,15 +83,15 @@ cf_data <- function(x, y=NULL, z=NULL,
8083
} else if (fit == "locfit") {
8184
# browser()
8285
X <- data.frame(x, y, z)
83-
lfmod <- locfit::locfit(z ~ x + y, data=X)
86+
lfmod <- locfit::locfit(z ~ x + y, data=X, family=family)
8487
pred.func <- function(xx) {
8588
# browser()
8689
predict(lfmod, data.frame(x=xx[,1], y=xx[,2]))
8790
}
8891
} else if (fit == "gam") {
8992
# browser()
9093
X <- data.frame(x=x, y=y, z=z) # Need new names?
91-
gammod <- mgcv::gam(z ~ te(x, y), data=X)
94+
gammod <- mgcv::gam(z ~ te(x, y), data=X, family=family)
9295
print(gammod)
9396
pred.func <- function(xx) {
9497
# browser()

man/cf_data.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)