Hello,

I'm trying to estimate a semi-parametric regression model with (1) a continuous and a categorical variable interacting in the basis function and (2) a continuous parametric regressor. I then want to plot predicted probabilities using margins. However, when specifying covariate values at which to estimate predicted probabilities, margins does not recognize the continuous regressor specified in the asis() option as a covariate:
Code:
sysuse auto, clear
npregress series price mpg i.foreign, asis(weight)
margins, over(foreign) at(mpg = (15 (5) 40) weight = 3000)
The problem does not occur with categorical variables specified in the asis() option:
Code:
gen group = mod(_n, 2) == 0
npregress series price mpg i.foreign, asis(weight i.group)
margins, over(foreign) at(mpg = (15 (5) 40) group = 1)
Most curiously, the problem also disappears if the categorical variable is removed from the basis function:
Code:
npregress series price mpg, asis(weight i.foreign)
margins, over(foreign) at(mpg = (15 (5) 40) weight = 3000 foreign = 1)
How can I specify the values of a parametric (i.e. asis) continuous variable when calculating margins for an npregress model?