Re: [R] Using sapply instead of for loop

2014-11-20 Thread Amit Thombre
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 } From: Charles Determan Jr [deter...@u

Re: [R] Using sapply instead of for loop

2014-11-19 Thread Charles Determan Jr
NA > [2,] NA NA > The ervalue itself loses the values , I think and hence A does not have > it. > > -- > *From:* Charles Determan Jr [deter...@umn.edu] > *Sent:* Wednesday, November 19, 2014 10:04 PM > > *To:* Amit Thombre > *Cc:*

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 Charles Determan Jr
al,maxval,maxval,maxval,maxval,2)) # depdending > on the max value set the , stores the error value.array size > ervalue<-array(, c(maxval,maxval,maxval,maxval,maxval,maxval, 2)) # > depdending on the max value set the , stores the error value.array size > erval1<-array(, c(maxval,maxval,maxval,maxval,maxval,maxval, 2)) # >

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 8:40 PM To: Amit Thombre Cc: r-help@r-project.org Subject: Re: [R] Using sapply instead of for loop Amit, Even if you aren't getting an error with your original global va

Re: [R] Using sapply instead of for loop

2014-11-19 Thread Charles Determan Jr
ing 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),simpli

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,

Re: [R] Using sapply instead of for loop

2014-11-19 Thread Charles Determan Jr
Amit, Your question isn't necessarily complete. You haven't provided a reproducible example of your data or an error message. At first glance you aren't passing anything to your 'far' function except for 'p' and yet it uses i,j,k,l,m,n,testsize1, and act1. You should generally try to avoid glob

[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