This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Create a random effect basis with integers rather than factors | |
#' @import mgcv | |
#' @export | |
smooth.construct.re2.smooth.spec <- function (object, data, knots) { | |
if (!is.null(object$id)) | |
stop("random effects don't work with ids.") | |
if(any(sapply(data, is.numeric))) data <- lapply(data, as.factor) ## <-- All I did was this (and below) | |
form <- as.formula(paste("~", paste(object$term, collapse = ":"), | |
"-1")) | |
object$X <- model.matrix(form, data) |