[R] Pseudo R squared for quantile regression with replicates
Donia Smaali Bouhlila
sma.ali at fsjegj.rnu.tn
Thu Sep 18 16:53:50 CEST 2014
Hi,
I am a new user of r software. I intend to do quantile regressions with
complex survey data using replicate method. I have ran the following
commands successfully:
mydesign
<-svydesign(ids=~IDSCHOOL,strata=~IDSTRATE,data=TUN,nest=TRUE,weights=~TOTWGT)
bootdesign <- as.svrepdesign(mydesign,type="auto",replicates=150)
fit<-
withReplicates(bootdesign,quote(coef(rq(Math1~Female+Age+calculator+computer+desk+
+
dictionary+internet+work+Book2+Book3+Book4+Book5+Pedu1+Pedu2+Pedu3+Pedu4+Born1+Born2,tau=0.5,weights=.weights,
method="fn"))))
I want get the pseudo R squared but I failed. I read a query dating from
August 2006, [R] Pseudo R for Quant Reg and the answer to it:
rho <- function(u,tau=.5)u*(tau - (u < 0))
V <- sum(rho(f$resid, f$tau))
I copied it and paste it , replacing f by fit I get this error message:
Error in fit$resid : $ operator is invalid for atomic vectors, I don't
know what it means
The fit object is likely to be quite complicated I used str() to see
what it looks like:
str (fit)
Class 'svrepstat' atomic [1:19] 713.24 -24.01 -18.37 9.05 7.71 ...
..- attr(*, "var")= num [1:19, 1:19] 2839.3 10.2 -122.1 -332.4 -42.3
...
.. ..- attr(*, "dimnames")=List of 2
.. .. ..$ : chr [1:19] "(Intercept)" "Female" "Age" "calculator" ...
.. .. ..$ : chr [1:19] "(Intercept)" "Female" "Age" "calculator" ...
.. ..- attr(*, "means")= Named num [1:19] 710.97 -24.03 -18.3 9.39
7.58 ...
.. .. ..- attr(*, "names")= chr [1:19] "(Intercept)" "Female" "Age"
"calculator" ...
..- attr(*, "statistic")= chr "theta"
How can I retrieve the residuals?? and calculate the pseudo R squared??
Any help please
--
Dr. Donia Smaali Bouhlila
Associate-Professor
Department of Economics
Faculté des Sciences Economiques et de Gestion de Tunis
More information about the R-help
mailing list