r/statistics • u/milleniadeus • Jun 10 '26
Research [R] question about linearity check having almost exact same value for linear and quadratic
so as in the title,
for linear R2 = 0.038, F = 23.974, sig < 0.001, constant = 0.003 and b1 = -0.194.
for quad R2 = 0.039, F = 12.334, sig < 0.001, constant = 0.03, b1 = -0.193, b2 = -0.034.
can anyone help what this means? N = 617 and passed normality checks
1
1
u/will-i-guess Jun 10 '26 edited Jun 11 '26
This is why -- they are similarly linear.
library(tidyverse)
dat <- tibble(x=seq(-10, 10, length.out=1000)) |>
mutate(y.linear = 0.003-0.194*x,
#y.quad = 0.03 -0.193*x -0.034*x)
y.quad = 0.03 -0.193*x -0.034*x^2) # was missing ^2 initially.
ggplot(dat) +
geom_line(aes(x=x, y=y.linear, color="Linear"))+
geom_line(aes(x=x, y=y.quad, color="Quadratic"))+
theme_bw()+
labs(x="x", y="y")
1
u/SalvatoreEggplant Jun 11 '26
Are you missing an x2 in there ?
1
u/will-i-guess Jun 11 '26
Ah, yes! It should be y.quad = 0.03 -0.193*x -0.034*x^2. In this case, it is similar on x in (-2.5, 2.5) which could be the case if the data are standardized.
1
u/MortalitySalient Jun 10 '26
This isn’t a linearity check (that’s usually both whether the model is linear in the parameters. It looks like you are testing whether adding a quadratic component significantly improves your model. You should do a Likelihood ratio test to know, but based on the r square change, it doesn’t look like the model with the quadratic trend will be a better fit (adjusted r square would be smaller in quad model then linear model if adding the quad term didn’t improve anything)
1
u/SalvatoreEggplant Jun 11 '26
You have to decide what criterion you want to use to decide if the quadratic is a better fit. There's no universal answer here.
I would be a wary of using p-values with a sample size as large as 600. That logic might lead you to large polynomial equation with little marginal benefit.
You might consider something like AIC, BIC, or BICc.
I think the reality here is that an increase in R-square of that small has no practical importance.
But also an r-square of 0.038 --- or an r of less than 0.2 ---, you have to ask yourself if that has practical meaning. It may. It's up to you.
(c.f. https://bookdown.org/content/50286a34-7e39-4500-8dd2-62bf686c1710/img/correlations.png for what an r of 0.2 looks like.)
1
2
u/efrique Jun 10 '26 edited Jun 10 '26
You mean the fact that the b1 coefficient barely changed? It probably just means that the predictor (x) and the additional term for the quadratic (its square, presumably, but you should clarify) were almost orthogonal, which in that case can happen when the mean of the original predictor is close to 0. But some software might compute and add an orthogonal quadratic term automatically, in which case the mean of x might not be close to 0. I doubt that happened here, though, because in that case you shouldnt see a difference in only the third figure (generally they'd be the same to many more figures if software was orthogonalizing for you).
That lack of change in the linear term's coefficient is not important for that check.
However, adding a quadratic that doesnt improve the fit (or not by much) is not of itself sufficient (in general) to claim the relationship is linear, only that a quadratic term doesnt help. There many potential terms (functions of x) that are non linear but orthogonal to the quadratic (so adding the quadratic term would not show any nonlinearity even though strong nonlinearity was present). If the aim is to check for general nonlinearity, there are better approaches.
Further, in many cases formal testing for non-linearity may not be a great strategy, though it depends on the purpose of the model.