0

Let's say I have run a linear regression model that models the sugar content in a Jelly Bean as a function of its colour and weight:

lm(sugar ~ color + weight)

The summary of the above model outputs the following:

Coefficients:
              Estimate Std. Error t value Pr(>|t|)
(Intercept)    0.07934    0.28625   0.277   0.7823
   coloured    0.41976    0.09952   2.208   0.0296 *
     weight    2.54078    0.35643   7.128 1.81e-10 ***

What is the mean sugar content of a coloured Jelly Bean?

Would it be 0.07934 + 0.41976 + 2.54078? Or is it not possible to calculate without knowing the mean weight of a coloured Jelly Bean?

I would be very grateful for any help with this. Please note this is not a homework question.

  • 2
    To answer this question you would need to know the coding of the coloured variable. I’m guessing that it should have been coded as a factor classed variable and was not. – DWin Jan 08 '23 at 00:01
  • How many different colors? If only two, colored/uncolored, it does not matter if you code as a factor or as numerically zero/one, but tell us the coding – kjetil b halvorsen Jan 09 '23 at 18:22
  • See my answer at https://stats.stackexchange.com/a/602431/919 for a detailed explanation of how to find out for sure what your parameter estimates mean. We must be a little uncertain about your question, though, because your output doesn't match the code you claim produced it: the latter refers to color while the former refers to coloured. BTW, where is there any "contrast" in this question? – whuber Jan 20 '23 at 21:43

1 Answers1

1

Is difficult to decide without knowing what type of variables are involved. I suppose according to the output, that the coloured is dummy variable (TRUE/FALSE). The easiest way is to fit it into the equation of linear regression:

$$ \begin{align*} Y_i &= \beta_0 + \beta_1 x_{1,i} + \beta_2 x_{2,i} + \epsilon_i = \\ &= 0.07934 + 0.41976 \cdot \mathbb{I}\{color_i = `colored` \} + 2.54078 \cdot weight_i + \epsilon_i \end{align*} $$

and insert the necessary variables (weight, is colored). If you don't know if it is a colour pack, the result always refers to the non-coloured package. Non-coloured is reference level, and is included in intercept (beta0).