Skip to Content
R 錦囊妙計
book

R 錦囊妙計

by Paul Teetor
January 2014
Beginner to intermediate
488 pages
8h 1m
Chinese
GoTop Information, Inc.
Content preview from R 錦囊妙計
288
|
第十章
延伸資訊
錦囊 10.22 關於繪製其他分配的 Q-Q 圖;錦囊 11.15 關於應用常態 Q-Q 圖來診斷線性
迴歸。
10.22 繪製其他分配的 Q-Q
問題點
您想要繪製非常態分配資料的分位數圖(Q-Q )。
解決方案
當然,您必須對資料的基本分配有些概念。此錦囊的解決方案主要包括下列步驟:
使用
ppoints
函數產生一個介於 0 1 之間的點序列。
將這些點轉換為分位數,應用分位數函數於假設的分配上。
對樣本資料進行排序。
對已排序的資料點與計算出的分位數繪製散佈圖。
使用
abline
函數繪製對角斜線。
假設您的資料
y
t
分配,自由度為 5;之前的章節提過,
t
分配的分位數函數為
qt
,其
第二個引數為自由度。因此,上述步驟可使用兩行 R 程式碼執行:
> plot(qt(ppoints(y), 5), sort(y))
> abline(a=0, b=1)
討論說明
此錦囊的解決方案看似複雜,其實不然;前述 R 程式碼的結構如下所示:
> plot(quantileFunction(ppoints(y), ...), sort(y))
> abline(a=0, b=1)
其中,
quantileFunction
是指假設分配的分位數函數,而
...
代表
quantileFunction
數除了
y
之外所需的參數。此外,使用
abline
函數可沿著對角線繪製一直線。理想情況
下,所有的資料點會剛好落在直線附近。
舉例來說,若從平均值為 10(或比例為 1/10
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

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

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

J.D. Long, Paul Teetor
優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769829