# Manually compute linearized standard errors of mean in survey

I am would like to manually compute the Taylor-linearized standard error and 95% confidence interval for the mean of a variable x in a survey with 1-stage primary sampling Units y and strata z. I would like to obtain the same value that I get when using the following Stata command:

svyset Y [pweight=pweight], strata(z)
svy: mean x


I would be grateful if you could show the complete formula and all the steps of the computation.

• Welcome to the site, @Mario. This appears to be a question about how to use Stata (which would be off topic here). If your question is more about standard errors for stratified sampling, please edit to clarify. – gung Oct 20 '16 at 15:09
• @gung as I read it Mario wants to know how to do manually what Stata does although in that case he should perhaps tag it [self-study] and tell us what steps he has taken so far. – mdewey Oct 20 '16 at 16:05
• The online Stata documentation in my experience has quite good descriptions of the algorithms they use in the technical appendix. For other commands, I've been able to replicate their calculated standard errors to within machine precision. I'd look through the method and formulas sections of: stata.com/manuals13/svy.pdf – Matthew Gunn Oct 20 '16 at 18:54
• Thank you very much for your advice. Yes, I would like to do understand the so-called Taylor linearization to compute the standard errors of the mean in the survey I analyze. I thought that the best way to understand would be to manually replicate the procedure. If I understand correctly, I need to apply to the mean the procedure described in "Linearized/Robust Variance Estimation" on page 188-189 of the manual stata.com/manuals13/svy.pdf, but I don't understand it.I was wondering whether somebody has an example that could make more clear all the steps involved in this estimation. Many Thanks – Mario Oct 20 '16 at 20:35
• hi, it may not be easy to decipher if you're not familiar with the R language, but the only open source algorithm that i'm aware of that will walk you through each step of manually computing TSL is within the R survey package, with source code available at cran.r-project.org/src/contrib/survey_3.31-2.tar.gz – Anthony Damico Oct 21 '16 at 12:21