MATLAB: How to set the iteration limit for the “glmfit” function

glmfititerationlimitoptionssetstatisticsStatistics and Machine Learning Toolboxstatset

How can I set the iteration limit for the "glmfit" function? The default limit is 100 and I get the following warning message after I execute the "glmfit" command:
Warning: Iteration limit reached.
> In glmfit (line 332)
How can I increase this limit to 1000?

Best Answer

You can use the "statset" function to define the options to be used in "glmfit". Iteration limit can be set by the parameter "MaxIter" as follows:
opts = statset('glmfit');
opts.MaxIter = 1000; % default value for glmfit is 100.
Then you can call "glmfit" with this options structure:
This example is taken from the "glmfit" documentation:
x = [2100 2300 2500 2700 2900 3100 ...
3300 3500 3700 3900 4100 4300]';
n = [48 42 31 34 31 21 23 23 21 16 17 21]';
y = [1 2 0 3 8 8 14 17 19 15 17 21]';
b = glmfit(x,[y n],'binomial','link','probit', 'options', opts);
Note that these above steps can also be taken to set different statistics options for a variety of functions available in the Statistics and Machine Learning Toolbox. You can refer to the following documentation for more details about what options can be set using "statset" function: