[R] truncpareto() - doesn't like my data and odd error message
John Hillier
J.Hillier at lboro.ac.uk
Wed Mar 9 18:52:24 CET 2016
Dear All,
I am attempting to describe a distribution of height data. It appears roughly linear on a log-log plot, so Pareto seems sensible. However, the data are only reliable in a limited range (e.g. 2000 to 4800 m). So, I would like to fit a Pareto distribution to the reliable (i.e. truncated) section of the data.
I found truncpareto(), and implemented one of its example uses successfully. Specifically, the third one at http://www.inside-r.org/packages/cran/vgam/docs/paretoff (also see p.s.).
When I try to run my data, I get the output below. Inputs shown with chevrons.
> pdataH <- data.frame(H_to_fit$Height)
> summary(pdataH)
H_to_fit.Height
Min. :2000
1st Qu.:2281
Median :2666
Mean :2825
3rd Qu.:3212
Max. :4794
> fit3 <- vglm(y ~ 1, truncpareto(2000, 4794), data = pdataH, trace = TRUE)
Error in eval(expr, envir, enclos) :
the value of argument 'lower' is too high (requires '0 < lower < min(y)')
This is odd as the usage format is - truncpareto(lower, upper), and varying 2000 to 1900 and 2100 makes no difference. Neither do smaller or larger variations. From the summary I think that my lowest input is 2000, which I am taking as min(y). I have also played with the upper limit. pdataH has 2117 observations in it.
Is this a data format thing? i.e. of pdataH (a tried a few things, but to no avail)
Is truncpareto sensitive to not converging?
Am I using completely the wrong command?
Thank you in advance for any assistance you can give.
John
<http://www.inside-r.org/packages/cran/vgam/docs/paretoff><http://www.inside-r.org/packages/cran/vgam/docs/paretoff>p.s - Example that I did get to run.
# Upper truncated Pareto distribution
lower <- 2; upper <- 8; kay <- exp<http://inside-r.org/r-doc/base/exp>(2)
pdata3 <- data.frame<http://inside-r.org/r-doc/base/data.frame>(y = rtruncpareto(n = 100, lower = lower,
upper = upper, shape = kay))
fit3 <- vglm(y ~ 1, truncpareto(lower, upper), data<http://inside-r.org/r-doc/utils/data> = pdata3, trace<http://inside-r.org/r-doc/base/trace> = TRUE)
coef<http://inside-r.org/r-doc/stats/coef>(fit3, matrix<http://inside-r.org/r-doc/base/matrix> = TRUE)
c<http://inside-r.org/r-doc/base/c>(fit3 at misc$lower, fit3 at misc$upper)
and output
> # Upper truncated Pareto distribution
> lower <- 2; upper <- 8; kay <- exp(2)
> pdata3 <- data.frame(y = rtruncpareto(n = 100, lower = lower,
+ upper = upper, shape = kay))
> fit3 <- vglm(y ~ 1, truncpareto(lower, upper), data = pdata3, trace = TRUE)
VGLM linear loop 1 : loglikelihood = 12.127363
VGLM linear loop 2 : loglikelihood = 12.130407
VGLM linear loop 3 : loglikelihood = 12.130407
> coef(fit3, matrix = TRUE)
loge(shape)
(Intercept) 1.955295
> c(fit3 at misc$lower, fit3 at misc$upper)
[1] 2 8
-------------------------
Dr John Hillier
Senior Lecturer - Physical Geography
Loughborough University
01509 223727
[[alternative HTML version deleted]]
More information about the R-help
mailing list