残差二乗和

22 views (last 30 days)
Sho Sanuka
Sho Sanuka on 9 Jan 2020
Answered: Hiro Yoshino on 10 Jan 2020
プロットした図にそのデータの近似直線の追加とその近似直線とデータの残差二乗和をもとめるにはどうしたら良いでしょうか。
  1 Comment
Kenta
Kenta on 9 Jan 2020
こちらの下のほうに、近似直線の式や残差についての記述があります。これに沿って実行すればできると思います。

Sign in to comment.

Answers (2)

michio
michio on 9 Jan 2020
が一番手っ取り早いかと思います。ご参考まで。

Hiro Yoshino
Hiro Yoshino on 10 Jan 2020
(x, y)データが入ったtableデータを用意します (variable name は x, yとかにします)
linear_model = fitlm(table, "y~x");
plot(linear_model)
で直線がピッと引かれます。
y~xの書き方はwilkinson's notationの表記といい、他にもモデルの表現の方法はありますが、覚えておくと便利です。
linear_modelはlinear modelクラスのインスタンスで、その中には色々と情報が入っていますので
properties(linear_model)
とやってみてみてください。統計量や推定したパラメータの信頼区間等も見つかります。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!