Reputation: 2617
I'm using fitlm to test a linear model:
mdl = fitlm(tbl,'GPA ~ 1 + HSRANK + SATV + SATM')
When using the function disp(mdl)
, the following output appears:
My question is, where are stored the F-statistic vs. constand model and the p-value? I suppose they should be stored in the the mdl lineal model, but I can't find them.
Upvotes: 1
Views: 1879
Reputation: 7297
The most common test statistics are available from within LinearModel object, but this is not the case for the F-statistic. Rather you can access it with coefTest or for a more elaborate view anova.
Let us have a look at this reproducible example (a classic from MathWorks):
% Load some standard data
load imports-85
ds = dataset(X(:,7),X(:,8),X(:,9),X(:,15),'Varnames',{'curb_weight','engine_size','bore','price'});
mdl = fitlm(ds,'price~curb_weight+engine_size+bore')
% Show
fit
Now use coefTest
for your specific question:
[p,F] = coefTest(mdl)
% Output
% p =
% 1.1416e-47
% F =
% 135.5791
Also see what MathWorks writes about Assess Fit of Model Using F-statistic.
Upvotes: 2