Skip to content
Back to formatted view

Raw Message

Message-ID: <1140788587.25774.42.camel@localhost.localdomain>
Date: 2006-02-24T13:43:07Z
From: Tom
Subject: help with optimize statement

Can some help me spot what I'm doing wrong here.
I have two equations, one a michalis-menton eqn and one a straight line.
I need to work out where they cross.

I created the function:
solveEqn<-function(x,vals){
Vmax<-vals[1]
Ks<-vals[2]
m<-vals[3]
c<-vals[4]
    diff<-0
    mmVal<-exp(Vmax+x/(Ks+x))
    slVal<-x*m+c

    diff<-mmVal-slVal
    return(diff)
}
> optim(c(200,500),solveEqn,vals=c(2.4591201,-0.4015233,5.924e-5,3.437))
Error in optim(c(200, 500), solveEqn, vals = c(2.4591201, -0.4015233,  :
        objective function in optim evaluates to length 2 not 1


If i replace return(diff) with sum(diff) then the optim function runs
but returns the wrong value (which should be about 290).

Many thanks 
Tom