I have been recently trying to fit a linear model to my data. The dependent variable is continuous and the independent variable is numeric and discrete. When I first test the assumptions concerning the data structure in order to run a linear regression I observe violations of the assumptions of linearity and normality. The relationship between my independent variable and my dependent variable is nonlinear, and residuals are not normally distributed:
Here a plot of the relationship between y and x (plus a line of predicted values using a linear regression):
Here some plots to test linearity and normality assumptions:
After that, I tried unsuccessfully to linearize the relationship between the variables by transforming the data (by doing log(y); log(x); sqrt(y). etc...), but I did not find any transformation that satisfactorily increased the linearity.
Thus, I decided not to run a prototypical linear regression but a polynomial regression, using a quadratic polynomial. The model that I have run is as follows:
model <- lm(y ~ x + I(x^2))
summary(model)
By running the polynomial regression I obtain the next residuals and coefficients:
Residuals: Min 1Q Median 3Q Max -2.30465 -0.65161 0.01504 0.60506 1.95826 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 2.3617770 0.0036701 643.52 <2e-16 *** x -0.0508341 0.0014057 -36.16 <2e-16 *** I(x^2) -0.0062881 0.0001141 -55.12 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.8663 on 739197 degrees of freedom Multiple R-squared: 0.1781, Adjusted R-squared: 0.1781 F-statistic: 8.007e+04 on 2 and 739197 DF, p-value: < 2.2e-16
Here a plot of the polynomial fitting the data:
Some questions:
1) By running a linear regression (y~x) I get R2=0.1747. When running the quadratic regression I get R2=0.1781. Giving this R2 and giving that there is a violation of the linearity assumption: should I keep the quadratic regression as a better fit of my data?
2) In a prototypical linear regression (y = b0 + b1*x) the way to read the output of x (our predictor effect or effect size) is quite straightforward: "for every increase of x by 1, the effect of x on y is b1". However, for the quadratic regression, the interpretation of the effect of x on y seems to be a bit more complicated. How could I report (read, explain) the effect of my independent variable (in the current case) in an elegant way?
I really appreciate suggestions.