How to get the sum of squares in GLM model summary ?

I want to calculate the % of variance explained by each variable in a GLM, for that I need the summ of square. Can we get it from the fitglm function output ?

 Accepted Answer

You can get SST, SSE and SSR:
mdl = fitglm(rand(100, 2), randi([0 1], 100, 1), 'dist', 'binomial', 'link', 'logit');
mdl.SSE
ans = 23.9711
mdl.SSR
ans = 1.0278
mdl.SST
ans = 24.9900

3 Comments

thank you, but actally what I need is an ANOVA table as described here for lm : https://fr.mathworks.com/help/stats/linearmodel.anova.html
however, in my case the anova doesn't work :
modelspec = 'PSD_0_100Hz ~ Tide*Temperature*Salinity';
g = fitglm([Prof_BBG Temperature_BBG Salinite_BBG],Band_PSD_BBG_1_interp, modelspec, 'VarNames', {'Tide', 'Temperature', 'Salinity','PSD_0_100Hz'})
anova(g)
I get this message : "Check for incorrect argument data type or missing argument in call to function 'anova'."
You cannot use anova on a GLM, but only an LM. The link you provided is the same. I assume your response is continuous, so you can use fitlm. Also, it's easier if you share your data.
Indeed, the response is continuous, and using fitlm I can use anova
Thank you !

Sign in to comment.

More Answers (0)

Asked:

on 6 Apr 2022

Commented:

on 8 Apr 2022

Community Treasure Hunt

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

Start Hunting!