Skip to content
Prev 156019 / 398502 Next

Complex sampling survey _ Use of survey package

On Fri, 12 Sep 2008, Ahoussou Sylvie wrote:

            
Do you mean 'fpc1 is the total number of herds'? That is what your 
svydesign() call says.
Well, we seem to have either a bug or a problem with the data.

If you do
   options(error=recover)
before the svydesign() call you can go into as.fpc() and look at the data.

As an example;

Error in as.fpc(fpc, strata, ids) :
   FPC implies >100% sampling in some strata.

Enter a frame number, or 0 to exit

1: svydesign(id = ~dnum + snum, fpc = ~fpc1 + I(pmin(fpc2, 4)), data = 
apiclus2)
2: svydesign.default(id = ~dnum + snum, fpc = ~fpc1 + I(pmin(fpc2, 4)), 
data = apiclus2)
3: as.fpc(fpc, strata, ids)
Selection: 3
Called from: eval(expr, envir, enclos)
Browse[1]> which(sampsize>popsize, arr.ind=TRUE)
     row col
22   22   2
23   23   2
24   24   2
...

Browse[1]> sampsize[22,2]
[1] 5
Browse[1]> popsize[22,2]
[1] 4
Browse[1]> ids[22,]
    dnum    snum
22  200 200.841

So in this case one of the problems is in dnum 200, snum 841, where the 
population size was specified as 4 but the sample size is 5.

 	-thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle