# [R] Exact quantile regression

Greg Snow greg.snow at ihc.com
Thu May 5 17:07:01 CEST 2005

```Here is an approach using optim:

tmpfunc <- function(param){
ml<-param[1]
sl<-param[2]
(qlnorm(.15,ml,sl)-10)^2 + (qlnorm(.5,ml,sl)-30)^2
}

res <- optim(c(1,2), tmpfunc)
res <- optim(res\$par, tmpfunc)
res

hope this helps,

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
greg.snow at ihc.com
(801) 408-8111

>>> Per Bak <perbak at tdcadsl.dk> 05/05/05 07:37AM >>>
Hi,

I have been returning to the same problem a number of times without
success
and now look for help with the following:

How do I fit a distribution function with the same number of parameters
as
there are quantiles and values such that I get an exact solution as
opposed
to a minimum least squares type solution? Say, which lognormal
distribution
has a 15% quantile of 10 and a 50% quantile of 30? My hope is that the

solution to this problem can be expanded, such that I can fit three
quantiles
with the Generalized Weibull distribution (which has three
parameters).

This is what I attempt without success:
=======================

library(stats)

Target <- data.frame(
quantiles = c(0.15, 0.50),
values = c(10, 30))

dist <- nls(values ~ qlnorm(quantiles, mu, sd), data = Target,
start = list(mu = 30, sd = 5))

I can see that it works with one more value:
==========================
Target <- data.frame(
quantiles = c(0.15, 0.50, 0.85),
values = c(10, 30, 60))

dist <- nls(values ~ qlnorm(quantiles, mu, sd), data = Target,
start = list(mu = 30, sd = 5))

Kind regards,

Per Bak
Copenhagen, Denmark

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help