Skip to Content
R 语言经典实例(原书第 2 版)
book

R 语言经典实例(原书第 2 版)

by J.D. Long, Paul Teetor
June 2020
Beginner to intermediate
522 pages
9h 6m
Chinese
China Machine Press
Content preview from R 语言经典实例(原书第 2 版)
线性回归和方差分析
357
出什么结论呢?起初,他很高兴家庭作业看起来如此有效。然后他突然意识到这是统计
推理中的一个典型错误:他认为“相关性暗示着因果关系”。事实并非如此。也许有很
强动机的学生在家庭作业和考试中表现良好,而懒惰的学生则都表现不好。在这种情况
下,因果关系的因子是动机的程度,而不是布置作业这一明智选择。最后,他只能得出
一些非常简单的结论:完成作业的学生可能会在期中考试中取得好成绩,但他仍然不知
道为什么。
11.25 运用方差分析比较模型
11.25.1 问题
有两个针对相同数据的模型,而你想知道它们是否产生不同的结果。
11.25.2 解决方案
anova 函数可以比较两个模型并报告它们是否有显著差异:
anova(m1, m2)
这里,m1 m2 都是 lm 返回的模型对象。anova 的输出包括一个
p
值。通常,
p
值小于 0.05 表示模型显著不同,而超过 0.05 的值表明没有这样的证据。
11.25.3 讨论
11.3 节中,我们使用 anova 函数打印一个回归模型的方差分析表。现在我们使用双
参数形式来比较两个模型。
在比较两个模型时,anova 函数有一个强烈的要求:一个模型必须包含在另一个模型中。
也就是说,较小模型的所有项必须出现在较大的模型中。否则,比较是不可能的。
方差分析执行
F
检验,类似于线性回归的
F
检验。不同之处在于该检验比较两个模型,
而回归
F
检验比较使用回归模型和不使用模型。
假设我们通过增加预测变量的方式对 y 构建了三个模型:
load(file = './data/anova2.rdata') ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

机器学习实战:基于Scikit-Learn、Keras 和TensorFlow (原书第2 版)

Aurélien Géron
大规模数据分析和建模:基于 Spark 与 R

大规模数据分析和建模:基于 Spark 与 R

Javier Luraschi, Kevin Kuo, Edgar Ruiz
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey

Publisher Resources

ISBN: 9787111656814