Dear All,
Thank you very much for all of your help. If anyone feels unhappy with my
words then I apologize.
Actually, I am not an expert user as a result my coding seems to be wrong
on some points. Now, it is working.
I am thankful to all of you for your kind support. Take care.
Hossain
On Fri, Aug 5, 2022 at 4:27 AM Andrew Simmons <akwsimmo at gmail.com>
wrote:
> Hello again,
>
>
> Since the GEV distribution and the GPD distribution are similar, I was
> able to make dgpd, pgpd, qgpd, and rgpd with no trouble. You should be able
> to use the same piece of code I gave earlier to install the package, here
> it is again:
>
> install.packages(c("this.path", "essentials"), repos =
"
> https://raw.githubusercontent.com/ArcadeAntics/PACKAGES")
>
> I tried to make your code a little nicer and also use 'pgpd', let
me know
> if this behaves as expected.
>
> #####
> library(essentials)
> a <- rnorm(1000, 110, 5)
> b <- rnorm(1000, -0.3, 0.4)
> s <- length(a)
> lam <- 0.15
> thr <- 70
> r <- 10
>
> ff <- function(zz) {
> inner <- numeric(s)
> for (k in 1:s) {
> inner[k] <- 1 - lam * pgpd(zz, location = thr, scale = a[k],
shape
> = b[k], lower.tail = FALSE)
> }
>
>
> # if zz is length 1 (it is for uniroot), it would be much faster to do
> this:
> # inner <- 1 - lam * pgpd(zz, location = thr, scale = a, shape = b,
> lower.tail = FALSE)
> #
> # use whichever you please
>
> mean(inner) - (1 - 1/r)
> }
> ########
> out <- uniroot(ff, lower = 0, upper = 10000)$root
> out
>
> On Thu, Aug 4, 2022 at 3:17 PM Md. Moyazzem Hossain <hossainmm at
juniv.edu>
> wrote:
>
>> Dear Andrew Simmons,
>>
>> Thank you very much.
>>
>> Actually, I want to calculate the predictive return level of GPD and
>> compare it with the return level to see the difference. I have used the
>> following function before but it does not provide the results as
expected.
>> It is OK for GEV but not GPD.
>>
>> inner[k] = pgpd(zz, scale = a[k], shape = b[k] )
>>
>> Other lines of the code were the same.
>>
>> Please help me to calculate the predictive return level of GPD.
>>
>> Thanks in advance.
>>
>> Hossain
>>
>> On Thu, Aug 4, 2022 at 5:11 PM Andrew Simmons <akwsimmo at
gmail.com> wrote:
>>
>>> Is this a GEV distribution by chance? If so, I made functions dgev,
>>> pgev, qgev, and rgev that you can find install with:
>>>
>>> install.packages(c("this.path", "essentials"),
repos = "
>>> https://raw.githubusercontent.com/ArcadeAntics/PACKAGES")
>>>
>>> and then in your R script
>>>
>>> library(essentials)
>>> dgev(...) or pgev or qgev as needed
>>>
>>> On Thu, Aug 4, 2022, 09:31 Md. Moyazzem Hossain <hossainmm at
juniv.edu>
>>> wrote:
>>>
>>>> Dear R Experts,
>>>>
>>>> I hope that you are doing well.
>>>>
>>>> I am facing a problem to find out the value of the following
function. I
>>>> need help in this regard.
>>>>
>>>> #####
>>>> a=rnorm(1000, 110, 5)
>>>> b = rnorm(1000, -0.3, 0.4)
>>>> s = length(a)
>>>> lam=0.15
>>>> thr=70
>>>> r= 10
>>>>
>>>> ff = function(zz){
>>>> inner = vector("numeric", length = s)
>>>> for(k in 1:s){
>>>> inner[k]=(1- lam*((1+b[k]*((zz-thr)/a[k]))^(-1/b[k])))
>>>> }
>>>> answer = mean(inner)- (1- (1/r))
>>>> return(answer)
>>>> }
>>>> ########
>>>> out=uniroot(ff, lower = 0, upper = 10000 )$root
>>>> out
>>>>
>>>> ########### Error ########
>>>> Error in uniroot(ff, lower = 0, upper = 10000) :
>>>> f.upper = f(upper) is NA
>>>>
>>>> Please help me. Thanks in advance.
>>>>
>>>> Take care.
>>>>
>>>> Hossain
>>>>
>>>> --
>>>> Best Regards,
>>>> Md. Moyazzem Hossain
>>>> Associate Professor
>>>> Department of Statistics
>>>> Jahangirnagar University
>>>> Savar, Dhaka-1342, Bangladesh
>>>>
>>>> [[alternative HTML version deleted]]
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and
more, see
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible
code.
>>>>
>>>
>>
>> --
>> Best Regards,
>> Md. Moyazzem Hossain
>> Associate Professor
>> Department of Statistics
>> Jahangirnagar University
>> Savar, Dhaka-1342, Bangladesh
>> Website: http://www.juniv.edu/teachers/hossainmm
>> Research: *[image: Google Scholar]
>>
<https://scholar.google.com/citations?hl=en&user=-U03XCgAAAAJ>* |
*ResearchGate
>> <https://www.researchgate.net/profile/Md_Hossain107>* | *ORCID iD
>> <https://orcid.org/0000-0003-3593-6936>*
>>
>
--
Best Regards,
Md. Moyazzem Hossain
Associate Professor
Department of Statistics
Jahangirnagar University
Savar, Dhaka-1342, Bangladesh
Website: http://www.juniv.edu/teachers/hossainmm
Research: *[image: Google Scholar]
<https://scholar.google.com/citations?hl=en&user=-U03XCgAAAAJ>* |
*ResearchGate
<https://www.researchgate.net/profile/Md_Hossain107>* | *ORCID iD
<https://orcid.org/0000-0003-3593-6936>*
[[alternative HTML version deleted]]