sysuse auto
reg price weight rep78
现在想计算在rep78取值为其mean时,各个weight取值的predicted y,并生成新变量yhat(类似于predict yhat,但是rep78不是每个观察值的实际rep78取值,而是whole sample中rep78的mean)
1. margins weight, atmeans错误,因为这个命令要求weight是factor variable,数据库中weight是连续变量
2. margins, at((asobs) weight) atmeans得出来的是weight=mean时的predicted y,不是weight实际取值的
另外请教如何让这个predicted y 成为一个新变量yhat
非常感谢!