R Under development (unstable) (2024-10-21 r87258 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ## This is just from ?anova.rq (extended) > library(quantreg) Loading required package: SparseM > data(barro) > fit0 <- rq(y.net ~ lgdp2 + fse2 + gedy2 , data = barro) > fit1 <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2, data = barro) > > a01 <- anova(fit1,fit0) > a01 Quantile Regression Analysis of Deviance Table Model 1: y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2 Model 2: y.net ~ lgdp2 + fse2 + gedy2 Df Resid Df F value Pr(>F) 1 2 155 18.879 4.596e-08 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > fit2 <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2, data = barro, + tau = 0.75) > fit3 <- rq(y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2, data = barro, + tau = 0.25) > > a123 <- anova(fit1,fit2, fit3) Warning message: In summary.rq(x, se = se, R = R, covariance = TRUE) : 1 non-positive fis > a.123 <- anova(fit1,fit2, fit3, joint=FALSE) Warning message: In summary.rq(x, se = se, R = R, covariance = TRUE) : 1 non-positive fis > a.123 Quantile Regression Analysis of Deviance Table Model: y.net ~ lgdp2 + fse2 + gedy2 + Iy2 + gcony2 Tests of Equality of Distinct Slopes: tau in { 0.5 0.75 0.25 } Df Resid Df F value Pr(>F) lgdp2 2 481 1.0656 0.34535 fse2 2 481 2.6398 0.07241 . gedy2 2 481 0.7862 0.45614 Iy2 2 481 0.0447 0.95632 gcony2 2 481 0.0653 0.93675 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > > AE <- function(x,y) all.equal(x, y, tol = 1e-5) > ## ---------- {giving a bit more digits below} > stopifnot( + AE(100 * unname(coef(fit0)), + c(-0.74679759, 0.46539963, 0.15902838, -36.619915)) + , + AE(unlist(a01$table), + c(ndf=2, ddf=155, Tn = 18.878717, pvalue= 4.6e-08)) + , + AE(100* unname(coef( fit2 )), + c(13.103018, -1.4885239, -0.026452369, + 0.3999839, 14.526663, -13.504643)) + , + AE(100* unname(coef( fit3 )), + c(6.0860719, -0.88350554, 0.24596781, + -14.962498, 15.592489, -15.861804)) + , + AE(unlist(a123$table), + c(ndf = 10, ddf = 473, Tn = 1.80385526, pvalue=0.0575117558)) + , + AE(a.123$table[,"Tn"], + c(1.0655561, 2.6398508, 0.78623238, 0.04467014, 0.065344348)) + ) > > proc.time() user system elapsed 1.51 0.26 1.75