withReplicates
evaluates the statistic and produces a
replicate-based estimate of variance.withReplicates(design, theta, rho = NULL, ..., return.replicates=FALSE)
svrepdesign
)design
uses BRR weights, rho
optionally
specifies the parameter for Fay's variance estimator.theta
return.replicates=FALSE
, the weighted statistic, with the
variance matrix as the "var"
attribute. If
return.replicates=TRUE
, a list with elements theta
for
the usual return value and replicates
for the replicates.theta
is a function its first argument will be a vector of
weights and the second argument will be a data frame containing the
variables from the design object.
If it is an expression, the sampling weights will be available as the
variable .weights
. Variables in the design object will also
be in scope. It is possible to use global variables in the
expression, but unwise, as they may be masked by local variables
inside withReplicates
.svrepdesign
, as.svrepdesign
, svrVar
data(scd)
repweights<-2*cbind(c(1,0,1,0,1,0), c(1,0,0,1,0,1), c(0,1,1,0,0,1),
c(0,1,0,1,1,0))
scdrep<-svrepdesign(data=scd, type="BRR", repweights=repweights)
a<-svrepratio(~alive, ~arrests, design=scdrep)
print(a$ratio)
print(a$var)
withReplicates(scdrep, quote(sum(.weights*alive)/sum(.weights*arrests)))
withReplicates(scdrep, function(w,data) sum(w*data$alive)/sum(w*data$arrests))
Run the code above in your browser using DataLab