[R] Optimization function

2014-11-20 Thread Amit Thombre
Hi, I want to optimize the root mean square error objective function using the optim function. Thus the function will look like sqrt(sum((yi - f(xi))^2)/n). Now the f(xi) is the Arima function. I am not clear how do I get the f(xi) because the call to arima function in C gives the value of th

Re: [R] Using sapply instead of for loop

2014-11-20 Thread Amit Thombre
Thanks Charles. I will have to extract the min value from the list A by selecting the proper index. From: Charles Determan Jr [deter...@umn.edu] Sent: Wednesday, November 19, 2014 11:48 PM To: Amit Thombre Cc: r-help@r-project.org Subject: Re: [R] Using sapply

Re: [R] Using sapply instead of for loop

2014-11-19 Thread Amit Thombre
_ From: Charles Determan Jr [deter...@umn.edu] Sent: Wednesday, November 19, 2014 10:04 PM To: Amit Thombre Cc: r-help@r-project.org Subject: Re: [R] Using sapply instead of for loop The following provides array A with 3.212016 as the last value. The error values are indeed in the array here.

Re: [R] Using sapply instead of for loop

2014-11-19 Thread Amit Thombre
on the max value set the , stores the error value.array size for (i in 1:pmax) { for (j in 1:dmax) { for (k in 1:qmax) { for (l in 1:Pmax) { for (m in 1:Dmax) { for (n in 1:Qmax) { A<-sapply((1:Permax),function(p) far(p),simplify=FALSE) } } } } } #for looping through period value }

Re: [R] Using sapply instead of for loop

2014-11-19 Thread Amit Thombre
=function(e) { return(NA) } ) cat("Value of error", er[i,j,k,l,m,n,p]) cat("Value of i,j,k,l,m,n,p", i, j, k, l, m, n,p) } From: Charles Determan Jr [deter...@umn.edu] Sent: Wednesday, November 19, 2014 7:05 PM To: Amit Thombr

Re: [R] Using sapply instead of for loop

2014-11-19 Thread Amit Thombre
) { for (k in 1:qmax) { for (l in 1:Pmax) { for (m in 1:Dmax) { for (n in 1:Qmax) { A<-sapply((1:Permax),function(p) far(p),simplify=FALSE) } } } } } #for looping through period value } From: Charles Determan Jr [deter...@umn.edu] Sent: Wednesday, November 19,

[R] Using sapply instead of for loop

2014-11-19 Thread Amit Thombre
I am trying to replace a for loop by using sapply, The code is for forecasting using arima. The code is as follows:- --- far<-function(p) { cat("does it come here value of p", p) tryCatch({ air.model <-Arima(tsa,order=c(i-1,j-1,k-1), seasonal=l