aL3*_*3xa 3 r nonlinear-functions
在我以前的帖子,我一直在寻找关联性比率(η或η 2我被那没有人使用了线性的GLM程序检查η感到意外)例程R..
让我们从一个简单的例子开始:你如何检查双变量相关的线性?只有散点图?
有几种方法可以做到这一点,一种方法是比较线性和非线性模型R 2,然后应用F检验来寻找它们之间的显着差异.
最后,问题是:你如何检查线性,"非格式"方式?
答案就是你所说的(比较线性模型和非线性模型).例如
model1<-lm(yv~xv)
model2<-lm(yv~xv+I(xv^2)) #Even if we restrict ourselves to the inclusion of a quadratic term, there are many curves we can describe, depending upon the signs of the linear and quadratic terms
anova(model1,model2)
Analysis of Variance Table
Model 1: yv ~ xv
Model 2: yv ~ xv + I(xv^2)
Res.Df RSS Df Sum of Sq F Pr(>F)
1 16 91.057
2 15 68.143 1 22.915 5.0441 0.0402 *
Run Code Online (Sandbox Code Playgroud)
更复杂的曲线模型是对线性模型的显着改进(p = 0.04),因此,在这种情况下,我们接受数据中存在曲率的证据.