[R] how to increase speed for function?/time efficiency of below function
sagarnikam123
sagarnikam123 at gmail.com
Thu Mar 29 13:54:34 CEST 2012
i am using sarima() function as below
___________________________________________________________________________________________
sarima=function(data,p,d,q,P=0,D=0,Q=0,S=-1,tol=.001){
n=length(data)
constant=1:n
xmean=matrix(1,n,1)
if (d>0 & D>0)
fitit=arima(data, order=c(p,d,q), seasonal=list(order=c(P,D,Q),
period=S),
optim.control=list(trace=1,REPORT=1,reltol=tol))
if (d>0 & D==0)
fitit=arima(data, order=c(p,d,q), seasonal=list(order=c(P,D,Q),
period=S),
xreg=constant,include.mean=F,
optim.control=list(trace=1,REPORT=1,reltol=tol))
if (d==0 & D==0)
fitit=arima(data, order=c(p,d,q), seasonal=list(order=c(P,D,Q),
period=S),
xreg=xmean,include.mean=F,
optim.control=list(trace=1,REPORT=1,reltol=tol))
if (d==0 & D>0)
fitit=arima(data, order=c(p,d,q), seasonal=list(order=c(P,D,Q),
period=S),
xreg=constant,include.mean=F,
optim.control=list(trace=1,REPORT=1,reltol=tol))
if (S < 0) goof=20 else goof=3*S
tsdiag(fitit,gof.lag=goof)
k=length(fitit$coef)
BIC=log(fitit$sigma2)+(k*log(n)/n)
AICc=log(fitit$sigma2)+((n+k)/(n-k-2))
AIC=log(fitit$sigma2)+((n+2*k)/n)
innov<<-fitit$resid
list(fit=fitit, AIC=AIC, AICc=AICc, BIC=BIC)
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
it takes 1-2 minutes for one time series,i have 4500 times series data,how
to increase speed/time of execution
is there any concept of threading/parallel computing in R
Please..Please.....can u suggest me code for above function,which will be
time efficient,i am frustrated with time consumption & reading material on
parallel computing, but i cant understand it properly
--
View this message in context: http://r.789695.n4.nabble.com/how-to-increase-speed-for-function-time-efficiency-of-below-function-tp4515201p4515201.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list