[R] 4 questions regarding hypothesis testing, survey package, ts on samples, plotting
James Reilly
reilly at stat.auckland.ac.nz
Wed Dec 19 10:50:00 CET 2007
On 19/12/07 8:39 PM, eugen pircalabelu wrote:
> 2. How can i find the median of a variable in survey package?
> a<-c(1:10)
> b<-sample(1:20, 10, replace=T)
> b1<-sample(0:1, 10, replace=T)
> c<-data.frame(a,b, b1)
> library(survey)
> design<-svydesign(id=~1, data=c)
> svymean(~b, design)
>
> svymean gives me the mean, but what function gives me the svymedian, and what function gives me the svyproportion for b1?
> I want to know the median for a metric variable and the proportion for a binomial variable ?
The svyquantile function will give you the median, e.g.
svyquantile(~b, design, 0.5, interval.type="score")
Since a proportion is just the mean of a 0/1 variable, you can use
svymean for that, e.g.
svymean(~b1, design)
HTH,
James
--
James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand
More information about the R-help
mailing list