# [R] TR: The results of your email commands

Date: Fri 08 Apr 2005 - 22:33:23 EST

Hi,

I try to minimize the sum of the sum of sce. The following program has been

created but it only takes in consideration the last kinetic and not the     first ones. I think that I have forget a subscrib but I don't know where. so

if you can help me, it will be great....     I have try an other program where y and x are directly calculate in sce     function but the time of running was to long.     Thanks in advance,
Anne KERVAHU

rm(list=ls())
nbr=10
#list of data
x_a<-c(0,0.5,1,1.5,2,3,4,6,8,15,20,40,60,80,120)

y_a<-c(5.4771213,5.0791812,4.8450980,4.3010300,4,2.30103,1.5563025,1.30103,1

,1.6434527,0.60206,0.60206,0.30103,0,0.4771213)     x_b<-c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)

y_b<-c(5.3424227,4.9867717,4.6627578,4.0606978,3.07182,3.4771213,2.7993405,2

.9395193,2.69897,2.6127839,1.9777236,1.3222193,1.4149733,0.7781513,1.322219)

x_c<-c(0,3,6,10,12,14,16,18,20,24,26,28,30,34)

y_c<-c(5.5185139,5.1461280,4.3617278,3.771513,3.20412,3.0413927,2.7781513,2.

5682017,2.255272,1.7823917,1.447158,1.3222193,1.2787536,0.69897)

#number of kinetics
nb=3

#complete data set
x<-c(x_a,x_b,x_c)
y<-c(y_a,y_b,y_c)

#cumulative length
long<-c(0,15,30,44)

coeff<-matrix(nrow=1,ncol=(nb*2)+2)

#function to minimise
sce<-function(param){
return(sum(sum((yy-(param[i+nb]-(xx/param[i])^param[(nb*2)+1]))^2)))     }

#initial value for optim function
ninit<-vector(length=nb)
for(i in 1:nb){
ninit[i]<-x[long[i]+1]
}

pinf=c(rep(0.01,nb),rep(3,nb),0.5)
psup=c(rep(10,nb),rep(8,nb),4)

pinit=c(runif(nb,min=0.1,max=5),ninit,runif(1,min=0.5,max=4))     print(pinit)

for (i in 1:nb)
{
yy<-y[((long[i]+1):long[i+1])]
for( k in 1:length(yy)){

ifelse((yy[k]<=log10(nbr)),(yy<-yy[1:(min(which(yy<=log10(nbr),arr.ind=FALSE

))-1)]),(yy<-yy))
}

```    vv<-x[((long[i]+1):long[i+1])]
xx<-x[((long[i]+1):((long[i]+1)+(length(vv)=length(yy))-1))]
fl<-optim(p=pinit,sce,method="L-BFGS-B",lower=pinf,upper=psup,
```
control=list(maxit=200000,temp=200))     co<-fl\$par
coe<-fl\$value
coeff<-c(co,coe)
}
coeff

#graphical verification
plot(x_b,y_b)
y_est<-coeff-(x_b/coeff)^coeff     points(x_b,y_est)

attached mail follows:

Hi,

I try to minimize the sum of the sum of sce. The following program has been created but it only takes in consideration the last kinetic and not the first ones. I think that I have forget a subscrib but I don't know where. so if you can help me, it will be great.... I have try an other program where y and x are directly calculate in sce function but the time of running was to long.

Anne KERVAHU

rm(list=ls())
nbr=10

#list of data

```x_a<-c(0,0.5,1,1.5,2,3,4,6,8,15,20,40,60,80,120)
y_a<-c(5.4771213,5.0791812,4.8450980,4.3010300,4,2.30103,1.5563025,1.30103,1
,1.6434527,0.60206,0.60206,0.30103,0,0.4771213)

x_b<-c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14)
```
y_b<-c(5.3424227,4.9867717,4.6627578,4.0606978,3.07182,3.4771213,2.7993405,2 .9395193,2.69897,2.6127839,1.9777236,1.3222193,1.4149733,0.7781513,1.3222193 )

x_c<-c(0,3,6,10,12,14,16,18,20,24,26,28,30,34) y_c<-c(5.5185139,5.1461280,4.3617278,3.771513,3.20412,3.0413927,2.7781513,2. 5682017,2.255272,1.7823917,1.447158,1.3222193,1.2787536,0.69897)

#number of kinetics

nb=3

#complete data set

x<-c(x_a,x_b,x_c)
y<-c(y_a,y_b,y_c)

#cumulative length

long<-c(0,15,30,44)

coeff<-matrix(nrow=1,ncol=(nb*2)+2)

#function to minimise

sce<-function(param){
return(sum(sum((yy-(param[i+nb]-(xx/param[i])^param[(nb*2)+1]))^2))) }

#initial value for optim function

ninit<-vector(length=nb)
for(i in 1:nb){
ninit[i]<-x[long[i]+1]
}

pinf=c(rep(0.01,nb),rep(3,nb),0.5)
psup=c(rep(10,nb),rep(8,nb),4)

pinit=c(runif(nb,min=0.1,max=5),ninit,runif(1,min=0.5,max=4)) print(pinit)

for (i in 1:nb)
{
yy<-y[((long[i]+1):long[i+1])]
for( k in 1:length(yy)){
ifelse((yy[k]<=log10(nbr)),(yy<-yy[1:(min(which(yy<=log10(nbr),arr.ind=FALSE ))-1)]),(yy<-yy))
}

```vv<-x[((long[i]+1):long[i+1])]
xx<-x[((long[i]+1):((long[i]+1)+(length(vv)=length(yy))-1))]
fl<-optim(p=pinit,sce,method="L-BFGS-B",lower=pinf,upper=psup,
```
control=list(maxit=200000,temp=200))
co<-fl\$par
coe<-fl\$value
coeff<-c(co,coe)
}
coeff

#graphical verification

plot(x_b,y_b)
y_est<-coeff-(x_b/coeff)^coeff
points(x_b,y_est)

R-help@stat.math.ethz.ch mailing list