You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using augment.merMod with data/newdata with missing values (sometimes) gives a warning, even when the missing values are in unused variables. It seems like calculation of .mu, .offset and remaining columns to the right is related to the problem.
library(lme4)
#> Loading required package: Matrix
library(broom.mixed)
d<-sleepstudyd$a<-1d$a[10] <-NAfm1<- lmer(Reaction~Days+ (Days|Subject), d)
augment(fm1)
#> # A tibble: 180 × 14#> Reaction Days Subject .fitted .resid .hat .cooksd .fixed .mu .offset#> <dbl> <dbl> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>#> 1 250. 0 308 254. -4.10 0.229 0.00496 251. 254. 0#> 2 259. 1 308 273. -14.6 0.170 0.0402 262. 273. 0#> 3 251. 2 308 293. -42.2 0.127 0.226 272. 293. 0#> 4 321. 3 308 313. 8.78 0.101 0.00731 283. 313. 0#> 5 357. 4 308 332. 24.5 0.0910 0.0506 293. 332. 0#> 6 415. 5 308 352. 62.7 0.0981 0.362 304. 352. 0#> 7 382. 6 308 372. 10.5 0.122 0.0134 314. 372. 0#> 8 290. 7 308 391. -101. 0.162 1.81 325. 391. 0#> 9 431. 8 308 411. 19.6 0.219 0.106 335. 411. 0#> 10 466. 9 308 431. 35.7 0.293 0.571 346. 431. 0#> # … with 170 more rows, and 4 more variables: .sqrtXwt <dbl>, .sqrtrwt <dbl>,#> # .weights <dbl>, .wtres <dbl># .mu is NA when `a` is NA
augment(fm1, data=d)
#> Warning in indices[which(stats::complete.cases(original))] <- seq_len(nrow(x)):#> number of items to replace is not a multiple of replacement length#> # A tibble: 180 × 15#> Reaction Days Subject a .fitted .resid .hat .cooksd .fixed .mu#> <dbl> <dbl> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>#> 1 250. 0 308 1 254. -4.10 0.229 0.00496 251. 254.#> 2 259. 1 308 1 273. -14.6 0.170 0.0402 262. 273.#> 3 251. 2 308 1 293. -42.2 0.127 0.226 272. 293.#> 4 321. 3 308 1 313. 8.78 0.101 0.00731 283. 313.#> 5 357. 4 308 1 332. 24.5 0.0910 0.0506 293. 332.#> 6 415. 5 308 1 352. 62.7 0.0981 0.362 304. 352.#> 7 382. 6 308 1 372. 10.5 0.122 0.0134 314. 372.#> 8 290. 7 308 1 391. -101. 0.162 1.81 325. 391.#> 9 431. 8 308 1 411. 19.6 0.219 0.106 335. 411.#> 10 466. 9 308 NA 431. 35.7 0.293 0.571 346. NA <- .mu and all columns to the right is now NA#> # … with 170 more rows, and 5 more variables: .offset <dbl>, .sqrtXwt <dbl>,#> # .sqrtrwt <dbl>, .weights <dbl>, .wtres <dbl>d$a<-NA# We do not get the warning, but .mu is now all NA
augment(fm1, data=d)
#> # A tibble: 180 × 15#> Reaction Days Subject a .fitted .resid .hat .cooksd .fixed .mu#> <dbl> <dbl> <fct> <lgl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>#> 1 250. 0 308 NA 254. -4.10 0.229 0.00496 251. NA#> 2 259. 1 308 NA 273. -14.6 0.170 0.0402 262. NA#> 3 251. 2 308 NA 293. -42.2 0.127 0.226 272. NA#> 4 321. 3 308 NA 313. 8.78 0.101 0.00731 283. NA#> 5 357. 4 308 NA 332. 24.5 0.0910 0.0506 293. NA#> 6 415. 5 308 NA 352. 62.7 0.0981 0.362 304. NA#> 7 382. 6 308 NA 372. 10.5 0.122 0.0134 314. NA#> 8 290. 7 308 NA 391. -101. 0.162 1.81 325. NA#> 9 431. 8 308 NA 411. 19.6 0.219 0.106 335. NA#> 10 466. 9 308 NA 431. 35.7 0.293 0.571 346. NA#> # … with 170 more rows, and 5 more variables: .offset <dbl>, .sqrtXwt <dbl>,#> # .sqrtrwt <dbl>, .weights <dbl>, .wtres <dbl>
Using
augment.merMod
with data/newdata with missing values (sometimes) gives a warning, even when the missing values are in unused variables. It seems like calculation of.mu
,.offset
and remaining columns to the right is related to the problem.Created on 2022-03-03 by the reprex package (v2.0.0)
Session info
The text was updated successfully, but these errors were encountered: