Edit: I should provide more contexts. I am analyzing a complex survey (multistage sampling) design data. I wanted to compare a multilevel method using a MLwin and a svyset method in Stata. The actual data structure is three levels but below I am only showing as a level 1 structure to simplify. To incorporate the three level structure, I would use three levels in MLwiN and jackknife replicate weights in svyset of Stata.

I compared baseline statistics of RCT using runmlwin and svy:mean + estat sd, variance.

At the bottom of the post, you can see the results as an attachment. You see that for the unweighted version, means and the variances are the same (or very similar) for both methods. For the weighted version, you see that the variances are vastly different, while the means are the same. For example, svy: mean gives larger variances for the treatment group, while runmlwin gives the opposite.

Below are my codes for svy:mean. I am using the final weight w.

Code: Select all

```
**********************baseline statistics with descriptive analysis*****************
/////*unweighted*/////
local outcomes test1 test2 test3
foreach outcome in `outcomes' {
mean `outcome', over(treatment)
estat sd, variance
}
/////*weighted*/////
local outcomes test1 test2 test3
svyset [pweight=w]
foreach outcome in `outcomes' {
svy: mean `outcome', over(treatment)
estat sd, variance
}
```

Code: Select all

```
**********************baseline statistics with mlwin*****************
/////*unweighted*/////
***set a loop for a model for cognitive outcomes
eststo clear
local outcomes test1 test2 test3
local n : word count `outcomes'
local residuals a b c d e f g h i j k l m n o p q r s t u v w y z
forvalues i = 1/`n' {
local outcome = word("`outcomes'", `i')
eststo clear
*** treatment (F, R)
runmlwin `outcome' trt ctrl, ///
level1( HSIS_CHILDID: trt ctrl, diagonal residuals(`residual')) nopause
eststo
}
/////*weighted at level 1 only*/////
***set a loop for a model for cognitive outcomes
eststo clear
local outcomes test1 test2 test3
local n : word count `outcomes'
local residuals a b c d e f g h i j k l m n o p q r s t u v w y z
destring CHILDCOHORT, replace
forvalues i = 1/`n' {
local outcome = word("`outcomes'", `i')
eststo clear
*** treatment (F, R)
runmlwin `outcome' trt ctrl, ///
level1( HSIS_CHILDID: trt ctrl , weightvar(w) diagonal residuals(`residual')) nopause
eststo
}
```

Thank you in advance,

Sun