Hi list,
I have the following code to compute the acf of a time series
acfresid <- acf(residfit), where residfit is the series
when I type acfresid at the prompt the follwoing is displayed
Autocorrelations of series ?residfit?, by lag
0.0000 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333
1.000 -0.015 0.010 0.099 0.048 -0.014 -0.039 -0.019 0.040 0.018 0.042
0.9167 1.0000 1.0833 1.1667 1.2500 1.3333 1.4167 1.5000 1.5833 1.6667 1.7500
0.078 -0.029 0.028 -0.016 -0.021 -0.109 0.000 -0.038 -0.006 0.015 -0.032
1.8333 1.9167 2.0000 2.0833
-0.002 0.014 -0.226 -0.030
Residfit is a timeseries object at monthly interval (0.0833), Here I
understand R computed the correlation at lags 0 to 2 years.
What is surprising to me is
if I type acfresidfit at the prompt the following is displayed
Autocorrelations of series ?residfit?, by lag
0 1 2 3 4 5 6 7 8 9 10
1.000 -0.004 0.011 0.041 -0.056 0.019 -0.052 -0.027 -0.008 -0.012 -0.034
11 12 13 14 15 16 17 18 19 20 21
0.024 -0.005 0.006 -0.045 0.031 -0.035 -0.011 -0.021 -0.020 -0.010 -0.007
22 23 24 25
-0.038 0.017 0.051 0.038>From the header I understand both are autocorrelation computed at the same
lags. but the correlations are different
where am I going wrong and which is the correct one.
file residfit is also attached(filename-fileree2_test_out.txt)
Thanks
nuncio
--
Nuncio.M
Research Scientist
National Center for Antarctic and Ocean research
Head land Sada
Vasco da Gamma
Goa-403804
-------------- next part --------------
4.54540234232334
-14.4778008999506
-3.79668140611868
-7.81347830768482
-6.27293225798647
-6.87201981207487
-6.64965905122317
-6.75123982158051
18.7798275931915
6.81254237499438
17.533220743665
11.8179723199377
-13.8382453401278
3.54961036332585
-3.97203313203956
-1.11029123677042
-2.21102643268432
-1.78925830375029
-1.95531252764598
-1.90169073408017
-16.2251504389829
31.1513180684656
-5.0374856234746
3.64237537817929
35.7825921539956
-24.3131812339976
7.67437033129054
-4.57640838126481
0.136777763691723
-1.678854866888
-0.980572231720623
-1.25035922801876
-23.7161201125191
5.99944860265195
6.61868629783817
-1.3221234388819
10.2414420460275
-8.47848871031044
1.63078138547826
-2.26306522145922
-0.764479820758242
-1.34245520108361
-1.12077197260524
-1.20702766721386
5.98843679322213
7.33766331906203
-2.39623468909737
0.0189595505058051
-9.7878766373797
3.90933597855122
-3.15027883357282
-0.432594130850131
-1.48003000602628
-1.07756318111729
-1.23343646676257
-1.17429968377673
13.8000693717299
6.02003887937457
-8.34195666853458
-1.11099261410632
1.56296156653197
-2.75269349211589
-0.595469082283298
-1.42707843208285
-1.10772380913903
-1.23159158432425
-1.18477973889978
-1.20369456481332
21.7239849952369
-9.66196813638387
-0.891521279149956
9.25210349671729
10.3427639242166
-9.80695249149604
2.11038354823627
-2.47972753146567
-0.713019047280778
-1.39424540580337
-1.13280146608686
31.4656314670951
-0.108909595891454
-0.451065307346077
10.56546397663
-0.647946708663838
18.1367401912301
-3.53869009989366
-2.65626056469235
-0.654807910127964
-1.42643142842822
-1.13017662852014
-1.24514893937744
-13.9208705459327
-5.42722370392831
11.5554183170163
-1.11287843661796
-3.79345702201642
-16.8470908324909
4.77680059742864
-2.61594762546361
-0.680989698404531
-1.42700689601552
-1.14061278256847
-1.25178786153672
-19.2156665052095
3.59214434723623
9.68031595123078
-0.905773257642835
11.6697859140499
-10.438203868059
-3.04292317412673
0.76333844274339
-1.99296992395689
-0.932436833094549
-1.34172353169702
-1.18500028791065
-1.2462406728489
-33.1551884101196
19.0913314431478
-6.7817942558301
5.00083912161537
-3.23440161285666
-0.80515939314185
-1.3987298644782
-1.17104115381219
-1.25960948746092
-1.22639103288181
-1.2400712072929
46.5643087168762
17.4522540549196
-10.9812432669912
10.0524952224354
-1.45992013300943
4.90518728893209
-5.35388787161763
0.342273064087802
-1.85213822475519
-1.00798494789867
-1.33394637973212
-1.20931069510199
-19.8506519887964
-28.6308445373069
5.59082974922492
6.79381059715144
-2.5896614051167
-1.29096368912288
-1.29288147655713
-1.2322294690926
-1.25647397513093
-1.2480258537729
-1.25216727045333
-1.25146060728689
-27.5730296981935
5.19481715163884
5.228853569497
-3.52768178324466
2.26390585067962
10.4196518274518
-8.93836873407259
1.70129806057068
-2.39679794286931
-0.819558553443901
-1.42782263987167
-1.19447559456423
-1.28522288490369
-14.7482003454544
14.9839484682792
-3.23392273754434
3.74619714728151
-11.0770500672262
4.03870484048016
-3.30667482507862
-0.478945510500303
-1.56875824361717
-1.14997259983422
-1.31213006657225
44.8494266790537
45.8747777661297
-25.3865845300823
11.7813342281731
-1.19733031473043
17.5712159736525
-13.2582237918684
3.34350682483415
-3.050508327763
-0.589138057355864
-1.53787032402965
-1.17341307292178
-8.84586874444102
14.3506481320503
-4.07628087468823
4.70987052194326
4.39494471756441
-9.24601453129708
2.62270644700364
-2.78270637507523
-0.702034985002182
-1.50416468660651
-1.19616232201179
-1.31565847889372
-7.00007828891471
17.7085427122653
-1.52528847906864
-0.309797615869734
-0.0566490998050853
-5.19810851787238
0.888428207408488
-2.12551442046893
-0.965769470866167
-1.41326146433027
-1.24182582049418
-1.30873177393562
-16.2289073981339
-51.9225253379257
-19.3386796462891
2.38427752581183
-27.7361423578639
-19.5712596806443
13.8785744284575
-7.13852142522812
0.954021540291741
-2.1632076779049
-0.963688303263673
-1.42649694995691
-14.2992402218195
-7.7314839299092
-3.40738243534069
16.0648045973645
12.5540096462468
29.0526262750623
-22.5561725175906
6.88140413399041
-4.4555411157441
-0.0907078496920803
-1.77244084763005
-1.12571382124252
-1.37564877591533
34.7839130467653
28.1314141876941
-9.37828825214024
24.9150457215948
28.4137340430803
-11.8241441466989
0.0479727446966436
-1.83472654482799
-1.11060981397575
-1.39034661407175
-1.28351147977723
18.67445944689
11.9587572530683
10.1060538197511
-6.63876291771464
4.21145034560747
1.3204638917954
-8.19144085836375
2.37471436021782
-2.74138454700539
-0.772124469702433
-1.53135101326354
-1.23987013938925
-9.1322749650387
-15.4636561035409
13.6503851340109
-4.76950387371555
-1.40466359662758
-19.4286291355178
3.4958224310265
-1.70166897721047
-1.18227605746397
-1.3831761774716
-1.30670010152886
-1.33703826622651
-12.3389669044253
17.081019748534
0.950502974191608
6.15193179619922
1.41534278202565
1.94685751980317
-4.04387353173593
-0.290090836012148
-1.73651560052777
-1.180402947819
-1.39544339583655
-1.31352204946024
-1.34595712238194
-12.7460231813591
-8.118124618078
6.937253849588
-0.346911632202982
-18.5234777171214
8.9166532168388
-5.29169173777222
0.178883057399027
-1.92865771893443
-1.11795723277594
-1.43103639681612
-1.31136151874458
-45.1323735479384
5.28987429475017
5.1013488310248
-1.28711981747298
2.12711010146792
-3.68826205004599
-0.448348064670775
-1.69688816249149
-1.21697851752452
-1.40267410276981
-1.33205311049552
-1.36013655281591
41.7161501827383
-2.59309679589496
-1.95323484236723
7.4552610572846
19.3866434577005
-15.4620565516138
4.07494098685932
-3.44941019277704
-0.552761098305723
-1.66911401065156
-1.2401080627034
-1.40620124578789
36.2302292437129
2.39270813319921
0.195593921782148
1.80841005453113
6.26390892643767
-6.67133269745569
0.679081083389242
-2.15236310178926
-1.06289610991876
-1.48332490618523
-1.32231097445053
36.614796348231
9.52386815316633
-1.65968237968227
9.22472048287561
0.272541303060095
10.7197690902849
-9.45113070862807
Your question is a bit confusing. "acfresidfit" is an object, of which we don't know the origin. with your test file, I arrive at the first correlations (but with integer headings) :> residfit <- read.table("fileree2_test_out.txt") > acf(residfit) > acfresid <- acf(residfit) > acfresidAutocorrelations of series ?residfit?, by lag 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1.000 -0.015 0.010 0.099 0.048 -0.014 -0.039 -0.019 0.040 0.018 0.042 0.078 -0.029 0.028 -0.016 -0.021 -0.109 17 18 19 20 21 22 23 24 25 0.000 -0.038 -0.006 0.015 -0.032 -0.002 0.014 -0.226 -0.030 Could you please check where the object acfresidfit is coming from and how you generated it? Cheers Joris On Tue, Jul 6, 2010 at 9:47 AM, nuncio m <nuncio.m at gmail.com> wrote:> Hi list, > ? ? ? ? ?I have the following code to compute the acf of a time series > acfresid <- acf(residfit), where residfit is the series > when I type acfresid at the prompt the follwoing is displayed > > Autocorrelations of series ?residfit?, by lag > > 0.0000 0.0833 0.1667 0.2500 0.3333 0.4167 0.5000 0.5833 0.6667 0.7500 0.8333 > > ?1.000 -0.015 ?0.010 ?0.099 ?0.048 -0.014 -0.039 -0.019 ?0.040 ?0.018 ?0.042 > > 0.9167 1.0000 1.0833 1.1667 1.2500 1.3333 1.4167 1.5000 1.5833 1.6667 1.7500 > > ?0.078 -0.029 ?0.028 -0.016 -0.021 -0.109 ?0.000 -0.038 -0.006 ?0.015 -0.032 > > 1.8333 1.9167 2.0000 2.0833 > -0.002 ?0.014 -0.226 -0.030 > Residfit is a timeseries object at monthly interval (0.0833), Here I > understand R computed the correlation at lags 0 to 2 years. > > What is surprising to me is > if I type acfresidfit at the prompt the following is displayed > > Autocorrelations of series ?residfit?, by lag > > ? ? 0 ? ? ?1 ? ? ?2 ? ? ?3 ? ? ?4 ? ? ?5 ? ? ?6 ? ? ?7 ? ? ?8 ? ? ?9 ? ? 10 > > ?1.000 -0.004 ?0.011 ?0.041 -0.056 ?0.019 -0.052 -0.027 -0.008 -0.012 -0.034 > > ? ?11 ? ? 12 ? ? 13 ? ? 14 ? ? 15 ? ? 16 ? ? 17 ? ? 18 ? ? 19 ? ? 20 ? ? 21 > > ?0.024 -0.005 ?0.006 -0.045 ?0.031 -0.035 -0.011 -0.021 -0.020 -0.010 -0.007 > > ? ?22 ? ? 23 ? ? 24 ? ? 25 > -0.038 ?0.017 ?0.051 ?0.038 > >From the header I understand both are autocorrelation computed at the same > lags. but the correlations are different > > where am I going wrong and which is the correct one. > > file residfit is also attached(filename-fileree2_test_out.txt) > Thanks > nuncio > -- > Nuncio.M > Research Scientist > National Center for Antarctic and Ocean research > Head land Sada > Vasco da Gamma > Goa-403804 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php