version 12.1
clear all
* Create data
matrix input Corr = (1,.7,-.56,-.28\.7,1,-.80,-.40\-.56,-.80,1,.14\-.28,-.40,.14,1)
matrix input SDs = (1,1,1,1)
matrix input Means = (0,0,0,0)
corr2data income mhealth formula death, corr(Corr) mean(Means) sd(SDs) n(100)
* I. Estimate separate regressions
reg mhealth income
reg formula income mhealth
reg death income mhealth formula
* The mis-specified model
reg death formula
* II. SEM Commands
sem (mhealth <- income) (formula <- income mhealth) (death <- income mhealth formula)
* Estimate the direct, indirect, and total effects of each variable
estat teffects
* Incorrect model
sem death <- formula
* III. UCLA's pathreg command
pathreg (mhealth income) (formula income mhealth) (death income mhealth formula)