3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rで重回帰式

Last updated at Posted at 2014-03-16

##課題

  • 以下のデータにおいて、配向度を温度と圧力から説明する重回帰式を求める。
No. 配向度 温度 圧力
1 45 17.5 30
2 38 17.0 25
3 41 18.5 20
4 34 16.0 30
5 59 19.0 45
6 47 19.5 35
7 35 16.0 25
8 43 18.0 35
9 54 19.0 35
10 52 19.5 40

##手法

  • Rlm関数を利用する。

##内容

  • スクリプト
stat.R
f <- c(45, 38, 41, 34, 59, 47, 35, 43, 54, 52)                     # 配向度
t <- c(17.5, 17.0, 18.5, 16.0, 19.0, 19.5, 16.0, 18.0, 19.0, 19.5) # 温度
p <- c(30, 25, 20, 30, 45, 35, 25, 35, 35, 40)                     # 圧力

data <- data.frame(f, t, p)

data.lm <- lm(f ~ t + p, data=data) # 重回帰分析

result <- data.lm$coef # 偏回帰係数
names(result) <- c("(定数項)", "温度", "圧力")
  • 実行結果(resultを表示)
> source('stat.R', encoding='utf-8')
> result
 (定数項)        温度        圧力 
-34.7129308   3.4698126   0.5330095 

参考

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?