# Regression with independent variable as factor of 2

I have the wine data from here which consists of 11 numerical independent variables with a dependent rating associated with each entry with values between 0 and 10 (increments of 1). The dataset is split into 2: red wine and white wine. Can one make a single regression model to predict rating, i.e. for both red and white in the same time?

I have run a two independent samples t-test to check whether the rating means are equal between red and white and with a very low p-value (to the -9) they are not (the rating histograms and qqplots look normal, despite the difficulty of seeing this given the factor-like variable). Is it correct to conclude that a single linear regression model cannot be made for both wines, i.e. there should be 2 models, one for red and one for white?

Lastly, it seems that logistic regression could account for this red/white factor, even though one should perhaps fit a multinomial/ordinal logistic model; so a single model would suffice. Is this correct?

I work in R.

• Could you post the head() of your data? I have a solution, but it might take reshaping of your data. May 25, 2017 at 13:41
• A row looks like: 7.4 0.70 0.00 1.9 0.076 11 34 0.9978 3.51 0.56 9.4 5 with the last digit being the rating. I then added the type of wine as an extra factor column to allow me to do the t-test. May 25, 2017 at 20:43
• I don't follow your question. What rating are you referring to? Why would the fact that there are 2 types be a problem? May 26, 2017 at 16:29
• If you have a sample size you could test whether any of the regression coefficients for the independent variables differ significantly as a function of type of wine. If so that should be considered in your choice of models. May 26, 2017 at 21:07

You can easily make a single model, such as logistic or linear, for the red and white wine. The question is whether or not this is a reasonable approach and the answer cannot be found (credibly anyway) from comparing the average ratings or the dependent variables via a t-test.

The question is whether or not it is reasonable to assume that the dependent variables impact the rating in the same way. If the answer is yes, then simply combine the red and white data and, like you have suggested, include another binary regressor which indicates whether it is white or red.

If you believe the answer is no, then two models is best.

In the middle, if you believe there are only some regressors which impact the rating in a way that is different for red and white wines, then you can include interaction terms between your red/white binary and those regressors. This will be more efficient, of course under the assumption that we are correct about which variables have interactions, than two separate models.

If there is no theory or previous work in this domain which can help you answer these questions, then there are some numerical methods that may help, but be careful of overfitting.

You can slit you data into testing and training folds and use some cross validation technique to determine if adding certain interaction terms or two separate models entirely increases your out of sample predictions significantly. Asymptotically, you should see that your model accuracy improves out of sample with the correct model specification. But again, be careful of overfitting as this is likely to happen if you simply run every conceivable model and take the best fiiting ones. One way to combat this is to prioritize parsimony and when there is not clear advantages to adding a term, then opt for the simpler model.

On a side note, this data is likely to suffer from multicolinearity because you have relatively many, likely related regressors (especially once interaction terms are included). You may be better off using a model like Partial Least Squares or Ridge Regression.