{smcl}
{hline}
help for {hi:brrmodel}
{hline}

{title:Model estimates with balance repeated replication (BRR) based standard errors}

{p 8 15}{cmd:brrmodel} {it:varlist} [{it:weight}]
	[{cmd:if} {it:exp}] [{cmd:in} {it:range}] [{cmd:,} 
	{cmdab:brrw:eight(}{it:varlist}{cmd:)} {cmd:fay(}{it:#}{cmd:)} 
	{cmd:deff} {cmd:deft}
	{cmd:cmd(}{it:command name}{cmd:)}
	{cmdab:l:evel(}{it:#}{cmd:)} {cmdab:dof(}{it:#}{cmd:)} {cmd:or} {it:command_options} ]


{p}{cmd:pweight}s are allowed; see help {help weights}.  Analysis weights are required, and
must be specified with the command, or by the {help svyset:svyset pweight} command.


{title:Description}

{p}{cmd:brrmodel} estimates regression-type models for complex survey data. 
Standard errors are calculated using a series of user-supplied replication weights, by the
balanced repeated replication (BRR) method.  This is an alternate method to
the Taylor series linearization methods used by Stata's {help svy:svy-based} commands.

{p}It will run ols regression, logit/probit, ordered logit/probit, multinomial
logit, and poisson regression models.


{title:Options}

{p 0 4}{cmd:brrweight()} specifies the list of variables that contain the replicate weights
for the dataset.  The standard errors for the model are based on the variation in 
the estimates generated across the various weights.

{p 4 4}A set of {cmd:brrweights} is required for the analysis.  Once the brrweights are specified
they are stored as a {help char:characteristic} of the dataset and need not be respecified in subsequent command.

{p 0 4}{cmd:fay()} specifies the k value that should be used for weighting the estimates, based
on Fay's method.  The default is zero, meaning that simple averaging will be used.  As with the replicate weights,
the value for fay() is stored as a characteristic of the dataset once it is specified, and need not be
re-specified in subsequent commands.

{p 0 4}{cmd:dof()} specifies the degrees of freedom for model fit and t-statistics.  The default is
to use the number of replications.

{p 0 4}{cmd:deff} and {cmd:deft} request that design effects deff and deft be displayed with the model
estimates.  See {cmd:[R] svymean} for details.

{p 0 4}{cmd:cmd()} specifies the model estimation command.  
Valid options are {help regress} {help logit} {help probit} {help logistic} 
{help oprobit}, {help ologit}, {help mlogit} and {help poisson}.  The default is ols regression.

{p 0 4}{cmd:or} specifies that coefficients from a logit model should be displayed as odds-ratios.  See {help logit}.


{title:Example command and output}

{p 8 12}{inp:. brrmodel income region sex asset [pw=wgt] , brrw(bwgt*)} {p_end}

{txt}        OLS estimates with BRR-based standard errors

{txt}        Analysis weight:      wgt{col 48}Number of obs       ={res}{ralign 10:1904}
{txt}        Replicate weights:    bwgt*{txt}{col 48}Population size     ={res}{ralign 10:10738}
{txt}        Number of replicates: 20{txt}{col 48}Degrees of freedom{col 68}={res}{ralign 10:20}
{txt}        k (Fay's method):     0.000{txt}{col 48}F({res}{ralign 4:3}{txt},{res}{ralign 7:18}{txt})     ={res}{ralign 10:86.40}
{txt}        {col 48}Prob > F{col 68}={res}{ralign 10:0.0000}
{txt}        {col 48}R-squared{col 68}={res}{ralign 10:0.0057}{txt}

        {hline 13}{c TT}{hline 64}
              income {c |}      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        {hline 13}{c +}{hline 64}
              region {c |}{res}   .6214526    .116294     5.34   0.000     .3788676    .8640376
        {txt}         sex {c |}{res}  -1.121041   .2671536    -4.20   0.000    -1.678313   -.5637684
        {txt}       asset {c |}{res}   .1274654   .0077771    16.39   0.000     .1112427    .1436881
        {txt}       _cons {c |}{res}   37.61598   .5194737    72.41   0.000     36.53238    38.69959
        {txt}{hline 13}{c BT}{hline 64}


{title:Saved Results}

{cmd:brrmodel} is an estimation command, so it saves model estimates and brr-based (co)variance 
matrix in e(b) and e(V) and creates e(sample) to reflect the estimation sample.  It also stores design effects
in e(deff) and e(deft), and the simple-random-sampling-without-replacement (co)variance matrix in e(V_srs).

{p}{help svytest} will estimate adjusted Wald linear hypothesis tests after BRR model estimation.  
({cmd:brrmodel} specifies the estimation command as "svybrrmodel" in order to allow {cmd:svytest} to function.)

Scalars e(N_strata) and e(N_psu) are set in order to allow {cmd:svytest} to operate correctly.  N_strata
is set to the degrees of freedom for the model (by default the number of replicates), and N_psu is set to twice the
degrees of freedom.

{help predict} after an estimation should work as documented for the relevant command.  {input}Warning: this
has not been tested extensively{txt}.


{title:Methods and formulae}

{p}Point estimates are calculated using aweights, and are identical to those produced by Stata's svy-based
commands.  The variance matrix of the estimates is formed by calculating

                   G    
		V = c * SUM [ (B - B(i))(B - B(i))' ]
                  i=1

{p}where B is the estimated coefficient vector based on the full sample weights, B(i) is the estimated coefficient vector using the i'th set of replicate weights, G is the number of replicates, and c is a constant defined as:

         1 / G            for standard BRR (i.e. fay==0), or

         1 / (G*(1-k)^2)  for Fay's method.


{title:Acknowledgements}

{p}I would like to thank Bobby Gutierrez at StataCorp for advice on implementation of BRR.


{title:Author}

	Nick Winter
	Cornell University
	nw53@cornell.edu

