Skip to content
Prev 366375 / 398502 Next

how to extract weighted data in "survey" package

Thank You Anthony for the message.

Why did not I get the same values in the following examples?

To get the adjusted value, should not we just multiphy by weight? For example, I multiplied "api00" by "column "pw" (mean(apistrat$api00*apistrat$pw/100)) but I did not get the same value as of survey package given. I think I did mistake. Any suggestions?




# load the survey library

library(survey)


# load the apistrat data.frame

data(api)


# look at the first six records

head(apistrat)


# look at the weight column only

apistrat$pw

# calcualet mean using raw data and afetr adjusted


svymean(~api00, dstrat)


mean(apistrat$api00*apistrat$pw/100)
Message-ID: <DM3PR13MB06523175F7F345CA8AF810BFFA6C0@DM3PR13MB0652.namprd13.prod.outlook.com>
In-Reply-To: <CAOwvMDzX6ynvk3BiEEP=wkd-b2V2om9sJ39qe0+owTE8Xbt2kA@mail.gmail.com>