Skip to content

Commit

Permalink
fix issue #1536
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-buerkner committed Aug 9, 2023
1 parent 93e4842 commit b7c2bec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/data-predictor.R
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ data_sp <- function(bterms, data, data2, prior, index = NULL, basis = NULL) {
# take information from original data
Jmo <- basis$Jmo
} else {
Jmo <- as.array(ulapply(Xmo, max))
Jmo <- as.array(ulapply(Xmo, attr, "max"))
}
out[[paste0("Jmo", p)]] <- Jmo
# prepare prior concentration of simplex parameters
Expand Down
6 changes: 5 additions & 1 deletion R/formula-sp.R
Original file line number Diff line number Diff line change
Expand Up @@ -579,20 +579,24 @@ get_mo_values <- function(term, data) {
x <- eval2(term$term, data)
if (is.ordered(x)) {
# counting starts at zero
max_value <- length(levels(x)) - 1
x <- as.numeric(x) - 1
} else if (all(is_wholenumber(x))) {
min_value <- attr(x, "min")
if (is.null(min_value)) {
min_value <- min(x)
}
x <- x - min_value
max_value <- max(x)
} else {
stop2(
"Monotonic predictors must be integers or ordered ",
"factors. Error occurred for variable '", term$term, "'."
)
}
as.array(x)
x <- as.array(x)
attr(x, "max") <- max_value
x
}

# prepare 'sp_term' objects
Expand Down

0 comments on commit b7c2bec

Please sign in to comment.