Skip to content

Commit

Permalink
fix drawing of Hilbert GP smooths using gratia
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Clark committed Oct 3, 2024
1 parent 0251634 commit ac39524
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/gratia_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ eval_smoothDothilbertDotsmooth = function(smooth,
n = n, n_3d = n_3d, n_4d = n_4d,
id = which_smooth(
model,
gratia::smooth_label(smooth)
smooth_label(smooth)
)
)

# by variables
by_var <- gratia::by_variable(smooth)
by_var <- by_variable(smooth)
if (by_var == "NA") {
by_var <- NA_character_
}
Expand All @@ -353,7 +353,6 @@ eval_smoothDothilbertDotsmooth = function(smooth,
by <- unlist(purrr::map(gp_att_table, 'by'))
level <- unlist(purrr::map(gp_att_table, 'level'))
gp_covariate <- smooth$term
by <- smooth$by
level <- ifelse(is.null(smooth$by.level), NA, smooth$by.level)
k <- unlist(purrr::map(gp_att_table, 'k'))
scale <- unlist(purrr::map(gp_att_table, 'scale'))
Expand All @@ -365,17 +364,17 @@ eval_smoothDothilbertDotsmooth = function(smooth,
# Which GP term are we plotting?
if(!is.na(level)){
gp_select <- which(unlist(purrr::map(gp_att_table, 'covariate')) == gp_covariate &
unlist(purrr::map(gp_att_table, 'by')) == by &
which(by %in% by_var) &
unlist(purrr::map(gp_att_table, 'level')) == level)
} else {
gp_select <- which(unlist(purrr::map(gp_att_table, 'covariate')) == gp_covariate &
unlist(purrr::map(gp_att_table, 'by')) == by)
which(by %in% by_var))
}

# Compute eigenfunctions for this GP term
X <- prep_eigenfunctions(data = data,
covariate = gp_covariate,
by = by,
by = by_var,
level = level,
k = k[gp_select],
boundary = boundary[gp_select],
Expand Down Expand Up @@ -430,6 +429,7 @@ eval_smoothDothilbertDotsmooth = function(smooth,

## identify which vars are needed for this smooth...
keep_vars <- c(smooth$term, smooth$by)
keep_vars <- keep_vars[!keep_vars %in% 'NA']

## ... then keep only those vars
data <- dplyr::select(data, dplyr::all_of(keep_vars))
Expand Down
Binary file modified src/mvgam.dll
Binary file not shown.

0 comments on commit ac39524

Please sign in to comment.