I want to plot an interaction effect among two variables.
margins SentiSat_Rounded#PriceReduction
I get the following error:
'SentiSat_Rounded' not found in list of covariates
r(322);
The variables are present in the dataset. Also if the variable is not present in the dataset it throws a different error, like
variable X not found
Can you please suggest what is meant by not present in list of covariates?
To find covariates I came across this code: program covars, rclass version 8
capture local Covars : colnames e(b)
if _rc error 301
tempname b
mat `b' = e(b)
tokenize `Covars'
local k = 0
forval j = 1/`= colsof(`b')' {
if "``j''" != "_cons" & `b'[1,`j'] != 0 {
local covars "`covars'``j'' "
local ++k
}
}
if `k' {
di as txt "{p}`covars'{p_end}"
return local covars "`covars'"
c_local covars "`covars'"
}
end
I ran
covars
after that .. in the list of covariates, the above variable is not listed .. Is that list of covariates different from the variables in my dataset? How does Stata determine what is a covariate?
margins
command can only be used after some estimation, such asregress
. Are you estimating first? – Kyle Heuton