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 版)
307
11
线性回归和方差分析
在统计学中,建模是我们主要研究的内容。模型量化了变量之间的关系,也可以让我们
做出预测。
简单线性回归是最基本的模型。它只有两个变量,用一个含有误差项的线性关系来
建模:
y
i
=
β
0
+
β
1
x
i
+
ε
i
给定数据
x
y
,我们的任务是拟合模型,即给出
β
0
β
1
的最佳估计(参见 11.1 )。
可以自然地把简单线性回归推广到多元线性回归,其中有多个变量在关系式右侧(参见
11.2 节),即:
y
i
=
β
0
+
β
1
u
i
+
β
2
v
i
+
β
3
w
i
+
ε
i
统计学家将
u
v
w
称为
预测变量
,而
y
称为
响应变量
(即因变量)。显然,只有在预
测变量和响应变量之间存在相应的线性关系时,该模型才有用,但该要求的限制性比你
想象的要灵活许多。11.12 节讨论把变量转换为一个(或者多个)线性关系,以便你可以
使用成熟的线性回归模型。
R 的美妙之处在于任何人都可以构建这些线性模型。模型由函数 lm 构建,它返回一个
模型对象。从模型对象中,我们得到回归系数(
β
i
)和回归统计量。这个操作很容易。
R 的不便之处同样是任何人都可以建立这些模型。没有要求你检查模型是否合理,更不
用说具有统计意义。在你盲目相信模型之前,应该先检验它。你需要的大部分信息都在
回归结果的汇总中(参见 11.4 ):
模型统计显著吗?
检查回归模型的汇总结果下方的
F
统计量部分。
308
11
回归系数是否显著?
检查汇总结果中回归系数的
t
统计量和
p
值,或检查它们的置信区间(参见
11.14 )。
模型是否有用? ...
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

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

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

Javier Luraschi, Kevin Kuo, Edgar Ruiz
解密金融数据

解密金融数据

Justin Pauley
数据压缩入门

数据压缩入门

Colt McAnlis, Aleks Haecky

Publisher Resources

ISBN: 9787111656814