# test of non-linearity

#### noetsi

##### Fortran must die
I am reading an interesting econometric book where the author suggests testing if non-linearity exist by specifying a quadratic term, if its significant than non-linearity exist. Obviously there are many types of non-linearity, will specifying this one term and testing its significance tell you if there is some form of non-linearity?

That seems too simple.

#### rogojel

##### TS Contributor
There is a specific test for lack of fit which uses the oposite logic. If your model is linear and the lack of fit is significant then obviously we have a nonlinearity. If the model has interaction terms for instance then the lack of fit means "more nonlinear" then what the interaction implies.

regards

#### Dragan

##### Super Moderator
Well, there are a few ways to think about this - for any given particular design. For example, the classical easy case would be Y=Performance and regressed on X=Anxiety. This case has been demonstrated - time and again - that X^2 (Anxiety^2) should be included into the regression model.

Another way to think about this is in an ANOVA/Regression context: That is, R^2 in an ANOVA context provides the Correlation Ratio (think of, say 4 groups, with 3 dummy vectors), whereas the R^2 from the regression context, with one X, provides the linear relationship between the dependent variable (Y) and X (X is quantitative). The difference between the Correlation Ratio and the R^2 from a linear regression analysis is referred to as the "Deviation from Linearity". That s aid, typically a hierarchical approach is taken to approach the problem i.e., linear, quadratic, cubic, quartic.....but seldom does research go beyond a quadratic fit.

The same can be said in the context of what is called "Trend Analysis."

And, interaction terms are also relevant in the context of an IV (X) which can be considered as a "Moderating Variable."

Summary: It's all about the context and what prior research has demonstrated for any given research topic.

Last edited:

#### hlsmith

##### Omega Contributor
Do you remember posting on the Ramsey reset test? Same concept.

#### noetsi

##### Fortran must die
There is a specific test for lack of fit which uses the oposite logic. If your model is linear and the lack of fit is significant then obviously we have a nonlinearity. If the model has interaction terms for instance then the lack of fit means "more nonlinear" then what the interaction implies.

regards
Is this box-tidwel? If so it appears that can only be used with logistic regression.

#### noetsi

##### Fortran must die
I will look at the Ramsey reset test.

Dragan there is almost no theory in the area I am working. The vocational rehabilitation literature is extremely thin on empirical methods. Think social work...

#### CowboyBear

##### Super Moderator
I am reading an interesting econometric book where the author suggests testing if non-linearity exist by specifying a quadratic term, if its significant than non-linearity exist. Obviously there are many types of non-linearity, will specifying this one term and testing its significance tell you if there is some form of non-linearity?

That seems too simple.
Yeah, it's too simple. Non-linear relationships come in many flavours other than the quadratic (including non-polynomial forms, so the Ramsey reset test isn't a complete solution either). I don't know of a general test for any kind of unmodelled linearity though.

#### spunky

##### Super Moderator
I thought one of the good things about straight up OLS regression is that one can plot the residuals and look for patterns there?

I mean it's not an exact formal test but it's definitely something nice to look at.

#### noetsi

##### Fortran must die
I don't think I have encountered non-polynomial versions.

#### noetsi

##### Fortran must die
I thought one of the good things about straight up OLS regression is that one can plot the residuals and look for patterns there?

I mean it's not an exact formal test but it's definitely something nice to look at.
You can, but my data commonly has 10,000 points or more so even plotting partial regression plots to test non-linearity (as recommended) commonly results in large blobs of data. Its not easy to see any pattern in that, which is why I was looking for a formal test.

#### Miner

##### TS Contributor
You can, but my data commonly has 10,000 points or more so even plotting partial regression plots to test non-linearity (as recommended) commonly results in large blobs of data. Its not easy to see any pattern in that, which is why I was looking for a formal test.
Have you tried sorting the residuals then sampling every ith point (say every 100th point)? I know it sounds crude, but it would get rid of the "blob" effect and allow you to see a pattern.

#### noetsi

##### Fortran must die
Have you tried sorting the residuals then sampling every ith point (say every 100th point)? I know it sounds crude, but it would get rid of the "blob" effect and allow you to see a pattern.
I have considered it many times. I was not sure if its valid to sample randomly this way to test the residuals...You appear to be saying it is.

#### Miner

##### TS Contributor
It would not be random. Sort first then sequentially sample. Remember, you are not performing a statistical test here. You are interpreting the residuals for patterns, namely curvature. This just thins out the blob.

Also, someone mentioned code for a heat map in another post. This might help you see a pattern even through the blob.

#### noetsi

##### Fortran must die
I missed you were talking about stratified sampling. Hlsmith sent me how to do heat lamps - and I got swamped. Need to go back and find that.