[R] Need help

Md. Moyazzem Hossain ho@@@|nmm @end|ng |rom jun|v@edu
Thu Aug 4 15:49:46 CEST 2022


Dear JN,

Thanks.

I do not check whether the function actually crosses zero or not. However,
by assumption, the value would be greater than zero.

Hossain

On Thu, Aug 4, 2022 at 2:40 PM J C Nash <profjcnash using gmail.com> wrote:

> Have you checked that your function actually crosses zero?
>
> You should also set a seed if you want a reproducible result.
>
> JN
>
> On 2022-08-04 09:30, Md. Moyazzem Hossain 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
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]]



More information about the R-help mailing list