3
$\begingroup$

Beginner's question probably. I would like to know why, to measure country fixed effects, I need to subtract one from the factor variable that I would like to consider as a fixed effect.

For example, I want to consider country and year fixed effects, so my regression model is:

lm(Premium ~ Brand + factor(Country) - 1 + factor(Year) -1 + 
              Population + Employment + Inflation, data=df)

From what I understand, the -1 after each factor is due to the fact that I need to subtract one baseline country/year from which to measure the fixed effects. However, in the regression output, I get a coefficient for all 18 countries in my data. Shouldn't one country be "missing" from the list of results since it is the baseline? Instead, if the output is correct, what's the right interpretation and what is the default baseline R considers? Below is the output:

enter image description here

$\endgroup$
6
  • 3
    $\begingroup$ Ignoring factors, lm(Y ~ X - 1) would mean regress $Y$ against $X$ without an intercept term $\endgroup$
    – Henry
    Commented Feb 1, 2023 at 15:31
  • 2
    $\begingroup$ I suggest that this is off-topic as about the quirks of R syntax. Those thinking it is a valid question should wonder whether they regard questions about the quirks of syntax in any other language or software they don't use as equally acceptable. Otherwise put, the question isn't about fitting or not fitting an intercept, but about why the syntax is what it is to do that, and the explanation isn't statistical, it is an R convention for omission. $\endgroup$
    – Nick Cox
    Commented Feb 5, 2023 at 12:41
  • $\begingroup$ @NickCox I agree that it's on the border, but questions at the end frame it more to be about the statistical side "Shouldn't one country be "missing" from the list of results since it is the baseline? Instead, if the output is correct, what's the right interpretation and what is the default baseline R considers? ". A bit similar to another recent R question: Why is the Tukey's IQR not used in the R program?. The question arose from quirks in R, the meaning of -1, but is also a misunderstanding of how to make those linear regression formulas $\endgroup$ Commented Feb 5, 2023 at 17:13
  • $\begingroup$ @SextusEmpiricus I don't need to tell you that indeed questions can be borderline and that experienced members such as yourself can disagree on exactly where the border is. Your point is taken -- but at the same time asking multiple questions at once can also be a closure reason. I find that the key criterion is whether people would equally indulge a question on X, where here X is anything but R. For example, I could imagine many questions here about Stata syntax that non-Stata users would expunge with celerity, and as a Stata user I would agree too. $\endgroup$
    – Nick Cox
    Commented Feb 5, 2023 at 17:34
  • $\begingroup$ @NickCox I don't care so much about the closure, but mostly wanted to make my point. Besides my last comment, I don't believe this is much about R notation. Those symbolic notations of the structural formulas of linear models are used in a wider setting. An early description is Wilkinson and Rogers, 1973, Symbolic Description of Factorial Models for Analysis of Variance. $\endgroup$ Commented Feb 5, 2023 at 17:46

2 Answers 2

6
$\begingroup$

Original Answer

Using the -1 or 0 operator in your regression equation simply suppresses the intercept. Normally when you include a factor into your regression, the first level of your categorical factor will be the reference group, and will be used as the intercept as a result. From there, each coding of the coefficients in your model (including the factor) will be a linear combination that adjusts this intercept.

All that this accomplishes is removing the reference point and just includes the labels of each coefficient directly instead. This thread has a lot of info on this subject. I would advise against doing that unless you have a really good reason to. Kjetil's answer has some exceptions listed, but I don't think your regression would qualify.

Edit for Clarity

My answer has already been accepted, but after looking at the comments, it appears that I should make an edit to this answer. These are the formal recommendations listed in Hahn, 1977 for fitting a no-intercept model with continuous-only predictors:

enter image description here

However, in the case of a regression with a categorical factor, while you can always include an intercept by default, suppressing the intercept is not necessarily a problem. As highlighted by Sextus below in the comments:

$$ a + bx_1 + cx_2 \\ = \\ 0 + (a+b)x_1 + (a+c)x_2 $$

The coefficients therefore change numerically, but their estimates are only shifts from the original dummy-coded intercept. Therefore the interpretation of either the intercept-model or no-intercept model would have essentially the same linear solution.

Citation

$\endgroup$
9
  • $\begingroup$ "However, you have now assumed that the error term is equal to zero and as a consequence include bias into your regression." This is not the case when you have a categorical variable in the model. You don't actually remove the intercept from model because the intercept is a linear combination of the categorical variables. You only reparameterize the variables. $\endgroup$ Commented Feb 5, 2023 at 8:29
  • $\begingroup$ The part that came behind it belonged to it as well. The regression here, a case with at least one categorical variable, applies as an exception where one can choose to remove the intercept. $\endgroup$ Commented Feb 5, 2023 at 10:11
  • $\begingroup$ I'm a bit confused by this point (and that can certainly just be me being a goober), but I have edited my answer to hopefully explain my rationale a bit more. $\endgroup$ Commented Feb 6, 2023 at 3:32
  • $\begingroup$ A model with a categorical variable is effectively a model with $n$ dummy variables that encode for each category. With those dummy variables you are indirectly including an implicit intercept because it is inside the model space. If you remove an intercept of value $y_0$ then this is effectively the same as shifting all coefficients by that same value. $\endgroup$ Commented Feb 6, 2023 at 6:27
  • 1
    $\begingroup$ More precisely: It does change the coefficients in the model, but the estimates that the fitted model makes of the observations remain the same. If $x_1$ and $x_2$ are dummy variables encoding for a categorical variable, where always exactly one is equal to one and the others are zero (and thus $x_1+x_2 =1$), then $$a +b x_1+ c x_2 \\=\\ 0 + (a+b)x_1+ (a+c)x_2$$ In the case of a model without a categorical variable the intercept has indeed an influence and including or excluding it is a decision that requires good thought. But that is not the case of the question. $\endgroup$ Commented Feb 6, 2023 at 6:59
5
$\begingroup$

With the expression -1 you are not performing a subtraction of a category or a value.

It does the following instead: (from the r documentation about the formula class)

The - operator removes the specified terms, so that (a+b+c)^2 - a:b is identical to a + b + c + b:c + a:c. It can also used to remove the intercept term: when fitting a linear model y ~ x - 1 specifies a line through the origin. A model with no intercept can be also specified as y ~ x + 0 or y ~ 0 + x.

So it is defining the structural equation as being without an intercept.

This symbolic notation dates back to the late 60's early 70's when the need arrose to be able to describe equations to computer programs. An early description is found in Wilkinson and Rogers, 1973, Symbolic Description of Factorial Models for Analysis of Variance and it was used in genstat and algorithm AS 65, written in Fortran.


From what I understand, the -1 after each factor is due to the fact that I need to subtract one baseline country/year from which to measure the fixed effects.

Note that you only need to add it once and adding it after each factor is not doing anything different.

Also these baseline country/years will not be 'subtracted' when you have a model with more than one categorical variables. For example your use of factor(Year) -1 will not prevent that the dummy variable factor(Year)2012, relating to the year 2012 category which I suspect is also in your data, is not used. (I can't find a simple related example question, but this one is about it Why do output coefficients not resemble true coefficients in a linear model?)

$\endgroup$
1
  • 1
    $\begingroup$ I didn't even notice the multiple -1 operators. Good catch. $\endgroup$ Commented Feb 5, 2023 at 8:39

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