* this line defines the semicolon as the line delimiter;
# delimit ;
* set memork for 10 meg;
set memory 10m;
set matsize 5000;
log using psid3.log,replace;
*read in state data;
use psid1;
* generate new variables;
gen exp=age-educ-5;
gen exp2=exp*exp;
gen wage=laborinc/hours;
gen wagel=log(wage);
gen tenure2=tenure*tenure;
* label variables;
label var exp "potential experience";
label var exp2 "experience squared";
label var wage "hourly wage rate (earn/hours)";
label var wagel "log hourly wage rate";
label var tenure2 "tenure squared";
* get descriptive statistics;
sum;
* get OLS estimates;
reg wagel exp exp2 tenure tenure2 union educ black;
* now estimate a model with fixed effects;
* the xi command is used to construct a series of;
* dummy variables. suppose you have a variable ;
* x2 that has four values, 1,2,3,4. i.x2 will;
* construct a set of 3 dummy variables, one for;
* x2=1, x2=3 and x2=4.
* notice that in the within group model, you;
* must delete variables without any within-panel;
* variation. in this case, educ and black;
xi: reg wagel exp exp2 tenure tenure2 union i.id;
*sort the data by id;
sort id;
* get fixed-effect estimate by absorbing data by id;
* treats data as deviations from means to reduce number;
* of parameters to be estimated;
areg wagel exp exp2 tenure tenure2 union, absorb(id);
log close;