wine <- read.csv(“winequality-white.csv”, sep = “;”) head(wine) str(wine)
mlr_wine <- lm( quality ~ fixed.acidity + volatile.acidity + citric.acid + residual.sugar + chlorides + free.sulfur.dioxide + total.sulfur.dioxide + density + pH + sulphates + alcohol, data = wine )
summary(mlr_wine)
caseA <- data.frame( fixed.acidity = 7, volatile.acidity = 0.27, citric.acid = 0.36, residual.sugar = 20, chlorides = 0.045, free.sulfur.dioxide = 45, total.sulfur.dioxide = 170, density = 1.001, pH = 3.0, sulphates = 0.45, alcohol = 11.5 )
caseB <- data.frame( fixed.acidity = 6.5, volatile.acidity = 0.30, citric.acid = 0.34, residual.sugar = 10, chlorides = 0.050, free.sulfur.dioxide = 30, total.sulfur.dioxide = 140, density = 1.002, pH = 3.2, sulphates = 0.40, alcohol = 9.0 )
predA <- predict(mlr_wine, newdata = caseA) predB <- predict(mlr_wine, newdata = caseB)
predA predB ## Final Comments
This activity applied linear regression to the white wine dataset to understand how chemical properties influence wine quality. The results show that variables such as alcohol, volatile acidity, and residual sugar play an important role in predicting wine quality. Linear regression provides an interpretable and effective way to analyze relationships between predictors and the response variable.