r - 涉及多项式的模型提取
问题描述
我想提取定义我的模型的函数。我正在使用lme4和 Rstudio 中的lmer函数来获取模型。我正在使用的功能如下所示:
model<-lmer(y~poly(x, 6)+ z +(1|d))
显示估计值和其他内容:
summary(model)
我假设该函数如下所示:
y~intercept+x*0.3418+x^2*-0.1.....+x^6*0.05871+z*-0.002566
如果我为 x 和 z 插入值,则预测的 y 值与它们应该达到的任何值相去甚远。当我绘制图表时,它显示了现实值。
plot(x, predict(Model))
summary(Modeltest)
Linear mixed model fit by REML. t-tests use Satterthwaite's method
Formula: sum.ARM.g.cm³.ges ~ poly(Baumalter.bei.Jahrringsbildung, 6) +
Bonität.h100.gemessen.interpoliert + (1 | Baumnummer)
REML criterion at convergence: -8023.5
Scaled residuals:
Min 1Q Median 3Q Max
-5.3263 -0.5221 -0.0344 0.6118 3.1398
Random effects:
Groups Name Variance Std.Dev.
Baumnummer (Intercept) 0.0010255 0.03202
Residual 0.0001138 0.01067
Number of obs: 1307, groups: Baumnummer, 12
Fixed effects:
Estimate Std. Error df t value Pr(>|t|)
(Intercept) 5.841e-01 4.858e-02 1.000e+01 12.024 2.87e-07 ***
poly(Baumalter.bei.Jahrringsbildung, 6)1 3.418e-01 1.114e-02 1.289e+03 30.675 < 2e-16 ***
poly(Baumalter.bei.Jahrringsbildung, 6)2 -1.066e-01 1.122e-02 1.289e+03 -9.506 < 2e-16 ***
poly(Baumalter.bei.Jahrringsbildung, 6)3 -1.467e-01 1.092e-02 1.289e+03 -13.441 < 2e-16 ***
poly(Baumalter.bei.Jahrringsbildung, 6)4 1.547e-01 1.081e-02 1.289e+03 14.305 < 2e-16 ***
poly(Baumalter.bei.Jahrringsbildung, 6)5 -6.797e-02 1.073e-02 1.289e+03 -6.334 3.30e-10 ***
poly(Baumalter.bei.Jahrringsbildung, 6)6 5.871e-02 1.072e-02 1.289e+03 5.474 5.27e-08 ***
Bonität.h100.gemessen.interpoliert -2.566e-03 1.415e-03 1.000e+01 -1.814 0.0998 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Correlation of Fixed Effects:
(Intr) p(B..J,6)1 p(B..J,6)2 p(B..J,6)3 p(B..J,6)4 p(B..J,6)5 p(B..J,6)6
pl(B..J,6)1 -0.005
pl(B..J,6)2 -0.003 0.079
pl(B..J,6)3 -0.001 0.040 0.057
pl(B..J,6)4 0.003 -0.017 0.004 0.014
pl(B..J,6)5 0.001 -0.020 -0.025 -0.011 0.002
pl(B..J,6)6 0.001 -0.012 -0.021 -0.020 -0.008 0.004
Bntth100gms -0.982 0.005 0.004 0.002 -0.003 -0.001 -0.001
我希望你们能帮助我获得一个合适的功能。
解决方案
这不是 lme4 特有的问题,它与poly()
功能有关。默认情况下poly()
创建一个正交多项式;这不一定是一个容易重构的函数。你可以试试poly(x, 6, raw=TRUE)
这会给你一个“原始”多项式的形式b0+b1*x+b2*x^2+...
这个问题详细说明了如何推导正交多项式的系数。
推荐阅读
- xamarin - Xamarin Live Player 不会一直加载共享库
- javascript - 通过 java 脚本创建 href 并添加 var
- cmd - CMD字符串变量多行输出,不加空格和回车
- asp.net-mvc - .NET Core:如何将 StreamReader 中的字符串输出为 XML
- python - 列表和任何名称中的差异名称(列表中的 s 中的名称)
- python - 计算大矩阵的均值和协方差(300000 x 70000)
- mongodb - 将 MongoDB 云与 AWS 自动缩放集成
- node.js - 将NodeJS流消耗到缓冲区并写入流的正确方法
- sapui5 - 来自 JSON 文件的聚合绑定 SAPUi5
- python - PyQt5 和 OpenCV 有类似的库;如何避免两者之间的冲突?