* Equivalent models and not-equivalent models, with interaction terms
clear all
set seed 142016
set obs 12
generate tenure = (_n-1)/2
expand 2, generate(married)
generate wage = 7 + 1*tenure + 0.5*married + 0.5*tenure*married + rnormal()
regress wage c.tenure##married // model 1, full factorial
predict w1
separate w1, by(married)
twoway (scatter wage tenure) (line w10 w11 tenure), name(full)
regress wage c.tenure##b1.married // same as model 1, changed base
regress wage i.married c.tenure#married // also the same as model 1, "nested"
regress wage c.tenure c.tenure#married // not the same model, now model 2
// one intercept and two slopes - the second intercept has been constrained
// to equal the first
predict w2
separate w2, by(married)
twoway (scatter wage tenure) (line w20 w21 tenure), name(nodummy)
graph combine full nodummy, cols(1)
regress wage c.tenure#married // same as model 2
regress wage c.tenure#1.married // yet another model, almost certainly an error?
// one intercept and one non-zero slope, but using all the data
// here "both" intercepts are constrained to be equal, and the slope of
// the second group is constrained to be zero.
predict w3
separate w3, by(married)
twoway (scatter wage tenure) (line w30 w31 tenure)
regress wage tenure if married==0