[R] Fitting quantile (or cdf?) function to data with specified percentiles

Franco Danilo Roca Landaveri fradarola at hotmail.com
Fri May 27 04:51:21 CEST 2016


Hello,

I hope you can help me. In class, we were given an Excel worksheet with specified formulas that take the total score from a survey (or from a specific section) and convert it to a percentage, according to a table that assigns scores to a percentile. Since the formulas are too long and complicated (some have been input by hand) I figured we could fit the data with a function with some parameters. I plotted the table and sure it resembled a more-or-less symmetrical quantile function, and I wanted to use R to find a curve that fittted the data. Here it is:

percentile <- c(0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.05, 0.05, 0.05,
0.05, 0.05, 0.10, 0.10, 0.15, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50,
0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.90, 0.95, 0.95, 0.99, 0.99, 0.99, 0.99,
0.99, 0.99, 0.99, 0.99, 0.99)

score <- c(10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50)

I looked up the quantreg package, but I didn't know how to use it properly since I don't have the raw data, only the percentiles, and also because what I'm trying to get is the percentile based on the score, not the other way around. Then I tried to fit it using a sigmoid curve (similar to a cdf), using the following code:

require(drc)
model1 <- drm(percentile ~ score, fct = LL.4())
summary(model1)

But I found another problem, the fitted curve apparently went over 1 on the y axis, something not possible for a cdf. I'd like to know what would be the most appropiate way to do this, and also if it is possible to fit a quantile function with this data, apart from the cdf.

Thank you very much for your help
 		 	   		  


More information about the R-help mailing list