您只需要指定交互:
sysuse auto, clear
reg price foreign i.turn foreign#i.turn, coeflegend noheader
local coefinter 1.foreign#33.turn 1.foreign#34.turn 1.foreign#35.turn ///
1.foreign#36.turn 1.foreign#37.turn
coefplot, keep(`coefinter')
编辑:
您还可以得到所有非零系数,如下所示:
sysuse auto, clear
reg price foreign i.turn i.foreign#i.turn, coeflegend noheader
matrix A = e(b)
local namecol "`: colnames A'"
tokenize `namecol'
forvalues i = 1 / `=colsof(matrix(A))' {
local mv = A[1,`i']
if `mv' != 0 & strmatch("``i''" , "*#*") {
local coefinter `coefinter' ``i''
}
}
coefplot, keep(`coefinter')