Note that there are some explanatory texts on larger screens.

plurals
  1. POHow is the intercept computed in the GLM fit?
    primarykey
    data
    text
    <p>I have been reading the <a href="https://svn.r-project.org/R/trunk/src/library/stats/R/glm.R" rel="nofollow noreferrer">code</a> used by R to fit a <em>generalized linear model</em> (GLM), since the source-code of R is freely available. The algorithm used is called <em>iteratively reweighted least squares</em> (IRLS), which is a fairly documented algorithm. For each iteration, there is a call to a Fortran function to solve the weighted least squares problem.</p> <p>From the end-user's viewpoint, for a logistic regression for instance, a call in R looks just like this:</p> <pre><code>y &lt;- rbinom(100, 1, 0.5) x &lt;- rnorm(100) glm(y~x, family=binomial)$coefficients </code></pre> <p>And if you do not want to use an <em>intercept</em>, either of these calls is okay:</p> <pre><code>glm(y~x-1, family=binomial)$coefficients glm(y~x+0, family=binomial)$coefficients </code></pre> <p>However, I cannot manage to understand how the <em>formula</em>, i.e. <code>y~x</code> or <code>y~x-1</code>, is making sense in the code and being understood as for whether to use an intercept or not. I was looking for a part of the code where a column of ones would be bound to <code>x</code>, but it seems there is none.</p> <p>Thanks.</p> <p>PS: As far as I have read, the boolean intercept which appears in the function called <code>glm.fit</code> is not the same as the intercept which I am referring to. And it is the same for the <em>offset</em>.</p> <p>The documentation about <code>glm</code> and <code>glm.fit</code> is <a href="http://sekhon.berkeley.edu/stats/html/glm.html" rel="nofollow noreferrer">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload