Here's an example:
library(visreg)
my_data <- data.frame(
x = runif(100),
y = rnorm(100),
g = letters[1:10] |> rep(10),
w = runif(100)
)
fit <- glm(y ~ x + g, data=my_data, weights= w)
visreg(fit, "x")
#> Error in eval(extras, data, env): object 'w' not found
Currently, visreg converts characters to factors and updates the model, but it can't update the model if it doesn't have the weights.
This issue does not arise if the character variable is turned into a factor before being passed to the model (no update triggered):
library(visreg)
my_data <- data.frame(
x = runif(100),
y = rnorm(100),
g = letters[1:10] |> rep(10),
w = runif(100)
)
my_data$g <- factor(my_data$g)
fit <- glm(y ~ x + g, data=my_data, weights= w)
visreg(fit, "x")
# No error
Here's an example:
Currently,
visregconverts characters to factors and updates the model, but it can't update the model if it doesn't have the weights.This issue does not arise if the character variable is turned into a factor before being passed to the model (no update triggered):