R upper and lower bounds for a regression function

621 views Asked by At

I am trying to bound the following variables in a function

lower = c(Hyp.b = 0.01, Hyp.Di = .0000001),
upper = c(Hyp.b = 1.01, Hyp.Di = .1)

The script is as follows:

Hyp.q.forward.fun = function( time, Hyp.qi, Hyp.b, Hyp.Di ){ # time in days
Hyp.q.theo = Hyp.qi*(1 + Hyp.b*Hyp.Di*time)^(-1/Hyp.b)
return(Hyp.q.theo)
}


residfun = function(x,x.days,y.prod){
 Hyp.qi = x[1]
 Hyp.b  = x[2]
 Hyp.Di = x[3]
 q.theo = (365.25/12)*Hyp.q.forward.fun(
   time=x.days, 
   Hyp.qi=Hyp.qi, 
   Hyp.b=Hyp.b, 
   Hyp.Di=Hyp.Di)
 #plot(x.days,y.prod); lines(x.days,q.theo)
 residual = sqrt(sum((q.theo-y.prod)^2))
 return(residual)
 }

I'm not sure if I'm even using the correct method to bound the two variable. Any help would be much appreciated.

0

There are 0 answers