You are on page 1of 2

cd "C:\Users\H\Desktop"

log using 31Oct_2Nov2016.log


*QUADRATIC MODELS
use "C:\Users\H\Desktop\AppEcon1\hprice2.dta", clear
generate rooms2=rooms^2
gen ldist=log(dist)
reg lprice lnox ldist rooms rooms2 stratio
* As the number of rooms changes from 3 to 4, price is predicted to change by
display 100*(_b[rooms]+2*_b[rooms2]*3)
*Finding the turning point
display -_b[rooms]/(2*_b[rooms2])
*Graphing functions in STATA
*Our command to graph functions is "twoway function"
*Some examples
twoway function y=x, range(0 10)
twoway function y=x^3, range(-2 2)
*Depicting price-room realtionship:
reg lprice lnox ldist rooms rooms2 stratio
sum rooms
twoway function y=_b[_cons]+_b[rooms]*x+_b[rooms2]*x*x, range(0 8)
*The part of the graph less than 3.56 is useless for us.
*Because there is no counterpart in our sample.
**As the number of rooms changes from 5 to 6, price increases by 7.5%.
*Notice that here, change in rooms is 1.
display 100*(_b[rooms]+2*_b[rooms2]*5)
**Going rooms 5 to 7, change in rooms is 2.
display 100*(_b[rooms]+2*_b[rooms2]*5)*2
**Quadratic Models: Example 2
use "C:\Users\H\Desktop\AppEcon1\wage1.dta", clear
regress wage exper expersq
display -_b[exper]/(2*_b[expersq])
twoway function y=_b[_cons] + _b[exper]*x+_b[expersq]*x*x, range(5 35)
tab exper
***The regression above implies that exper has a diminishing marginal effect on
wage.
* Experience of 73% workers in the sample is less than 25.
* So it is rational to focus on that part of this graph.
*The first year of experience is worth approximately $0.298.
*The second year of experience is worth less:
disp _b[exper]+2*_b[expersq]*0
disp _b[exper]+2*_b[expersq]*1
*If exper changes from 10 to 11, wage is predicted to change by:
disp _b[exper]+2*_b[expersq]*10
**DUMMY VARIABLES
reg wage female
*How to interpret coefficient estimate on female:
*the difference in hourly wage between females and males,
* given the same amount of education (and the same error term u).
* Is there gender discrimination against women in the labor market?
*If the coeff. estimate on female is less than 0.
*Then we will be able to say that given the same level
*of education female workers earn less than male workers on average.
* This can easily be tested using t-statistic.
sum wage if female
sum wage if female==0
reg wage female married
*Using female and married we can separate workers into 4 groups
* and define dummy variables for these groups as follows:
gen marmale=married*(1-female)
gen marfem=married*(female)

gen singfem=(1-married)*(female)
gen singmale=(1-married)*(1-female)
*marrmale is the dummy for the married male workers, marrfem married female work
ers,
*singfem: single female workers and singmale is the single male workers.
*Need to choose one of these as the base group
*so that we include 4 -1 = 3 dummies in the model to avoid the dummy variable tr
ap.
*Suppose that the base group is singmale.
reg wage marmale marfem singfem
sum wage if female==0 & married==0
*Of course, we can add other control variables to the regression such as exper,
tenure.
reg wage marmale marfem singfem educ exper expersq tenursq tenure
*Storing regression results and constructing tables
reg wage marmale marfem singfem
*After the regression, let's store the results of this regression and name it re
g1
estimates store reg1
reg wage marmale marfem singfem educ exper expersq tenursq tenure
estimates store reg2
*Now present the results of these regressions in a table,
*b:coefficient estimates, se: standart errors.
*b(%8.4f) is about the font of the output.
estimates table reg1 reg2, b se t p stats(N r2) b(%8.4f)

You might also like