nuncio m
2010-May-20 07:38 UTC
[R] writing autocorrelation and partial auto correlation functions to a file
Dear All, I am very new to T. I need to fit a ARIMA model to my time series. So I found the auto correlation functions and partial auto correlation function in R. Now I want to save these valuse along with the significance levels to a file. How to do that?. I tried some function in R like write.table but returns an error "cannot coerce class "acf" into a data.frame". The I tried "write" but returned again an error "Error in cat(list(...), file, sep, fill, labels, append) : argument 1 (type 'list') cannot be handled by 'cat'". Where am I going wrong THanks in advance nuncio -- Nuncio.M Research Scientist National Center for Antarctic and Ocean research Head land Sada Vasco da Gamma Goa-403804 [[alternative HTML version deleted]]
Glen Barnett
2010-May-20 09:51 UTC
[R] writing autocorrelation and partial auto correlation functions to a file
The problem is that the acf function (like many R functions) returns a list containing many different things. For example, I have a short series in the vector z:> acz <- acf(z) > str(acz)List of 6 $ acf : num [1:11, 1, 1] 1 -0.0668 -0.7401 0.0627 0.5954 ... $ type : chr "correlation" $ n.used: int 11 $ lag : num [1:11, 1, 1] 0 1 2 3 4 5 6 7 8 9 ... $ series: chr "z" $ snames: NULL - attr(*, "class")= chr "acf" Let's say you are interested in extracting the acf and lag values from that> acd <- data.frame(cbind(lag=acz$lag,acf=acz$acf)) > acdlag acf 1 0 1.00000000 2 1 -0.06676557 3 2 -0.74006273 4 3 0.06266564 5 4 0.59542482 6 5 -0.06786556 7 6 -0.41370293 8 7 0.03464621 9 8 0.21887326 10 9 -0.07485743 11 10 -0.04835570
David Winsemius
2010-May-20 13:07 UTC
[R] writing autocorrelation and partial auto correlation functions to a file
On May 20, 2010, at 3:38 AM, nuncio m wrote:> Dear All, > I am very new to T. I need to fit a ARIMA model to my time > series. So I found the auto correlation functions and partial auto > correlation function in R. Now I want to save these valuse along > with the > significance levels to a file. How to do that?. I tried some > function in R > like write.table but returns an error "cannot coerce class "acf" > into a > data.frame". The I tried "write" > but returned again an error "Error in cat(list(...), file, sep, fill, > labels, append) : > argument 1 (type 'list') cannot be handled by 'cat'". > Where am I going wrongIf you are just interested in getting the same information that you see on the console into a text file then: ?capture.output -- David Winsemius, MD West Hartford, CT