R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(411,2930,2773,2785,2789,2815,3034,3089,3035,3061,2951,2891,2817,2793,2805,2757,2786,2773,2609,2653,2537,2727,2558,2585,2558,2574,2561,2639,2450,2422,2559,2372,2359,2548,2534,2370,2540,2474,2390,2640,2523,2681,2666,2522,2646,2691,2729,2727,2731,2772,2911,2860,3003,397,2550,3038,3011,3082,3192,3143,3033,3211,3170,3293,3039,3038,3067,2974,3059,2859,2727,2560,2652,2571,2499,2601,2577,2498,2539,2493,2533,2461,2488,2724,2486,2389,2442,2402,2436,2477,2311,2498,2369,2576,2604,2543,2679,2469,2503,2571,2565,2743,2598,2590,2787,2753,772,1992,2816,2739,2708,2708,2853,2794,2750,2713,2762,2769,2660,2691,2705,2591,2608,2610,2527,2616,2618,2555,2505,2492,2428,2439,2477,2650,2560,2803,2641,2483,2520,2406,2454,2629) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '48' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_autocorrelation.wasp/ > #Source of accompanying publication: > # > if (par1 == 'Default') { + par1 = 10*log10(length(x)) + } else { + par1 <- as.numeric(par1) + } > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > if (par6 == 'White Noise') par6 <- 'white' else par6 <- 'ma' > par7 <- as.numeric(par7) > if (par8 != '') par8 <- as.numeric(par8) > ox <- x > if (par8 == '') { + if (par2 == 0) { + x <- log(x) + } else { + x <- (x ^ par2 - 1) / par2 + } + } else { + x <- log(x,base=par8) + } > if (par3 > 0) x <- diff(x,lag=1,difference=par3) > if (par4 > 0) x <- diff(x,lag=par5,difference=par4) > postscript(file="/var/wessaorg/rcomp/tmp/1q09n1413752185.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,1)) > plot(ox,type='l',main='Original Time Series',xlab='time',ylab='value') > if (par8=='') { + mytitle <- paste('Working Time Series (lambda=',par2,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(lambda=',par2,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } else { + mytitle <- paste('Working Time Series (base=',par8,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(base=',par8,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } > plot(x,type='l', main=mytitle,xlab='time',ylab='value') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/2jgnz1413752185.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > racf <- acf(x, par1, main='Autocorrelation', xlab='time lag', ylab='ACF', ci.type=par6, ci=par7, sub=mysub) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3kzzw1413752185.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > rpacf <- pacf(x,par1,main='Partial Autocorrelation',xlab='lags',ylab='PACF',sub=mysub) > dev.off() null device 1 > (myacf <- c(racf$acf)) [1] 1.000000000 0.242098710 0.121945926 0.133875174 0.122408113 [6] 0.086154091 0.051457209 0.045353505 0.025964747 0.009139183 [11] -0.021603883 -0.014709046 -0.032845583 -0.035773409 -0.045102106 [16] -0.030218369 -0.019007055 -0.037959920 0.006107275 -0.052641390 [21] -0.047245741 -0.039329535 -0.049482019 -0.105623754 -0.064133446 [26] -0.062726439 -0.099235834 -0.119833228 -0.087520787 -0.099567008 [31] -0.122374276 -0.045653547 -0.031049641 -0.013806975 -0.030541952 [36] -0.010504034 -0.042149787 -0.025611198 -0.035725735 -0.034908243 [41] -0.035994950 -0.039161270 -0.019170785 -0.040726888 -0.023009630 [46] -0.021487918 -0.010007321 0.004257887 0.007808006 > (mypacf <- c(rpacf$acf)) [1] 0.2420987102 0.0672773880 0.0960922653 0.0691685050 0.0301121805 [6] 0.0030444205 0.0093754906 -0.0068013564 -0.0119531202 -0.0350588939 [11] -0.0105568481 -0.0291227307 -0.0184253350 -0.0252140333 -0.0023209547 [16] 0.0045014698 -0.0193998326 0.0341069564 -0.0522580313 -0.0212278598 [21] -0.0179817585 -0.0291000452 -0.0828987820 -0.0114774743 -0.0275914814 [26] -0.0588160406 -0.0673077033 -0.0214644855 -0.0508478396 -0.0616495546 [31] 0.0274074453 0.0091379680 0.0173684001 -0.0155035554 0.0046745950 [36] -0.0538851384 -0.0169201667 -0.0387120269 -0.0321371582 -0.0387335855 [41] -0.0273525559 -0.0143554051 -0.0400925665 -0.0094066893 -0.0123027737 [46] -0.0131606189 0.0032692646 -0.0002330004 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','ACF(k)','click here for more information about the Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 2:(par1+1)) { + a<-table.row.start(a) + a<-table.element(a,i-1,header=TRUE) + a<-table.element(a,round(myacf[i],6)) + mytstat <- myacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/453px1413752185.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Partial Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','PACF(k)','click here for more information about the Partial Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:par1) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,round(mypacf[i],6)) + mytstat <- mypacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/50n3h1413752185.tab") > > try(system("convert tmp/1q09n1413752185.ps tmp/1q09n1413752185.png",intern=TRUE)) character(0) > try(system("convert tmp/2jgnz1413752185.ps tmp/2jgnz1413752185.png",intern=TRUE)) character(0) > try(system("convert tmp/3kzzw1413752185.ps tmp/3kzzw1413752185.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.186 0.192 1.382