Skip to content

Need help

2 messages · John Fox, Md. Moyazzem Hossain

#
Dear Hossain,

Did you look at the values that your function returns? As John Nash 
pointed out, these values presumably depend on the random values of a and b.

I tried the following:

set.seed(123) # for reproducibility
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)
}

res <- sapply(0:10000, ff)
res[1:500]
plot(0:150, res[1:151], type="l")


It was quickly clear that ff() produces NaNs for all but the smallest 
values of zz.

Beyond this fact, it's unclear to me what the purpose of the computation 
is. In the short domain where it produces numbers, the function returns 
both negative and positive values (for my values of a and b) -- that is, 
does cross 0 -- and if it did not, it would be nonsense to look for roots.

I hope this helps,
  John
On 2022-08-04 9:49 a.m., Md. Moyazzem Hossain wrote:
#
Dear John

Thank you very much for your feedback.

Take care.

Hossain
On Thu, Aug 4, 2022 at 3:01 PM John Fox <jfox at mcmaster.ca> wrote: