Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_ci.lmer is not robust to formula types #43

Open
andercolin opened this issue Jul 10, 2019 · 0 comments
Open

add_ci.lmer is not robust to formula types #43

andercolin opened this issue Jul 10, 2019 · 0 comments

Comments

@andercolin
Copy link

andercolin commented Jul 10, 2019

Trying add_ci on a model with a formula involving I(...), i.e.

library(ciTools)
library(lme4)

data <- data.frame(x = c(1, 2, 3, 4), y = c(1, 3, 10, 15), gr = (1, 1, 2, 2))
mod <- lmer(y ~ I(x^2) + (1|gr), data)
add_ci(data, mod)

results in Error in x^2: non-numeric argument to binary operator. Attempting add_ci(data, mod, type = "parametric") results in Error in `[[<-.data.frame`(`*tmp*`, names[1], value = numeric(0)) : replacement has 0 rows, data has 4. The code completes in other cases, but returns spurious confidence intervals and the warning longer object length is not a multiple of shorter object length. At least in the parametric case, the problem appears to be in get_x_matrix_mermod.

Trying add_ci on a model with no fixed effects, i.e.

data <- data.frame(x = rep(seq(5), 2), y = c(rnorm(5), rnorm(5, mean = 0.5)), gr = c(rep(1, 5), rep(2, 5)))
mod <- lmer(y ~ (1 | gr), data)
data %>% add_ci(mod, type = "parametric")

results in Error in reformulate(attributes(terms(fit))$term.labels) : 'termlabels' must be a character vector of length at least one. Again, the problem appears to be in get_x_matrix_mermod.

@andercolin andercolin changed the title add_ci.lmer fails or returns invalid results for models with formulas involving I(...) add_ci.lmer is not robust to formula types Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant