[R] Complex sampling survey _ Use of survey package

Thomas Lumley tlumley at u.washington.edu
Fri Sep 12 06:02:27 CEST 2008


On Thu, 11 Sep 2008, Ahoussou Sylvie wrote:

> Data base = tab1 here are the five first rows of the database (nrow = 11792)
>
>
>
>
>     num
>     esp
>     Quarters
>     Totcat
>     Totshp
>     Totgt
>     Tbtpos
>     fpc1
>     Totanim
>     Id_An
>
>      10
>     2045
>     G
>     01-Q1
>     0
>     0
>     12
>     1
>     551
>     10
>     10
>
>      11
>     2046
>     G
>        01-Q1
>     8
>     0
>     60
>     1
>     551
>     11
>     11
>
>      50
>     2070
>     G
>        01-Q1
>     0
>     3
>     6
>     1
>     551
>     50
>     50
>
>      51
>     2070
>     S
>        01-Q1
>     0
>     3
>     6
>     1
>     551
>     51
>     51
>
>      52
>     2070
>     S
>     01-Q1
>     0
>     3
>     6
>     1
>     551
>     52
>     52
>
>

This has 11 data values in each row but only 10 variable names.  If we assume the first number doesn't belong it, the fpc1 column lines up correctly, so I will do that.

It is surprising that Id_An is the same as Totanim for each of these five records.

>
> - First strata = herds
>
> herd's id column = num
>
> sampled in 551 herds (column fpc1)
>
>
>
> - Second strata = animals
>
> animal id column= Id_An
>
> sampled in Totanim
>
>
>
> I tried :
>
> clustot <- svydesign (id=~num+Id_An, fpc=~fpc1+~Totanim, data=tab1)
>
This should be
   clustot <- svydesign (id=~num+Id_An, fpc=~fpc1+Totanim, data=tab1)
but that doesn't explain the problem

Your svydesign() call looks correct if fpc1 is the total number of herds in the population and Totanim is the total number of animals in the particular herd. I am not sure from your explanation whether this is how the variables are defined.

       -thomas


>
> and I get this error message
>
>
>
>> clustot <- svydesign(id=~num+Id_An, fpc=~fpc1+~Totanim, data=tab1)
>
> Erreur dans as.fpc(fpc, strata, ids) :
>
>  FPC implies >100% sampling in some strata.
>
>
>
> I don't have any strata with 100% sampling so do you know which arguments of the fonction svydesign I'm supposed to use ?
>
>
>
> Thanks in advance
>
>
>
> AHOUSSOU Sylvie
> Vétérinaire Epidémiologiste
> CIRAD Domaine Duclos
> 97 170 Petit-Bourg
> tel : 05 90 25 59 47
> 	[[alternative HTML version deleted]]
>
>

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



More information about the R-help mailing list