survey_weight: survey_weight

Description Usage Arguments Value Author(s) References Examples

Description

Creates a survey design object of class list, with survey design and vector of weights as two outputs.

Usage

1
survey_weight(matrix, dataframe, ...)

Arguments

matrix

matrix object, either as a matrix or as a cbind object

dataframe

dataframe object. Probably the data frame with which you are working.

...

Arguments passed on from other functions.

Value

survey_design

Survey design object, from package survey

Author(s)

Loren Collingwood <loren.collingwood@ucr.edu>

References

Thomas Lumley, “Survey Analysis in R” <http://faculty.washington.edu/tlumley/survey/>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#NOT RUN: READ IN DATA
data (wapoll)

#NOT RUN: CREATE WEIGHT TO PROPORTIONS
weight_props_age <- weight_to(c(26.0,39.3,34.7), c("18-40","41-65","66+"))
weight_props_gender <- weight_to(c(49,51), c("Male","Female"))

#NOT RUN: CREATE PROPORTIONS FROM DATA
age_current <- gen_survey_props(wapoll$age3) #1=18-40,2=41-65,3=66+; age3
gender_current <- gen_survey_props(wapoll$gender) #0=Male, 1=Female

#NOT RUN: CREATE WEIGHT TO AMOUNT
age_weight_to <- weight_amount(weight_props_age,age_current)
gender_weight_to <- weight_amount(weight_props_gender,gender_current)

#NOT RUN: CREATE AGE*GENDER WEIGHT
age_weight_2 <- variable_weight(wapoll$age3,age_weight_to)	
gender_weight_2 <- variable_weight(wapoll$gender,gender_weight_to)	
svyd_age_gender <- survey_weight(cbind(age_weight_2,gender_weight_2),dataframe=wapoll)
names(svyd_age_gender)
svyd_age_gender$survey_design
summary(svyd_age_gender$survey_weight)

lorenc5/Rweights3 documentation built on May 29, 2019, 11:05 p.m.