[R] Survey package

2007-09-09 Thread eugen pircalabelu
   
Hi R-users!

I have a problem with the survey package and i would be very grateful if you 
can help me.

A short example:  

stratum id weight nh Nh  y sex
 1  1  3 5 15 23   1
 1  2  3 5 15 25   1
 1  3  3 5 15 27   2
 1  4  3 5 15 21   2
 1  5  3 5 15 22   1
 2  6  4 3 12 33   1
 2  7  4 3 12 27   1
 2  8  4 3 12 29   2

 where nh is size of sample stratum and Nh the corresponding  population value, 
and  y is  metric variable.

Now if i let

 design - svydesign( id=~1, data=age, strata=~stratum, fpc=~Nh)
then weights(design)  gives me 3,3,3,3,3,4,4,4.

If i then let

x- postStratify( design, strata=~sex, data.frame(sex=c(1,2), 
freq=c(10,15)))
 the weights become 

 123456 
   78 
2.17   2.17   5.35   5.352.171.731.73   
 4.28

If i define

design - svydesign( id=~1, data=age )
x- postStratify( design, strata=~sex, data.frame(sex=c(1,2), 
freq=c(10,15)))
weights become  2 2 5 5 2 2 2 5

The question: does poststratify recognize that i have already stratified in the 
first design by stratum and then it post stratifies by sex? and why is that? 
(because i don't have the full joint distribution, the sex*stratum crossing, in 
order to apply correctly the post stratify function)
I see that Mr Lumley uses the postStratify function when the design does not 
include strata (eg from ?poststratify: 

dclus1-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc) 
rclus1-as.svrepdesign(dclus1) 
rclus1p-postStratify(rclus1, ~stype, pop.types) 

and  i use
design - svydesign( id=~1, data=age, strata=~stratum, fpc=~Nh)
x- postStratify( design, strata=~sex, data.frame(sex=c(1,2), 
freq=c(10,15)))
 
which has a first strata (stratum from svydesign) and a second strata(sex, from 
poststratify)
Is it correct to use the functions as use them or am i doing something wrong?


Thank you !

   
-
Park yourself in front of a world of choices in alternative vehicles.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R survey package again

2007-09-07 Thread eugen pircalabelu
Hi R-users!!
   
  I have some trouble with the survey pakage and i would be very glad if you 
can give me an advice.
   
  I have a sample from a survey where household were interviewed. The sample 
has 4 criteria on which the stratification was based: REGION, SIZE OF 
HOUSEHOLD, SIZE OF LOCALITY, AGE OF HEAD OF HOUSEHOLD. Since i don't have the 
whole information in each cell of the cross region*sizehh*sizeloc*age i can't 
use the postStratify function from Survey package. Is that correct? (I think so 
but i need a competent answer)
   
  The only additional info that i have is the size of a cell from a 2*2 
crossing (eg: I know the population size for all the strata defined by 
region*sizehh, region*sizeloc, sizeloc*age) so i have the behaviour of 
the population but in a 2 by 2 cross for each of these criteria.
   
  Now, i want to use this info but i don't know the proper way: 
   
  could i use the svydesign function as here 
   
  d- svydesign (id=~1, data=tabel, strata = 
c(region*sizehh,region*sizeloc.), nest=T)
   
  and then
   
  dd- poststratify(d, data.frame (region*size, region*sizeloc, ), 
population= data.frame(Nh region*sizehh, Nh region*sizeloc..)
   
   
  or raking would be better for this type of joint distribution while 
specifying  in the svydesign strata =~ region+sizehh+sizeloc+agehhh.
   
  Thank you!
  Bye!
   

   
-

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] the survey package

2007-09-06 Thread eugen pircalabelu
Good afternoon!
   
  I'm trying to use the survey package to get a better point of view for my 
data, but i need some piece of advice:
   
  i have some data from a survey which has been stratified using 2 criteria: 
region(7 values), size of locality(5 values)  Using the survey pakage how can i 
define in a correct way this design (taking into account all 4 strata not just 
one as in the Survey example) 
   
  i have tried 
   
  design- svydesign(ids=~0, strata= c(~regiune,~size_loc), data=tabel) # for 2 
criteria
   
  and got this error
   
  Error in strata[, 1] : incorrect number of dimensions
  My tabel looks like this:
   
   cod  cantitate   pondere  regiune  size_loc  
size_hhage_hhh
7405977.604  0.9962673   1  1   
3 52
74213879.362 0.8674601  1  1   
3  42
  743   7876.3220.9845403   1 1 
   4 53
7451169.084  1.1690844   11 
 3   50
  7464430.431  0.9845403   11   
   350
751 3938.161  0.9845403   1   1 
 2 39

   
   
  What does it mean and where was i wrong? 
   
  I'm sorry for taking up your time but i don't know how to fix my problem. 
Thank you!

   
-
Luggage? GPS? Comic books? 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Survey package

2007-09-06 Thread eugen pircalabelu
Good afternoon!
   
  I'm trying to use the Survey package for a stratified sample which has 4 
criteria on which the stratification is based. I would like to get the 
corrected weights and for every element i get  a weight of 1
   
  E.g: tipping
   
   design - svydesign (id=~1, strata= ~regiune + size_loc + age_rec_hhh + 
size_hh, data= tabel) 
   and then  weights(design)
   
  gives me:  1,1,1,1,1,1,1,1,1,1,1,... for each element
   
  Why is that? What do i do wrong?
  Thank you!

   
-


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.