How perform anova tests after using regress in MATLAB?

2 ビュー (過去 30 日間)
EM geo
EM geo 2019 年 9 月 7 日
コメント済み: EM geo 2019 年 9 月 9 日
Hi! I'm trying to perform ANOVA analysis for a multiple regression model built using
regress
This is my model:
clc; clear; close all;
load('pred_zeros')
D = [Zero L_mean R_mean];
D(any(isnan(D), 2), :) = []; %remove NaN from matrix D
%linear regression
X =[ones(size(D(:,1),1),1),D(:,1),D(:,2)];
b = regress(D(:,3), X);
Rmean_regr = b(1) + D(:,1)*b(2) + D(:,2)*b(3);
[~,~,~,~,stats] = regress(D(:,3), X); %model statistic
I only generate model statistics using stats. How should i do?

採用された回答

Jeff Miller
Jeff Miller 2019 年 9 月 8 日
Elisa, I think this might do what you want:
%linear regression
d1 = D(:,1);
d2 = D(:,2);
d3 = D(:,3);
t = table(d1,d2,d3);
mdl12 = fitlm(t,'d3~d1+d2');
a = anova(mdl12)
  1 件のコメント
EM geo
EM geo 2019 年 9 月 9 日
exactly!! thank you!!

サインインしてコメントする。

その他の回答 (1 件)

Jeff Miller
Jeff Miller 2019 年 9 月 7 日
It's a little difficult to say because "perform ANOVA" can mean several different things with regression models.
Usually the best approach is to make comparisons among models, where you fit several different regression models and compare their SSerror's. MATLAB's 'stepwisefit' does that, so you might have a look and see whether that will answer the specific question(s) that you have.
  1 件のコメント
EM geo
EM geo 2019 年 9 月 7 日
Jeff thank you for your reply. I was seraching for ANOVA analysis to apply to regression methods and i found this link https://it.mathworks.com/help/stats/linearmodel.anova.html#bszh780-1_sep_shared-mdl
I was wondering if is it possible to apply it to regress function. Can you help me about this?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeANOVA についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by