Hi,

I am trying to fit experimental points by exponemtial curve

my data are stored into a matrix data

the first column is the geographical point (a number = data[,1] ) ( I 
would like to plot several graphes at  the same time)
the second column is the time of measurement (x in the plot)
the third column is a speed (y in the plot)

if we assume the point are folowing this exponential behaviour y=exp(a+bx)
then log y = a+ bx
we then can determine the coefficient a and b by a linear regression with 
the lm function and get them as following : coef ( lm (log(y)~x)) 
then I can use those coefficient


if I plot ln y = ax+b , everything goes fine 

 
xyplot(log(data[,3])~data[,2]|data[,1],panel=function(x,y){panel.xyplot(x,y)+panel.abline(coef(lm(y~x)))})
and I get perfect linear regression of my points

...But I would prefer to plot the exponential curves (y=exp ( a*x + b ))..
I tried the following formula :

> 
xyplot(data[,3]~data[,2]|data[,1],panel=function(x,y){panel.xyplot(x,y)+panel.curve(coef(lm(log(y)~x))[1])})

and I get : 
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ (found for 'x')

... I don't really now what goes wrong and how to correct that
Maybe I am wrong in the use of the pannel.curve function .... 

Do anyone know something about that ? 


Thanks by advance

Jessica Gervais
 




	[[alternative HTML version deleted]]

