problem with optim: (list) object cannot be coerced to 'double'

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

problem with optim: (list) object cannot be coerced to 'double'

Zebouni, Stephane (Exchange)
Hi,

 

I am trying to use optim to solve a heavy calibration problem. I supply
the parameters in vector form. But before entering my target

 

The call is simply:

 

optim(par = parameters, fn = SumLSQ, method = "Nelder-Mead")

 

the function SumLSQ is simply:

 

SumLSQ<-function(parameters, data = timeseries){

 

print("sumLSQ")

     

 

      nbseries = dim(timeseries)[2]/3

 

      SumLSQ = 0

     

      for (i in (1:nbseries)){

            SumLSQ = SumLSQ +
LSQ(parameters,timeseries[,((i-1)*3+1):(i*3)])

      }

 

}

 

I actually never enter the objective function SumLSQ. I always receive
the error:

 

(list) object cannot be coerced to 'double'

 

And I really don't know where it comes from. II thought it was the
format of "par" argument but I think it is correct to supply a numerical
vector  ...

 

Thnaks a lot for any help!

 

Stephane

 

 




***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: problem with optim: (list) object cannot be coerced to 'double'

Uwe Ligges
Zebouni, Stephane (Exchange) wrote:

> Hi,
>
>  
>
> I am trying to use optim to solve a heavy calibration problem. I supply
> the parameters in vector form. But before entering my target
>
>  
>
> The call is simply:
>
>  
>
> optim(par = parameters, fn = SumLSQ, method = "Nelder-Mead")
>
>  
>
> the function SumLSQ is simply:
>
>  
>
> SumLSQ<-function(parameters, data = timeseries){
>
>  
>
> print("sumLSQ")
>
>      
>
>  
>
>       nbseries = dim(timeseries)[2]/3
>
>  
>
>       SumLSQ = 0
>
>      
>
>       for (i in (1:nbseries)){
>
>             SumLSQ = SumLSQ +
> LSQ(parameters,timeseries[,((i-1)*3+1):(i*3)])
>
>       }
>
>  
>
> }
>
>  
>
> I actually never enter the objective function SumLSQ. I always receive
> the error:
>
>  
>
> (list) object cannot be coerced to 'double'
>
>  
>
> And I really don't know where it comes from. II thought it was the
> format of "par" argument but I think it is correct to supply a numerical
> vector  ...

Yes, it is. Please type
   str(parameters)
an tell us the result.

Uwe Ligges



>
>  
>
> Thnaks a lot for any help!
>
>  
>
> Stephane
>
>  
>
>  
>
>
>
> ------------------------------------------------------------------------
>
>
>
> ***********************************************************************
> Bear Stearns is not responsible for any recommendation, solicitation,
> offer or agreement or any information about any transaction, customer
> account or account activity contained in this communication.
> ***********************************************************************
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: problem with optim: (list) object cannot be coerced to 'double'

Zebouni, Stephane (Exchange)
In reply to this post by Zebouni, Stephane (Exchange)
 

Here is what I get using str(parameters):

 

num [1:120]  0.2000 -0.0166  0.0934 -0.0300 -0.3219 ...

 

again, it doesn't even get into the objective function - I checked that

 

Many thanks

 

Stephane

 

-----Original Message-----
From: Uwe Ligges [mailto:[hidden email]]
Sent: 14 March 2006 15:18
To: Zebouni, Stephane (Exchange)
Cc: [hidden email]
Subject: Re: [R] problem with optim: (list) object cannot be coerced to
'double'

 

Zebouni, Stephane (Exchange) wrote:

 

> Hi,

>

>  

>

> I am trying to use optim to solve a heavy calibration problem. I
supply

> the parameters in vector form. But before entering my target

>

>  

>

> The call is simply:

>

>  

>

> optim(par = parameters, fn = SumLSQ, method = "Nelder-Mead")

>

>  

>

> the function SumLSQ is simply:

>

>  

>

> SumLSQ<-function(parameters, data = timeseries){

>

>  

>

> print("sumLSQ")

>

>      

>

>  

>

>       nbseries = dim(timeseries)[2]/3

>

>  

>

>       SumLSQ = 0

>

>      

>

>       for (i in (1:nbseries)){

>

>             SumLSQ = SumLSQ +

> LSQ(parameters,timeseries[,((i-1)*3+1):(i*3)])

>

>       }

>

>  

>

> }

>

>  

>

> I actually never enter the objective function SumLSQ. I always receive

> the error:

>

>  

>

> (list) object cannot be coerced to 'double'

>

>  

>

> And I really don't know where it comes from. II thought it was the

> format of "par" argument but I think it is correct to supply a
numerical

> vector  ...

 

Yes, it is. Please type

   str(parameters)

an tell us the result.

 

Uwe Ligges

 

 

 

>

>  

>

> Thnaks a lot for any help!

>

>  

>

> Stephane

>

>  

>

>  

>

>

>

>
------------------------------------------------------------------------

>

>

>

>
***********************************************************************

> Bear Stearns is not responsible for any recommendation, solicitation,

> offer or agreement or any information about any transaction, customer

> account or account activity contained in this communication.

>
***********************************************************************

>

>

>

>
------------------------------------------------------------------------

>

> ______________________________________________

> [hidden email] mailing list

> https://stat.ethz.ch/mailman/listinfo/r-help

> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

 




***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html