1
0

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 2019-08-22

備忘録的なメモです。

回帰モデルを作成します。

y = b_0 + b_1x \\\

A1:説明変数
A2:目的変数
DF:データフレーム

Model1 <- lm(A2 ~ A1, DF)

作成した回帰モデル(Model1)から係数を取り出す方法はこんな感じ。

a <- Model1$coefficients #回帰係数の値を取り出す

表示方法はこんな感じ

a
a[1] #1つずつ表示(b0)
a[2] #1つずつ表示(b1)

実行結果は、

実行結果
> a <- Model1$coefficients #回帰係数の値を取り出す
> a
(Intercept)          C1 
   3.667721    0.339507 
> a[1] #1つずつ表示(b0)
(Intercept) 
   3.667721 
> a[2] #1つずつ表示(b1)
      C1 
0.339507
1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?