I want to include in a multiple linear regression model, the interaction between categorical variables. I have three categorical variables: CO2 (0,1) Temperature (0,1) Soil (1,2,3)

But when i interact: SoilxCO2; SoilxTemp, SOilxCO2xTemp i get the attached output.

Could i be coding the variables wrongly? Thanks! enter image description here

  • $\begingroup$ The response variable is log transformed. Depending on the interaction included the model works. $\endgroup$ – Katrina Mar 24 '15 at 11:54
  • $\begingroup$ I have updated the output when including all categorical variables and interactions. $\endgroup$ – Katrina Mar 24 '15 at 12:09
  • 1
    $\begingroup$ In what sense do you think the model works? Incidentally, what software is this that reports $r^2 > 2 * 10^{19}$ and negative $F$? (And much else that is impossible or implausible.) Such results are utterly wrong in principle and the software on this evidence should be avoided as dangerous for any statistical purpose. (I find the output difficult to read and would rather believe that I am not seeing what I think I am seeing.) $\endgroup$ – Nick Cox Mar 24 '15 at 12:18
  • $\begingroup$ Yes i agree. I am using SAM, ecoevol.ufg.br/sam $\endgroup$ – Katrina Mar 24 '15 at 12:28
  • 1
    $\begingroup$ That software is not known to me, but whatever its uses for other purposes, this is just standard regression and any standard statistical software is very strongly recommended as a check. Be clear: the results are so nonsensical that you must regard the software you used as demonstrated to be unreliable for any such purpose. Can you post the data? $\endgroup$ – Nick Cox Mar 24 '15 at 12:53

Too long for comment and I am listing my suggestions here. There are still some major problems about the data and without looking at the data myself I can't tell what is wrong. My gut sense is some of your predictors could have been a constant or nearly so: that is little or no variation in that predictor. The one thing I am sure is that this is wrong: for example, $R^2$ is bounded between 0 and 1; it cannot be more than $2 \times 10^{19}$.

So, here are suggestions for you to revise the question further or communicate with a statistician:

It would be helpful to start with just a few independent variables, presumably the major one that you're interested in and then slowly add variables and observe if anything changes. The model may collapse like this after the addition of a certain independent variable; by adding them incrementally you have a better chance to figure out which one is wrong.

Examine the relationship between the dependent and each of the independent variables carefully, using both statistics (linear regression, t-test) and graphs (box plot, scatter plot, etc.)

The interaction term is still not correctly specified. If we want to model a 3-level categorical variable (like Soil), the model should have 2 indicators. (k levels in a categorical variable result in (k-1) indicators.) So, to model Soil, it should be:

$y = \beta_0 + \beta_1 \text{SoilLv2} + \beta_2 \text{SoilLv3}$

assuming we are using Level 1 as the reference group. To further put interaction into it, the model will become:

$y = \beta_0 + \beta_1 \text{SoilLv2} + \beta_2 \text{SoilLv3} + \beta_3 \text{CO2} + \beta_4 (\text{SoilLv2} \times\text{CO2}) + \beta_5(\text{SoilLv3} \times\text{CO2})$

Finally, the software output is really weird. I will be worried that some software will still produce output even nearly everything is wrong. I'd recommend cross-checking it with other software.

Overall, there are too many items to address, so I'd strongly recommend you to bring your data to a statistician and work this out.


What is the purpose of your study? There is nothing wrong necessarily with what you did. However, if you only have 3 soil categories in your data (as opposed to 4), then it's usually a better idea to use a full-rank parametrization of your model matrix by creating two dummy variable for example for soil: $x_{soil1}$ = 1 if the soil is of type 1, 0 otherwise; and $x_{soil2}$ = 1 if the soil is of type 2, 0 otherwise.

Using a full rank parameterization allows you to examine the individual coefficients and to draw conclusions from them. Without a full rank parameterization, you would need to take estimable linear combinations of your estimated coefficients in order to get any sensical results.

My guess is that you are using a less than full rank model matrix, which results in non-unique estimated coefficients and this is why you are seeing some weird output.


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.