# Re: st: adjusted R2 in survey regression

 From Steven Samuels To statalist@hsphsun2.harvard.edu Subject Re: st: adjusted R2 in survey regression Date Wed, 15 Oct 2008 11:11:35 -0400

Below is a do-file which will calculate the adjusted R-square and related statistics after -svy: reg-. The statistics are computed as temporary variables and are displayed with Nick Cox's -dlist- command, downloadable from SSC. Be sure to zap gremlins in your text editor before running the code. I agree with Maarten that theory- based choice of predictors is a necessity.
```
-Steve

**************************CODE BEGINS**************************
/* Program to Compute Adjusted R Square for -svy: reg- */
capture program drop _all

webuse nhanes2, clear
svy : reg weight height
predict double resid, residual

```
svy: mean weight resid // substitute the response variable for "weight" here"
```tempvar v1 v2 sd1 sd2 adjr2

gen `v1' = e(N)*el(e(V_srs),1,1)
gen `sd1' = sqrt(`v1')
gen `v2' = e(N)*el(e(V_srs),2,2)
gen `sd2' = sqrt(`v2')

label var `v1' "Est Pop Variance"
label var `v2' "Est Residual Var"
label var `sd1' "Est Pop SD"
label var `sd2' "Est Resid SD"

format `v1' `v2' `sd1' `sd2' `adjr2' %10.1f

```
dlist `v1' `v2' `sd1' `sd2' `adjr2' in 1, name(0) // -dlist- by Nick Cox from SSC
```***************************CODE ENDS***************************

On Oct 15, 2008, at 4:35 AM, Maarten buis wrote:

```
```--- "Aca N.T." <acant29@gmail.com> wrote:
```
```I'm puzzled with model building using -svy: reg- for there is no
Is there an alternative test for this?
```
```
Yes, it's called theory. Add the variable in whose effect you are
interested and add variables you think influence both the variable of
interest and the dependent variable. Do _not_ add variables that are
influenced by the variable of interest and in turn influence the
dependent variable. In other words add confounding variables but not
intervening variables.

-- Maarten

```
```*
*   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/
```