diff --git a/inst-not/quantreg/ggplo2-quantreg-rqss.R b/inst-not/quantreg/ggplo2-quantreg-rqss.R new file mode 100644 index 0000000..8b3cf3d --- /dev/null +++ b/inst-not/quantreg/ggplo2-quantreg-rqss.R @@ -0,0 +1,13 @@ +library(ggplot2) + +m <- + ggplot(mpg, aes(displ, 1 / hwy)) + + geom_point() +m + stat_quantile() + +m + stat_quantile(method = "rqss") + +m + stat_quantile(method = "rqss", lambda = 0.1) + +sessionInfo() + diff --git a/inst-not/quantreg/ggpmisc-quantreg-rqss.R b/inst-not/quantreg/ggpmisc-quantreg-rqss.R new file mode 100644 index 0000000..8247ca8 --- /dev/null +++ b/inst-not/quantreg/ggpmisc-quantreg-rqss.R @@ -0,0 +1,25 @@ +library(ggplot2) +library(ggpmisc) + +p <- + ggplot(mpg, aes(displ, 1 / hwy)) + + geom_point() +p + stat_quant_line() + +p + stat_quant_line(method = "rqss") + +p + stat_quant_line(method = "rqss", lambda = 0.1) + +p + stat_quant_band() + +p + stat_quant_band(method = "rqss") + +p + stat_quant_band(method = "rqss", lambda = 0.1) + +p + stat_quant_eq() + +p + stat_quant_eq(method = "rqss") + +p + stat_quant_eq(method = "rqss", lambda = 0.1) + +sessionInfo() diff --git a/inst-not/quantreg/quantreg-rqss-examples.R b/inst-not/quantreg/quantreg-rqss-examples.R new file mode 100644 index 0000000..3bc853f --- /dev/null +++ b/inst-not/quantreg/quantreg-rqss-examples.R @@ -0,0 +1,29 @@ +library(quantreg) + +n <- 200 +x <- sort(rchisq(n,4)) +z <- x + rnorm(n) +y <- log(x)+ .1*(log(x))^2 + log(x)*rnorm(n)/4 + z +plot(x, y-z) + +f.N <- rqss(y ~ qss(x, constraint= "N") + z) + +f.I <- rqss(y ~ qss(x, constraint= "I") + z) + +f.CI <- rqss(y ~ qss(x, constraint= "CI") + z) + +lines(x[-1], f.N $coef[1] + f.N $coef[-(1:2)]) + +lines(x[-1], f.I $coef[1] + f.I $coef[-(1:2)], col="blue") + +lines(x[-1], f.CI$coef[1] + f.CI$coef[-(1:2)], col="red") + +## A bivariate example +if(requireNamespace("interp")){ + if(requireNamespace("interp")){ + data(CobarOre) + fCO <- rqss(z ~ qss(cbind(x,y), lambda= .08), data=CobarOre) + plot(fCO) + }} + +sessionInfo() diff --git a/tests/testthat/test-eq-label-utils.R b/tests/testthat/test-eq-label-utils.R index 0333c33..a87cdec 100644 --- a/tests/testthat/test-eq-label-utils.R +++ b/tests/testthat/test-eq-label-utils.R @@ -58,7 +58,7 @@ test_that("polynomial as character well formatted", { expect_equal(poly2character(x = (1:5) * 1e-6, decreasing = TRUE, digits = 3, keep.zeros = TRUE), "5.00e-06*x^4 + 4.00e-06*x^3 + 3.00e-06*x^2 + 2.00e-06*x + 1.00e-06") expect_equal(poly2character(x = (1:5) * 1e+3, decreasing = TRUE, digits = 3, keep.zeros = TRUE), - "5.00e+03*x^4 + 4.00e+03*x^3 + 3.00e+03*x^2 + 2.00e+03*x + 1.000e+03") + "5.00e+03*x^4 + 4.00e+03*x^3 + 3.00e+03*x^2 + 2.00e+03*x + 1.00e+03") expect_warning(poly2character(x = NA)) expect_true(is.na(suppressWarnings(poly2character(x = NA)))) expect_equal(poly2character(x = NULL), character(0))