Fotis Papailias wrote:
> 
> ....
> 
> local.whittle <- function(d, x, m)
> {
> n <- length(x)
> t <- matrix(c(0:n1), nrow = n, ncol=1)
> lambda <- (2*pi*t)/n
> wx <- (2*pi*n)^(-1/2)*Conj(fft( Conj(x)))*exp(1i*lambda)
> M1 <- m+1
> lambda2 <- lambda[2:M1]
> wx2 <- wx[2:M1]
> ix <- wx2*Conj(wx2)
> g <- mean((lambda2^(2*d))*ix)
> r <- log(mean((lambda2^(2*d))*ix)) - 2*d*mean(log(lambda2))
> }
> 
> =======================================================================================
> 
> which seems to run, but when I am trying to call the function and minimize
> it using:
> 
> 
> e <- optimize(local.whittle, x, m, c(-0.5, 0.5))
> e1 <- e$minimum
> 
> 

optimize only handles functions with a scalar argument.
Your function takes a vector a argument. Assuming that x is the parameter
vector to be optimized over, it should also be the first argument of the
local.whittle function.

You should use something like optim.
Do ?optim to find out how to use it.
Also have a look at the links in the See Also section.

Berend
-- 
View this message in context: 
http://www.nabble.com/transcript-a-matlab-code-in-R-tp18657256p18657971.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to