我用
Rstudio
。根据https://stats.stackexchange.com/questions/135694/using-b-splines-within-a-linear-mixed-effects-model-in-r我想添加所谓的b样条线进入我的 lmer 模型:
degree<- 3
fit<- lmer(log(log(Amplification)) ~ bs(poly(Voltage, degree)) + bs(poly(Voltage, degree) | Serial_number),data = APD))
但这会导致
Error in splineDesign(Aknots, x, ord) :
length of 'derivs' is larger than length of 'x'
In addition: Warning messages:
1: In Ops.factor(poly(Voltage, 3), Serial_number) :
‘+’ not meaningful for factors
2: In min(x, na.rm = na.rm) :
no non-missing arguments to min; returning Inf
3: In max(x, na.rm = na.rm) :
no non-missing arguments to max; returning -Inf
这是什么意思?当我使用时
summary(fit<- lmer(log(log(Amplification)) ~ (poly(bs(Voltage), degree)) + (poly(Voltage, degree) | Serial_number), data = APD))
然后这会导致
Error in poly(dots[[i]], degree, raw = raw, simple = raw) :
'degree' must be less than number of unique points
下降到
degree=0
收益率
Error in poly(dots[[1L]], degree, raw = raw, simple = raw && nd > 1) :
'degree' must be at least 1
如何将 B 样条线添加到 lmer 中? 预先感谢您!
在回归中使用尺度(VAR)后,这发生在我身上。当我在上一步中使用 mutate(CVAR=scale(VAR, center=TRUE, scale=TRUE) 缩放变量时,ggpredict 给出了正确的估计。