Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# st: Regression with errors on dependent and independent variables

 From Nicholas Hall To "statalist@hsphsun2.harvard.edu" Subject st: Regression with errors on dependent and independent variables Date Tue, 14 Aug 2012 12:44:35 -0700

```Dear Stata users,

I'm wondering if I could get some help with how to do a regression in which both my dependent and independent variables have errors.  I'm aware of regression with aweights but aweights only assign a relative weight to each data point (i.e., the relative size of the errors) whereas I want give the absolute size of the errors.  Here is a concrete example in which the dependent and independent variables are averages and thus their errors are simply the standard error of the means.

Say I have a distribution of x and y values for a set of groups defined by the categorical variable group and I calculate the means and standard deviations of each of these groups as follows:
. collapse (mean) meanx=x (sd) sdx=x (count) nx=x (mean) meany=y (sd) sdy=y (count) ny=y, by(group)

So now each observation corresponds to a group of observations and I calculate the standard error of the mean for each group:
gen semx = sdx/nx
gen semy = sdy/ny

Now I would like to run the regressing taking into consideration the errors for each group which may be quite different for different groups.  In my ideal world I would just do something like:
reg y x, [yerror=semy] [xerror=semx]

Nicholas

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```