ANOVA with a known linear model

4 ビュー (過去 30 日間)
Clare
Clare 2015 年 8 月 7 日
コメント済み: Brendan Hamm 2015 年 8 月 10 日
I want to use ANOVA function to generate a report for a multiple linear regression model. ANOVA takes the input of LM, a linear model class, which can be created using fitlm function. My question is that since the model is already determined including the coefficients and the predictors, can I input my model somehow in ANOVA without having to run fitlm function? In other words, how can I create a LM class with my own coefficients?
Thanks in advance.

回答 (1 件)

Ghada Saleh
Ghada Saleh 2015 年 8 月 10 日
Hi Claire,
As you have mentioned, ANOVA only accepts an input of type Linear Model which can be constructed using 'fitlm' or 'stepwiselm'. If you already have the coefficients of your linear model, you can use them to generate data for the dependent variable given your independent variable values. As an example:
x = rand(1,10); % you can replace with your independent variable values.
y = 5*x+12; % replace by your linear model;
lm = fitlm(x,y);
Now 'lm' is a Linear Model object that will estimate the coefficients '5,12'. Given enough number of samples, 'fitlm' will estimate your model and create Linear Model object that you can then input to ANOVA.
I hope this helps,
Ghada
  1 件のコメント
Brendan Hamm
Brendan Hamm 2015 年 8 月 10 日
Or you could just use the anova1() function, or anova2(), etc.

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

カテゴリ

Help Center および File ExchangeAnalysis of Variance and Covariance についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by