watersilikon.blogg.se

Regress x on y stata
Regress x on y stata








regress x on y stata

regress x on y stata

Now we can perform quadratic regression using hours and hours2 as our explanatory variables and happiness as our response variable.

regress x on y stata

We can see that hours2 is simply hours squared. We can view this new variable by going to Data > Data Editor > Data Editor (Browse) along the top menu. We can do so by typing the following into the Command box: This upside down “U” shape in the scatterplot indicates that there is a quadratic relationship between hours worked and happiness, which means we should use quadratic regression to quantify this relationship.īefore we fit the quadratic regression model to the data, we need to create a new variable for the squared values of our predictor variable hours. We can see that happiness tends to increase as number of hours worked increases from zero up to a certain point, but then begins to drop lower as the number of hours worked exceeds about 30. Use the following steps to perform a quadratic regression in Stata.īefore we can use quadratic regression, we need to make sure that the relationship between the explanatory variable (hours) and response variable (happiness) is actually quadratic. So, let’s visualize the data using a scatterplot by typing the following into the Command box: You can replicate this example by typing in this exact data into Stata using Data > Data Editor > Data Editor (Edit) along the top menu. We have the following data on the number of hours worked per week and the reported happiness level (on a scale of 0-100) for 16 different people: Suppose we are interested in understanding the relationship between number of hours worked and happiness.

#REGRESS X ON Y STATA HOW TO#

This tutorial explains how to perform quadratic regression in Stata. However, when two variables have a quadratic relationship, you can instead use quadratic regression to quantify their relationship. When two variables have a linear relationship, you can often use simple linear regression to quantify their relationship.










Regress x on y stata