Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rの基礎9 基本的な統計と検定
Search
xjorv
January 23, 2021
Education
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rの基礎9 基本的な統計と検定
Rの基礎9では、Rでの統計や検定の基礎について説明します。
xjorv
January 23, 2021
More Decks by xjorv
See All by xjorv
コンパートメントモデル
xjorv
3
6.1k
コンパートメントモデルをStanで解く
xjorv
0
540
生物学的同等性試験 検出力の計算法
xjorv
0
3.7k
生物学的同等性試験ガイドライン 同等性パラメータの計算方法
xjorv
0
6.7k
粉体特性2
xjorv
0
2.6k
粉体特性1
xjorv
0
3k
皮膜5
xjorv
0
2.4k
皮膜4
xjorv
0
2.3k
皮膜3
xjorv
0
2.3k
Other Decks in Education
See All in Education
新入社員を「あの子」と呼ばない運動 -PBL その前に- / Stop Calling New Hires "Kids"
aokiplayer
2
910
未踏峰連山 Frontiers: Creating and Conquering Untrodden Peaks
ishii_mit
1
160
子どものためのプログラミング道場『CoderDojo』〜法人提携例〜 / Partnership with CoderDojo Japan
coderdojojapan
PRO
4
19k
AIでアウトプットできる時代だからこそ、自分の言葉で考えることの大切さ / What's Left to Think, When AI Can Write?
masakiokuda
1
350
私たちはなんでテストするんだっけ? Ver.東北IT物産展2026 in 会津若松
camel_404
3
210
25-26 CBT Library top items
cbtlibrary
0
340
20260908_ターゲットとスコープを決める発表法
masakiokuda
1
130
組合せ最適化特論
tasusu
0
130
Adobe Express
matleenalaakso
2
8.4k
医療事務養成の専門学校でのAI教育 非エンジニアの学生にAIを1年間使ってもらって、感じたこと
naochim2026
0
140
Sanapilvet opetuksessa
matleenalaakso
1
36k
Sekolah Sabat - Triwulan 3 2026 - Pelajaran 12
hiola
0
12k
Featured
See All Featured
How to Talk to Developers About Accessibility
jct
2
560
The Language of Interfaces
destraynor
162
27k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
350
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
700
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Un-Boring Meetings
codingconduct
0
440
YesSQL, Process and Tooling at Scale
rocio
174
15k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
730
Raft: Consensus for Rubyists
vanstee
142
7.7k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
390
Transcript
Rの基礎 9 基本的な統計と検定 2020/8/15 Ver. 1.0
基本統計量 ベクトルの平均・分散・標準偏差などは関数で簡単に求まる mean sd var max min quantile sum median
平均値 標準偏差 分散 最大値 最小値 4分位値 合計 中央値
summary関数 基本統計量はsummary関数で表示できる データがあれば、とりあえずsummary関数の引数にしてみる
確率分布と乱数 Rでは、確率分布に従った乱数を簡単に得ることができる *乱数: ランダムな数のこと。乱数シミュレーションなどで利用できる runif rnorm rbinom rpois 一様分布 正規分布
二項分布 ポアソン分布
確率分布のグラフ histやggplot2のgeom_densityを用いる *平均0、標準偏差1の正規乱数200000個を生成し、ヒストグラムや確率密度関数にしたもの
相関係数 相関係数も相関行列もcor関数で得られる
直線回帰 直線回帰はlm関数で計算できる • Rでは、Y~Xという表現で2数の関係を示す • Yが従属変数、Xが説明変数となる • Interceptは切片、説明変数の数字は傾きとなる 切片 傾き
直線回帰の詳しい情報 回帰の結果をsummary関数の引数に取る 切片と傾き 切片と傾きの検定結果 *検定では傾きや切片が有意にゼロから離れていることを示す
重回帰分析 重回帰もlm関数で計算できる • 説明変数を+でつなぐだけ • +を*に変えると、交互作用を計算できる
平均の差の検定: t検定 t検定は、t.test関数で実行できる t.test(1つ目の集団, 2つ目の集団)で計算できる これがp値 Welchは等分散でないときのt検定の拡張
平均の差の検定: ウィルコクソンの順位和検定 ウィルコクソンはt検定のノンパラメトリック*版 wilcox.test(1つ目の集団, 2つ目の集団)で計算できる *ノンパラメトリック: 集団が正規分布しないときに使用する検定手法。検出力が低い
分散分析 aov関数で計算できる aov(差を知りたいデータ~カテゴリデータ)で計算できる *線形回帰のlmをaovに変えただけ。summaryで情報が得られるのも同じ。+を使えば多元にできるし、*を使えば交互作用を調べられる
カテゴリデータ: factor(因子) カテゴリを示すときに因子を多用する • データフレームを読み込むと文字列は因子に変換*される • 数字に名前がついたもの • 同じ名前のものが同じカテゴリとして扱われる *stringAsFactors
= Tがデフォルトなので、read.table関数で読み込むと変換が起きる
多重比較: Tukeyの方法 総当りの比較にはTukeyの方法を用いる TukeyHSD(aovの結果)で計算できる *他にScheffeやDunnett、Kruskal-Wallis、holm、Bonferroniの方法などがある
検出力の計算 検定の検出力はpowerから始まる関数で行う power.t.test, power.prop.test, power.anova.testなどがある これが検出力
例数の計算 例数もpowerから始まる関数で計算できる これが例数
まとめ • Rには統計に関する手法・パッケージが豊富にある • カテゴリデータの扱いに因子を用いる • 「R 統計手法」で検索すれば、だいたい手法が見つかる