lmer 中使用的 B 样条中出现错误“derivs 大于 x 的长度”

Ben*_*Ben 5 r lme4

我用Rstudio。根据https://stats.stackexchange.com/questions/135694/using-b-splines-within-a-linear-mixed-effects-model-in-r我想将所谓的 b-splines 添加到我的型号:

\n\n
degree<- 3\nfit<- lmer(log(log(Amplification)) ~ bs(poly(Voltage, degree)) + bs(poly(Voltage, degree) | Serial_number),data = APD))\n
Run Code Online (Sandbox Code Playgroud)\n\n

但这会导致

\n\n
Error in splineDesign(Aknots, x, ord) : \n  length of \'derivs\' is larger than length of \'x\'\nIn addition: Warning messages:\n1: In Ops.factor(poly(Voltage, 3), Serial_number) :\n  \xe2\x80\x98+\xe2\x80\x99 not meaningful for factors\n2: In min(x, na.rm = na.rm) :\n  no non-missing arguments to min; returning Inf\n3: In max(x, na.rm = na.rm) :\n  no non-missing arguments to max; returning -Inf\n
Run Code Online (Sandbox Code Playgroud)\n\n

这意味着什么?当我使用

\n\n
summary(fit<- lmer(log(log(Amplification)) ~ (poly(bs(Voltage), degree)) + (poly(Voltage, degree) | Serial_number), data = APD))\n
Run Code Online (Sandbox Code Playgroud)\n\n

那么这会导致

\n\n
Error in poly(dots[[i]], degree, raw = raw, simple = raw) : \n  \'degree\' must be less than number of unique points\n
Run Code Online (Sandbox Code Playgroud)\n\n

degree=0收益率下降

\n\n
Error in poly(dots[[1L]], degree, raw = raw, simple = raw && nd > 1) : \n  \'degree\' must be at least 1\n
Run Code Online (Sandbox Code Playgroud)\n\n

如何将 b 样条线添加到 lmer 中?\n提前谢谢您!

\n