Hi Statalisters,
I am attempting to create a variable equal to the partial correlation between an IV and a DV, stratified on a categorical variable.
For models with a single IV, this has proven quite simple:
sysuse auto
egen PMcorr=corr(mpg price), by(foreign)
ta PMcorr
However, it has proven problematic to replicate this procedure with additional IVs.
The model I wish to create is functionally similar to:
sysuse auto
ta rep78, gen(rep_)
by foreign: pcorr mpg price rep_*
in that it is stratified by a categorical variable, has multiple IVs, and contains both continuous and categorical IVs. I wish to generate from this a variable equal to the partial correlation between price and mpg. Is this possible? The limited documentation on pcorr did seem promising.
Thanks in advance,
Nick
I am attempting to create a variable equal to the partial correlation between an IV and a DV, stratified on a categorical variable.
For models with a single IV, this has proven quite simple:
sysuse auto
egen PMcorr=corr(mpg price), by(foreign)
ta PMcorr
However, it has proven problematic to replicate this procedure with additional IVs.
The model I wish to create is functionally similar to:
sysuse auto
ta rep78, gen(rep_)
by foreign: pcorr mpg price rep_*
in that it is stratified by a categorical variable, has multiple IVs, and contains both continuous and categorical IVs. I wish to generate from this a variable equal to the partial correlation between price and mpg. Is this possible? The limited documentation on pcorr did seem promising.
Thanks in advance,
Nick
Comment