2
$\begingroup$

Does R's glm function use randomness in any way? Exercise 8(d) in chapter 5 (section 5.4) of An Introduction to Statistical Learning (a free book) seems to indicate that it does because it has the reader change the random seed and fit a new model (with the same data).

Remark: I'm not using (and don't use) R, so I couldn't test it.

$\endgroup$
4
  • $\begingroup$ Per the documentation [1], it uses iteratively reweighted least squares (IWLS) to fit the model -- might be a place to start. [1]: stat.ethz.ch/R-manual/R-devel/library/stats/html/glm.html $\endgroup$
    – dlid
    May 11 '21 at 21:26
  • $\begingroup$ Thanks @dlid. Looks like the only place where there could be any randomness is in the initial "guess" of the approximation algorithm (as in Newton's method). R has a separate IWLS function and its documentation indicates that its implementation is from a research paper, "page 46 of Suveges (2007)". I checked that out and didn't see any obvious randomness there either. (I might've missed it.) $\endgroup$ May 11 '21 at 22:26
  • $\begingroup$ Try running it twice with the same inputs and see if the outputs are identical. $\endgroup$
    – Ben
    May 12 '21 at 2:11
  • $\begingroup$ Thanks @Ben. That's what I meant I cannot do when I said "I couldn't test it." $\endgroup$ May 12 '21 at 18:51
1
$\begingroup$

There is no randomness in the fitting algorithm or in the initialisation for the built-in link and family. glm accepts user-defined link/family combinations and these could in principle use randomness.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.