想研究性别和受教育年限作为交互变量对于幸福感的影响,并且做出margins图像,使用的数据是cgss2015
因变量是幸福感 自变量是性别与教育程度
编码如下:
recode a2 -8=. -3=. -2=. -1=. 1=2 2=1,gen(sex)(性别分类,1为男性,2为女性)
recode a36 -8=. -3=. -2=. -1=. 1=1 2=1 3=2 4=3 5=3,gen(是否有幸福感)(1代表不幸福、2代表一般、3代表很幸福)
recode a7a -8=. -3=. -2=. -1=. 1=0 2=0 3=6 4=9 5=12 6=12 7=12 8=12 9=16 10=15 11=16 12=16 13=20,gen(受教育年限)(0 3 6 9 12.......是受教育年限为xx年)
图像编码如下:
reg 是否有幸福感 受教育年限 sex b0.sex#c.受教育年限
margins sex, at(受教育年限=(0(1)20))
marginsplot,noci
但是却一直如下:
invalid at() dimension information;
using variable sex as a factor variable and a regular variable is not supported
请问该怎么处理这个问题