[R-sig-ME] nlme::gls() outputting behavior for missing data
@|m@h@rme| @end|ng |rom gm@||@com
Fri Jan 14 03:25:09 CET 2022
In my `data` below, some combinations of `teaching_level:time` are missing.
When I use `nlme::gls()`, such missingness causes singularity, hence an
error stopping the entire model from being fit.
When I use `lm()`, such missingness causes NA only for the missing
combinations, but the model fits fine.
I wonder which behavior is more reasonable, specifically, assuming the
model specification is 100% accurate:
1- Is the `gls()` error really related to singularity or missingness?
2- NA coefficients aside, are the non-NA coefficients of `lm()` valid?
3- Is there a way for `gls()` to output the results like lm() and not stop?
######## Reproducible code:
data <- read.csv("https://raw.githubusercontent.com/fpqq/w/main/1.csv")
res1 <- lm(gi ~ 0 + teaching_level*time, data = data, na.action = "na.omit")
Coefficients: (3 not defined because of singularities)
Estimate Std. Error t value
teaching_levelelementary:timePost-test 2 NA NA NA
teaching_levelmixed:timePost-test 2 NA NA NA
teaching_levelsecondary:timePost-test 3 NA NA NA
res2 <- gls(gi ~ 0 + teaching_level:time, data = data, na.action =
Error: computed "gls" fit is singular, rank 10
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models