margins, atmeans saves the means of covariates of a model in a matrix r(at), see here:
Code:
// Open data sysuse auto, clear // Run regression model (1) of no further importance qui regress mpg i.rep78 length trunk // Calculate average mpg when holding covariates at their means margins, atmeans // Matrix including the means of covariates matrix list r(at) // Save matrix under the name cov_averages matrix cov_averages = r(at)
Code:
// Run regression model (1) of no further importance for other (sub)sample qui regress mpg i.rep78 length trunk if foreign == 1
covariates at the means as included in r(at) from regression model (1), as in
Code:
margins, at(~cov_averages~) if foreign == 1
Is there a way to do this?
Thanks for your consideration
Klaus
0 Response to Using -margins- for different subsamples
Post a Comment