Re: [R] Exact quantile regression

From: Greg Snow <greg.snow_at_ihc.com>
Date: Fri 06 May 2005 - 01:07:01 EST


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@ihc.com
(801) 408-8111

>>> Per Bak <perbak@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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 06 01:28:16 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:36 EST