Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I have data on a dependent variable y and an explanatory one, x, and want to find out if there is a non-linear relationship between theses by running regressions where the data is divided in quartiles from the lowest to the highest value of x. So for example, what is the slope of x when x lies in the first quartile, say between 0 and 4 compared to when in the second, say between 4 and 10? I´m confused on how to accomplish this in Stata. Any help would be much appreciated!
Thanks in advance
Oscar
$\begingroup$
This is a highly problematic statistical practice. Besides greatly reducing power, it actually assumes a very strange relationship between X and Y. Suppose that X was linearly related to Y and that X did not have a uniform distribution. The the proposed approach would come up with a nonlinear relationship. It does not make sense for X to relate to Y by the shape of the marginal distribution of X. A better approach would be to fit a regression spline in the original X. You are also assuming that slope changes occur at certain percentiles of X which is hard to believe.
$\begingroup$
$\endgroup$
–
$\begingroup$
$\endgroup$
–
$\begingroup$
$\endgroup$
–
$\begingroup$
$\endgroup$
–
$\begingroup$
$\endgroup$
–
$\begingroup$
Assuming you work with Stata 11 or above, so that you can easily use factor variables, you probably would want to do something like
sysuse auto, clear
xtile qprice = price , nq(4)
reg mpg c.price##i.qprice
testparm i(2/4).qprice#c.price i(2/4).qprice
If this solution is unclear, comment on it, I'll expand the explanation.
$\begingroup$
$\endgroup$
–
$\begingroup$
$\endgroup$
–
Thanks for contributing an answer to Cross Validated!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.