I just wonder that if you know theta and x. Why can't you specify
these in your functions. such as
f1<-function(theta1){1+2+theta1[1]} (Let me assume theta[1]=1, theta[2]=2)
f2<-function(theta1){f1(theta1)*exp(3)*theta1[2]} (again, I assume x=3)
f3<-function(theta1){f1(theta1)-f2(theta1)}
optim
On Fri, May 30, 2008 at 12:04 PM, threshold <[EMAIL PROTECTED]> wrote:
> Thanks for all your replies and sorry for a negligence in my examples. They
> are very simplified to reflect very roughly the structure of the case I deal
> with, which is too complicated to be quoted here.
>
> What I deal wit
Thanks for all your replies and sorry for a negligence in my examples. They
are very simplified to reflect very roughly the structure of the case I deal
with, which is too complicated to be quoted here.
What I deal with is:
1) 'theta' which is vector with length 2, being known to me (eg.
theta=
Did you copy-paste that error message?
I get:
> optim(par=c(1,1), f3)
Error in f1(theta, theta1) : object "theta" not found
>
You seem to be confusing your formal and actual parameters.
When you invoke f3 (within optim()), theta is not defined within f3().
Ray
On Fri, 30 May 2008, threshold
Hi,
I think Ray has answered this question in the previous e-mail.
Because optim can only use one single parameter thus you can not have
the parameters: theta, theta1 and x at the same time.
such as:
f1<-function(theta)
{theta[1]+theta[2]}
f2<-function(theta)
{f1(theta)*3}
f3<-function(thet
Hi, thanks for your replay the previous post of mine. Let me ask you one more
question similar to the previous one, based on a naive example:
f1<-function(theta, theta1)
{theta[1]+theta[2]+theta1[1]}
f2<-function(theta, x, theta1)
{f1(theta, theta1)*exp(x)*theta1[2]}
function to be optimized wi
The error comes from the way you specify the parameters:
At least not as elegant, but it works:
function4 <- function(x){
theta1 <- x[1]
theta2 <- x[2]
theta3 <- x[3]
function3(theta1,theta2,theta3)
}
fit<-optim(par=c(1, 1.2, .2), fn=function4)
Bart
threshol
On Wed, 23 Apr 2008, threshold wrote:
> Hi, here comes my problem, say I have the following functions (example
> case) #
> function1 <- function (x, theta)
> {a <- theta[1] ( 1 - exp(-theta[2]) ) * theta[3] )
> b <- x * theta[1] / theta[3
8 matches
Mail list logo