Hi, dear all
As Professor LUMLEY suggest, I use the withReplicates function to comute SE of
a complex statistics here below the source I wrote :
>wi<-weights(EC2deg)
> Qratio<-function(w=wi,don=EC2,x,a1=.2,a2=.8){
> xx<-unlist(model.frame(x,don))
> Qtle <- function(p){
> oo <- order(unlist(xx))
> cum.w <- cumsum(w[oo])/sum(w)
> val <- approxfun(cum.w, xx[oo])
> val(p)
> }
>
res<-weighted.mean(xx[xx>=Qtle(a2)],w[xx>Qtle(a2)])/weighted.mean(xx[xx<=Qtle(a1)],w[xx<Qtle(a1)])
> res
> }
>svyqratio<-function(x,design,a1=.2,a2=.8){
> rval<-withReplicates(design,Qratio,x=x)
> rval
>}
When I use it, very slow e.g
> duration<-system.time(tab1<-svyqratio(~DEPUC,BootEC2))
> duration
[1] 237.73 7.24 256.81 NA NA
I know to make make it more fast I can reduce the number of replicates. I have
100 but this solution is statiscally insteresting. I want to use something like
svyby(~DEPUC,~S00Q1,BootEC2,svyqratio) . I can I modify this code source to
made it more fast ?
Processor Intel PIV, 2.66 GHz, 512MB RAM
> sessionInfo()
R version 2.4.0 (2006-10-03)
i386-pc-mingw32
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "tcltk" "base"
other attached packages:
ineq xtable foreign survey svIO R2HTML svMisc svSocket
"0.2-7" "1.3-2" "0.8-17" "3.6-4" "0.9-5" "1.58" "0.9-5" "0.9-5"
svIDE
"0.9-5"
Justin BEM
Elève Ingénieur Statisticien Economiste
BP 294 Yaoundé Cameroun.
Tél (00237)9597295.
___________________________________________________________________________
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions !
Profitez des connaissances, des opinions et des expériences des internautes sur
Yahoo! Questions/Réponses
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.