28.07.2014 Views

Linear Regression

Linear Regression

Linear Regression

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

This gives rise to the following plot:<br />

salary<br />

0 5 10 15 20 25<br />

1980 1985 1990 1995 2000<br />

year<br />

The relationship between year and highest salary is moderately strong, positive<br />

and curved. Since the scatter plot shows a curved relationship, a linear model is<br />

not appropriate. However, it appears that taking the logarithm of salary may help<br />

straighten the plot. We can generate a new variable named logsalary, which is<br />

the logarithm of the variable salary, by typing:<br />

generate logsalary = log(salary)<br />

We can make a scatter plot of this new variable against year by typing<br />

scatter logsalary year<br />

This gives rise to the following plot:<br />

logsalary<br />

0 1 2 3<br />

1980 1985 1990 1995 2000<br />

year<br />

It appears that the transformation has significantly straightened the scatter plot.<br />

We can now proceed with fitting a linear regression model to the transformed<br />

data by typing:<br />

regress logsalary year<br />

Note that now the response variable is logsalary instead of salary.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!