Related
Good afternoon. I have a vector 'a' containing 16000 values. I get the descriptive statistics with the help of the following:
library(pastecs)
library(timeDate)
stat.desc(a)
skewness(a)
kurtosis(a)
Especially skewness=-0.5012, kurtosis=420.8073 (1)
Then I build a histogram of my empirical data:
hist(a, col="lightblue", breaks = 140, border="white", main="",
xlab="Value",xlim=c(-0.001,0.001))
After this I try to fit a theoretical distribution to my empirical data. I choose Variance-Gamma distribution and try to get its parameter estimates on my data:
library(VarianceGammma)
a_VG<-vgFit(a)
The parameter estimates are the following:
vgC=-11.7485, sigma=0.4446, theta=11.7193, nu=0.1186 (2)
Further, I create a sample from the Variance-Gamma distribution with the parameters from (2)
and build a histogram of created theoretical values:
VG<-rvg(length(a),vgC=-11.7485,sigma=0.4446,theta=11.7193,nu=0.1186)
hist(VG,breaks=140,col="orange",main="",xlab="Value")
Bu the second histogram differs absolutely from the first (empirical) histogram. Moreover, it is built on the basis of the parameters (2), which I got on the empirical data.
What's wrong with my code? How can I fix it?
P.S. When I type dput(a[abs(a) > 5e-4]) I get:
c(0.000801110480004752, 0.000588162271316861, 0.000555169128569233,
0.000502563410256229, 0.000854633994686438, 0.00593622112246628,
-0.000506168123513007, -0.000502909585836875, 0.000720924373137422,
0.00119141739181039, 0.000548159382141478, -0.000516511318695123,
-0.000744590777740584, 0.000595213912401249, 0.000514055190913965,
-0.000589061375421807, -0.00175392114572581, 0.000745548313668465,
-0.00075910234096277, -0.00059987613053103, 0.000583568488865538,
0.00426484136013094, 0.000610760059768012, 0.000575522836335551,
0.000823785810599276, 0.00181936036509178, -0.00073316272551871,
-0.00184238143420679, -0.000519146793923397, -0.00120324664043103,
-0.000882469414168696, -0.00148118339830283, 0.000929612782487155,
0.000565364610238817, 0.000578158613453894, 0.00060479145432879,
-0.00520576206828594, 0.000708404040882016, 0.00105224485893451,
0.000636486872540587, -0.00359655507585543, 0.000769164650506582,
0.000635701125126786, 0.000570489501935612, -0.000641260260277221,
0.000735092947873994, 0.000757195823062773, 0.000556002742616357,
-0.00207489740356159, -0.000553386431560554, 0.000511326871983186,
0.000504591469525195, -0.000749886905655472, -0.0013939718643865,
-0.000513742626250036, -0.00105021597423516, -0.00156667292147716,
0.000864563166150134, 0.00433724128055069, 0.00053855648931922,
-0.00150732363190365, 0.00052621785349416, 0.000987781100809215,
0.000560725818171903, 0.00176012436713435, -0.000594895431092368,
-0.000686229580335151, 0.00138682284509528, -0.000531964338888358,
-0.00179959148771403, 0.000574543871314503, -0.000686996216439084,
-0.000559043343629995, 0.00055881173674166, -0.000636332688477736,
-0.000623778186703561, -0.00173834148094443, -0.000567224129968125,
-0.00122578683434504, 0.00130960156515414, -0.000548203197176633,
-0.000522749285863711, -0.000820371086264871, 0.000756014225812507,
-0.000714081490558627, -0.000617600335221624, 0.000523639760748651,
-0.000578502663833191, 0.00107478825239227, 0.000612725356974764,
-0.00065509337422931, 0.000505887803587513, -0.000566716376848575,
0.000511727090058756, 0.000572807738912218, -0.000756026937699161,
0.000547948751494332, 0.000628323894238392, -0.000541350489317693,
-0.00133529454372372, -0.000590618859845904, -0.000700581963648972,
0.000735987224462775, 0.000528958898682319, 0.000838250041022448,
-0.000519084424130511, -0.00052258402856431, -0.000538130765869838,
-0.000631819887885854, 0.00054800880764283, 0.00266115500510899,
-0.000839092093771754, 0.000559253571783103, -0.000801028189803432,
-0.000608879021022801, -0.000538018076854385, -0.000689859734395171,
0.00329650346269972, 0.000765494493951024, -0.000689450477848297,
-0.000560199139975737, 0.00159082699266122, -0.00208548663121455,
-0.000598493596793759, 0.000563544422691464, 0.000626996183768824,
-0.000653166846808162, -0.000851350174739807, -0.00140687473245116,
-0.000887003220306326, -0.000765614651347946, -0.00100676206277761,
0.000724714394852555, 0.00108872127644233, -0.000678558537305918,
-0.000705087556212902, 0.000544828152248655, -0.000791700964308362,
0.000606125736727137, -0.00119335967326073, 0.00075413211796338,
0.000526038939010931, 0.00086543737231537, -0.000817788712950573,
-0.000584070926663571, 0.000619657281937691, 0.000680783312420274,
-0.000513831718574664, -0.00050972403875349, -0.00114542220685365,
-0.00070564389723593, -0.01057964950882, -0.000610357922434801,
0.000818264221596365, 0.000940825400308043, -0.000726555639413817,
-0.000591089505560305, 0.000564738888193972, -0.00068515060569041,
0.000668920238348747, -0.00110103375121717, -0.0015480433031172,
0.000663030855223568, 0.000500097431997304, -0.000600730311271391,
-0.000672397772962796, -0.000607852365856587, 0.000536711920570809,
0.000595055206488837, 0.000523123873687581, 0.000977280737528119,
0.000616410821629998, 0.000788593666889881, -0.000671642905915704,
0.000717328711735021, -0.000551853104219902, -0.000565153434708421,
-0.000802585212152707, 0.000536342062561701, 0.000682048510343591,
-0.000541902545439399, 0.000779676683974273, 0.000698841439971787,
0.000559313965908359, -0.00064986819016255, 0.000795421518319017,
0.00364973919549527, 0.000669658692276087, 0.00109045476974678,
0.000514411572742901, 0.000503832507211754, -0.000507376233564116,
0.001232871590787, 0.000561820312542594, -0.000501190337518054,
-0.000769036505996468, -0.000695537959007453, -0.000572065848166048,
-0.00167929926328192, 0.000597078186826749, 0.00710238430870014,
0.000745192112519888, -0.00116091022028009, -0.000791139281769659,
-0.00148898466632552, 0.000565144038962018, -0.000514019821833855,
-0.00148427996685285, -0.000822717245339888, -0.00062922111212238,
-0.000636011367371125, 0.00119640327632808, 0.000548455410294579,
0.000652678152560426, 0.000509244387833618, 0.000961872348987924,
0.000662064072514568, -0.00068116858054168, -0.000569930302445343,
0.00188358126928101, 0.00130560555273895, 0.000593470885775105,
0.00160093110088155, 0.000785262438315115, -0.000912313442922752,
0.000609996052359563, 0.000720137994393966, 0.000568163899000496,
0.00128685533068307, -0.000756787473447318, 0.000765932134255465,
0.00064884753100003, 0.000687571386270847, -0.000582094290400903,
-0.000693177295971736, -0.000601776208094762, 0.000503616387996786,
-0.000615095866544735, -0.000799593899689199, 0.000773750859128342,
-0.000522576090260074, 0.000503578107212022, -0.00104492224837571,
0.000547928732299141, 0.00310304337507183, 0.000893382870797765,
-0.000577792878910799, -0.000647710366578735, -0.00061992948706191,
0.000825702487162516, 0.000606579510524341, 0.000552792484727505,
0.000688600840895504, 0.000505093563534231, -0.000728420573667066,
-0.00157924525963438, -0.000603846616019865, -0.000521941317177976,
0.00150498158245682, -0.000584572670337735, 0.000713757870583365,
0.000524287801789924, 0.00107217649464886, 0.00213147531822244,
0.000566012832157625, -0.00069828890607937, 0.000641567963736378,
-0.000509531713644762, -0.000547564140049417, -0.00115275240244728,
0.000560465768010943, -0.000651807371497171, -0.00096487058986483,
0.000753687665266511, -0.000665599418910645, -0.000691278087025182,
-0.000578010050725553, -0.000685833148198256, 0.000698470819832764,
0.00102943368139208, -0.000725840586788706, 0.00125882415960632,
-0.000630791474954151, -0.000764813558678412, -0.000638539347184164,
0.000654486496518558, 0.000547453642294471, 0.000572020020495501,
-0.000605791001705214, 0.00660211658324172, 0.00114928683282756,
0.000985676480677711, -0.000694668292547718, -0.000528955637964401,
0.000647975568638159, 0.00116454536417443, 0.000506748841724303,
-0.000500925156604382, -0.000567015088082101, 0.00128711230206946,
0.000533633762033858, 0.00505991432758357, 0.000518058378462527,
-0.000592822519784875, 0.00177414999018666, 0.00059845426944527,
-0.000511614433724716, 0.0016614697907098, 0.000852196464322219,
0.00241689725305427, -0.000614317948913978, -0.000729717143318709,
-0.000612900648802039, -0.000727983564232204, -0.000694965869158182,
-0.000527752006066251, -0.000584233784708843, 0.000522097476268968,
0.000543092880677776, 0.000947121210698398, -0.00241810275096377,
0.00181893137435019, 0.000931873879297385, 0.000512116215015013,
0.000724985702444059, -0.000566713495050664, 0.000603953591362227
)
After fitting the data look like the following (empirical histogram-blue, theoretical histogram-orange):
The same when include freq=FALSE in hist
This will all be due to anomalous values in a not represented by the histogram you've shown. This could be the cause of both the very high kurtotsis, and the vgFit() algorithm failing to find a good fit.
Type dput(a[abs(a) > 5e-4]) in the console and copy the output into your question. People then may be able to recreate aomething like the vector a without having to get all 16000 values and debug the vgFit issue.
Thanks for the extra data. There are some extreme values in there, but I don;t think those are what is causing the problem in vgFit. Fitting 4 parameters which can be almost any value is difficult, but you can help it along by rescaling your data to something typical. Try this:
b <- (a-mean(a))/sd(a)
vgf <- vgFit(b)
vgf$param
VG <- rvg(16000, param = vgf$param)
VG_rescaled <- VG*sd(a)+mean(a)
hist(VG_rescaled, breaks=140, col="orange", main="", xlab="Value")
and see if the two histograms are close enough now.
I am analyzing changes in unique users' ratings for different movies in time. In order to find significant changepoints in time, I am using the 'changepoint' package and the PELT method.
I understand that there are different types of penalties, however, I
am still unsure which one to use.
I tried to make an elbow plot to see the optimal number of changes,
but somehow it does not work. Here is what I have so far, based on,
for example, the movie "Inception".
Also, are all changepoints significant? Is there a way to prove
significance?
My data: timestamp_date = date; cummean = all ratings for the day:
timestamp_date cummean
18-07-2010 4.15384615
19-07-2010 4.23809524
20-07-2010 4.23880597
21-07-2010 4.24390244
22-07-2010 4.19387755
23-07-2010 4.21186441
24-07-2010 4.23758865
25-07-2010 4.28804348
26-07-2010 4.32126697
27-07-2010 4.34063745
28-07-2010 4.36330935
29-07-2010 4.35521886
30-07-2010 4.35448916
31-07-2010 4.34005764
1-08-2010 4.34741144
2-08-2010 4.35604113
3-08-2010 4.34725537
4-08-2010 4.33073497
5-08-2010 4.34051724
6-08-2010 4.34114053
7-08-2010 4.3467433
8-08-2010 4.32909091
9-08-2010 4.32901554
10-08-2010 4.32171799
11-08-2010 4.32316119
12-08-2010 4.32375189
13-08-2010 4.32532751
14-08-2010 4.32932011
15-08-2010 4.32855191
16-08-2010 4.33266932
17-08-2010 4.33246415
18-08-2010 4.33312102
19-08-2010 4.32982673
20-08-2010 4.33212121
21-08-2010 4.33195755
22-08-2010 4.33198614
23-08-2010 4.33370913
24-08-2010 4.3342511
25-08-2010 4.33441208
26-08-2010 4.33439153
27-08-2010 4.33541018
28-08-2010 4.331643
29-08-2010 4.32954545
30-08-2010 4.32992203
31-08-2010 4.330468
1-09-2010 4.33002833
2-09-2010 4.32679739
3-09-2010 4.32763401
4-09-2010 4.33091568
5-09-2010 4.33081033
6-09-2010 4.3289358
7-09-2010 4.33072917
8-09-2010 4.33104631
9-09-2010 4.33347422
10-09-2010 4.33430962
11-09-2010 4.33251029
12-09-2010 4.33292782
13-09-2010 4.33360129
14-09-2010 4.33359936
15-09-2010 4.33307024
16-09-2010 4.33268025
17-09-2010 4.33256528
18-09-2010 4.33358548
19-09-2010 4.33247232
20-09-2010 4.33734088
21-09-2010 4.33758621
22-09-2010 4.34044715
23-09-2010 4.34026846
24-09-2010 4.33878505
25-09-2010 4.33542631
26-09-2010 4.33409836
27-09-2010 4.33268482
28-09-2010 4.3332256
29-09-2010 4.33451157
30-09-2010 4.33545108
1-10-2010 4.33470032
2-10-2010 4.33550995
3-10-2010 4.33374384
4-10-2010 4.33455882
5-10-2010 4.33638026
6-10-2010 4.33704819
7-10-2010 4.33871933
8-10-2010 4.33881579
9-10-2010 4.33718861
10-10-2010 4.33931725
11-10-2010 4.34020918
12-10-2010 4.33927545
13-10-2010 4.33714286
14-10-2010 4.33730835
My code:
inds <- seq(as.Date("2010-07-18"), as.Date("2010-10-14"), by = "day")
myts <- ts(inception$cummean, start = c(2010, as.numeric(format(inds[1], "%j"))), frequency = 365)
#single changepoint: method AMOC
cpt <- changepoint::cpt.meanvar(myts)
cpts(cpt)
cpts.ts(cpt)
param.est(cpt)
plot(cpt)
summary(cpt)
#multiple changepoints: method PELT
mcpt <- changepoint::cpt.meanvar(myts, method = "PELT")
cpts(mcpt)
cpts.ts(mcpt)
param.est(mcpt)
ncpts(mcpt)
plot(mcpt)
summary(mcpt)
Also, as I use a ts.object, I cannot convert the date to appear right when I plot cpt, what am I doing wrong?
Thank you!!
We are trying to decompose a time series in R and we are able to do it but the results do not look right.
Here's the data with time stamps:
"_time","dummy_data"
"2017-02-05T00:00:00.000-0500","205.472222"
"2017-02-05T01:00:00.000-0500","169.443611"
"2017-02-05T02:00:00.000-0500","156.011944"
"2017-02-05T03:00:00.000-0500","177.169722"
"2017-02-05T04:00:00.000-0500","219.049167"
"2017-02-05T05:00:00.000-0500","215.821667"
"2017-02-05T06:00:00.000-0500","214.983333"
"2017-02-05T07:00:00.000-0500","246.723889"
"2017-02-05T08:00:00.000-0500","343.308889"
"2017-02-05T09:00:00.000-0500","473.200278"
"2017-02-05T10:00:00.000-0500","390.223333"
"2017-02-05T11:00:00.000-0500","373.974444"
"2017-02-05T12:00:00.000-0500","639.402500"
"2017-02-05T13:00:00.000-0500","512.378611"
"2017-02-05T14:00:00.000-0500","428.824444"
"2017-02-05T15:00:00.000-0500","477.611944"
"2017-02-05T16:00:00.000-0500","534.378611"
"2017-02-05T17:00:00.000-0500","716.046944"
"2017-02-05T18:00:00.000-0500","470.218056"
"2017-02-05T19:00:00.000-0500","411.426389"
"2017-02-05T20:00:00.000-0500","393.147222"
"2017-02-05T21:00:00.000-0500","368.726389"
"2017-02-05T22:00:00.000-0500","357.958056"
"2017-02-05T23:00:00.000-0500","379.284722"
"2017-02-06T00:00:00.000-0500","273.403056"
"2017-02-06T01:00:00.000-0500","269.764167"
"2017-02-06T02:00:00.000-0500","233.650000"
"2017-02-06T03:00:00.000-0500","227.802222"
"2017-02-06T04:00:00.000-0500","313.731389"
"2017-02-06T05:00:00.000-0500","327.502778"
"2017-02-06T06:00:00.000-0500","333.327500"
"2017-02-06T07:00:00.000-0500","393.542778"
"2017-02-06T08:00:00.000-0500","659.569167"
"2017-02-06T09:00:00.000-0500","770.509444"
"2017-02-06T10:00:00.000-0500","1037.536667"
"2017-02-06T11:00:00.000-0500","935.926667"
"2017-02-06T12:00:00.000-0500","791.124722"
"2017-02-06T13:00:00.000-0500","903.093889"
"2017-02-06T14:00:00.000-0500","802.309167"
"2017-02-06T15:00:00.000-0500","792.085000"
"2017-02-06T16:00:00.000-0500","728.378056"
"2017-02-06T17:00:00.000-0500","740.647222"
"2017-02-06T18:00:00.000-0500","737.986111"
"2017-02-06T19:00:00.000-0500","502.763056"
"2017-02-06T20:00:00.000-0500","475.400556"
"2017-02-06T21:00:00.000-0500","522.482500"
"2017-02-06T22:00:00.000-0500","410.664722"
"2017-02-06T23:00:00.000-0500","370.423611"
"2017-02-07T00:00:00.000-0500","278.871667"
"2017-02-07T01:00:00.000-0500","290.182500"
"2017-02-07T02:00:00.000-0500","220.329167"
"2017-02-07T03:00:00.000-0500","252.641944"
"2017-02-07T04:00:00.000-0500","355.666667"
"2017-02-07T05:00:00.000-0500","273.100833"
"2017-02-07T06:00:00.000-0500","315.117778"
"2017-02-07T07:00:00.000-0500","359.764167"
"2017-02-07T08:00:00.000-0500","691.946944"
"2017-02-07T09:00:00.000-0500","941.796667"
"2017-02-07T10:00:00.000-0500","859.472222"
"2017-02-07T11:00:00.000-0500","949.285278"
"2017-02-07T12:00:00.000-0500","790.790833"
"2017-02-07T13:00:00.000-0500","952.915000"
"2017-02-07T14:00:00.000-0500","1136.490278"
"2017-02-07T15:00:00.000-0500","1175.359444"
"2017-02-07T16:00:00.000-0500","859.848889"
"2017-02-07T17:00:00.000-0500","718.357778"
"2017-02-07T18:00:00.000-0500","698.445278"
"2017-02-07T19:00:00.000-0500","630.867778"
"2017-02-07T20:00:00.000-0500","485.426389"
"2017-02-07T21:00:00.000-0500","571.723056"
"2017-02-07T22:00:00.000-0500","458.161944"
"2017-02-07T23:00:00.000-0500","336.733333"
"2017-02-08T00:00:00.000-0500","344.001111"
"2017-02-08T01:00:00.000-0500","315.671111"
"2017-02-08T02:00:00.000-0500","285.107778"
"2017-02-08T03:00:00.000-0500","281.013611"
"2017-02-08T04:00:00.000-0500","260.244722"
"2017-02-08T05:00:00.000-0500","233.998056"
"2017-02-08T06:00:00.000-0500","260.235833"
"2017-02-08T07:00:00.000-0500","362.811944"
"2017-02-08T08:00:00.000-0500","633.142500"
"2017-02-08T09:00:00.000-0500","872.285278"
"2017-02-08T10:00:00.000-0500","938.051389"
"2017-02-08T11:00:00.000-0500","951.735278"
"2017-02-08T12:00:00.000-0500","967.694444"
"2017-02-08T13:00:00.000-0500","960.494167"
"2017-02-08T14:00:00.000-0500","1039.334444"
"2017-02-08T15:00:00.000-0500","808.363889"
"2017-02-08T16:00:00.000-0500","661.919722"
"2017-02-08T17:00:00.000-0500","604.166944"
"2017-02-08T18:00:00.000-0500","464.267500"
"2017-02-08T19:00:00.000-0500","425.867500"
"2017-02-08T20:00:00.000-0500","537.951111"
"2017-02-08T21:00:00.000-0500","528.523611"
"2017-02-08T22:00:00.000-0500","401.029444"
"2017-02-08T23:00:00.000-0500","396.677778"
"2017-02-09T00:00:00.000-0500","263.640833"
"2017-02-09T01:00:00.000-0500","233.905278"
"2017-02-09T02:00:00.000-0500","202.222778"
"2017-02-09T03:00:00.000-0500","194.326944"
"2017-02-09T04:00:00.000-0500","208.162222"
"2017-02-09T05:00:00.000-0500","257.111667"
"2017-02-09T06:00:00.000-0500","277.464444"
"2017-02-09T07:00:00.000-0500","403.655000"
"2017-02-09T08:00:00.000-0500","700.535278"
"2017-02-09T09:00:00.000-0500","888.195278"
"2017-02-09T10:00:00.000-0500","690.172778"
"2017-02-09T11:00:00.000-0500","822.210556"
"2017-02-09T12:00:00.000-0500","801.144167"
"2017-02-09T13:00:00.000-0500","983.958056"
"2017-02-09T14:00:00.000-0500","1003.791111"
"2017-02-09T15:00:00.000-0500","1085.289722"
"2017-02-09T16:00:00.000-0500","740.004167"
"2017-02-09T17:00:00.000-0500","616.664444"
"2017-02-09T18:00:00.000-0500","473.841389"
"2017-02-09T19:00:00.000-0500","570.906944"
"2017-02-09T20:00:00.000-0500","568.685000"
"2017-02-09T21:00:00.000-0500","547.024722"
"2017-02-09T22:00:00.000-0500","369.073889"
"2017-02-09T23:00:00.000-0500","431.275833"
"2017-02-10T00:00:00.000-0500","211.516667"
"2017-02-10T01:00:00.000-0500","169.348611"
"2017-02-10T02:00:00.000-0500","185.133611"
"2017-02-10T03:00:00.000-0500","173.875278"
"2017-02-10T04:00:00.000-0500","250.226667"
"2017-02-10T05:00:00.000-0500","237.783056"
"2017-02-10T06:00:00.000-0500","247.450000"
"2017-02-10T07:00:00.000-0500","375.930278"
"2017-02-10T08:00:00.000-0500","605.365000"
"2017-02-10T09:00:00.000-0500","647.407500"
"2017-02-10T10:00:00.000-0500","714.873889"
"2017-02-10T11:00:00.000-0500","767.262778"
"2017-02-10T12:00:00.000-0500","643.721389"
"2017-02-10T13:00:00.000-0500","653.969722"
"2017-02-10T14:00:00.000-0500","656.156111"
"2017-02-10T15:00:00.000-0500","763.260833"
"2017-02-10T16:00:00.000-0500","579.947778"
"2017-02-10T17:00:00.000-0500","734.142500"
"2017-02-10T18:00:00.000-0500","636.389722"
"2017-02-10T19:00:00.000-0500","360.105833"
"2017-02-10T20:00:00.000-0500","438.675278"
"2017-02-10T21:00:00.000-0500","420.990833"
"2017-02-10T22:00:00.000-0500","343.326111"
"2017-02-10T23:00:00.000-0500","293.787778"
"2017-02-11T00:00:00.000-0500","282.809444"
"2017-02-11T01:00:00.000-0500","249.653889"
"2017-02-11T02:00:00.000-0500","163.781111"
"2017-02-11T03:00:00.000-0500","245.236111"
"2017-02-11T04:00:00.000-0500","284.649444"
"2017-02-11T05:00:00.000-0500","337.534167"
"2017-02-11T06:00:00.000-0500","258.772222"
"2017-02-11T07:00:00.000-0500","322.805833"
"2017-02-11T08:00:00.000-0500","380.436667"
"2017-02-11T09:00:00.000-0500","523.488056"
"2017-02-11T10:00:00.000-0500","478.361111"
"2017-02-11T11:00:00.000-0500","422.119722"
"2017-02-11T12:00:00.000-0500","425.315000"
"2017-02-11T13:00:00.000-0500","465.892222"
"2017-02-11T14:00:00.000-0500","412.729167"
"2017-02-11T15:00:00.000-0500","493.920000"
"2017-02-11T16:00:00.000-0500","381.506667"
"2017-02-11T17:00:00.000-0500","458.291667"
"2017-02-11T18:00:00.000-0500","433.393611"
"2017-02-11T19:00:00.000-0500","415.926389"
"2017-02-11T20:00:00.000-0500","349.008056"
"2017-02-11T21:00:00.000-0500","353.280000"
"2017-02-11T22:00:00.000-0500","399.022778"
"2017-02-11T23:00:00.000-0500","316.480556"
"2017-02-12T00:00:00.000-0500","252.727222"
"2017-02-12T01:00:00.000-0500","274.278333"
"2017-02-12T02:00:00.000-0500","269.609444"
"2017-02-12T03:00:00.000-0500","221.645278"
"2017-02-12T04:00:00.000-0500","294.641389"
"2017-02-12T05:00:00.000-0500","347.502222"
"2017-02-12T06:00:00.000-0500","313.468333"
"2017-02-12T07:00:00.000-0500","330.429722"
"2017-02-12T08:00:00.000-0500","369.703333"
"2017-02-12T09:00:00.000-0500","518.679167"
"2017-02-12T10:00:00.000-0500","542.199167"
"2017-02-12T11:00:00.000-0500","475.780833"
"2017-02-12T12:00:00.000-0500","419.468056"
"2017-02-12T13:00:00.000-0500","447.899444"
"2017-02-12T14:00:00.000-0500","526.429722"
"2017-02-12T15:00:00.000-0500","517.046111"
"2017-02-12T16:00:00.000-0500","515.500833"
"2017-02-12T17:00:00.000-0500","631.053056"
"2017-02-12T18:00:00.000-0500","708.575000"
"2017-02-12T19:00:00.000-0500","453.120000"
"2017-02-12T20:00:00.000-0500","554.589444"
"2017-02-12T21:00:00.000-0500","453.551389"
"2017-02-12T22:00:00.000-0500","419.450556"
"2017-02-12T23:00:00.000-0500","328.177778"
"2017-02-13T00:00:00.000-0500","293.752500"
"2017-02-13T01:00:00.000-0500","246.943889"
"2017-02-13T02:00:00.000-0500","213.986944"
"2017-02-13T03:00:00.000-0500","219.086111"
"2017-02-13T04:00:00.000-0500","303.708611"
"2017-02-13T05:00:00.000-0500","353.969167"
"2017-02-13T06:00:00.000-0500","346.050833"
"2017-02-13T07:00:00.000-0500","470.292222"
"2017-02-13T08:00:00.000-0500","844.538056"
"2017-02-13T09:00:00.000-0500","1100.996667"
"2017-02-13T10:00:00.000-0500","1271.799167"
"2017-02-13T11:00:00.000-0500","1447.440000"
"2017-02-13T12:00:00.000-0500","1034.428611"
"2017-02-13T13:00:00.000-0500","1076.172222"
"2017-02-13T14:00:00.000-0500","1087.887222"
"2017-02-13T15:00:00.000-0500","1259.043333"
"2017-02-13T16:00:00.000-0500","1140.602778"
"2017-02-13T17:00:00.000-0500","1148.073889"
"2017-02-13T18:00:00.000-0500","761.544722"
"2017-02-13T19:00:00.000-0500","568.453056"
"2017-02-13T20:00:00.000-0500","574.121667"
"2017-02-13T21:00:00.000-0500","458.542500"
"2017-02-13T22:00:00.000-0500","495.431389"
"2017-02-13T23:00:00.000-0500","404.716111"
"2017-02-14T00:00:00.000-0500","412.116667"
"2017-02-14T01:00:00.000-0500","310.014444"
"2017-02-14T02:00:00.000-0500","236.658333"
"2017-02-14T03:00:00.000-0500","222.509167"
"2017-02-14T04:00:00.000-0500","315.510556"
"2017-02-14T05:00:00.000-0500","369.872778"
"2017-02-14T06:00:00.000-0500","334.670000"
"2017-02-14T07:00:00.000-0500","461.795000"
"2017-02-14T08:00:00.000-0500","753.752222"
"2017-02-14T09:00:00.000-0500","923.558333"
"2017-02-14T10:00:00.000-0500","1107.344722"
"2017-02-14T11:00:00.000-0500","1194.949722"
"2017-02-14T12:00:00.000-0500","937.735833"
"2017-02-14T13:00:00.000-0500","1068.374722"
"2017-02-14T14:00:00.000-0500","1145.634167"
"2017-02-14T15:00:00.000-0500","988.993889"
"2017-02-14T16:00:00.000-0500","1067.995278"
"2017-02-14T17:00:00.000-0500","927.699722"
"2017-02-14T18:00:00.000-0500","739.886389"
"2017-02-14T19:00:00.000-0500","667.679722"
"2017-02-14T20:00:00.000-0500","604.938333"
"2017-02-14T21:00:00.000-0500","543.166667"
"2017-02-14T22:00:00.000-0500","442.916944"
"2017-02-14T23:00:00.000-0500","373.767778"
"2017-02-15T00:00:00.000-0500","337.545833"
"2017-02-15T01:00:00.000-0500","259.629167"
"2017-02-15T02:00:00.000-0500","186.775556"
"2017-02-15T03:00:00.000-0500","212.818611"
"2017-02-15T04:00:00.000-0500","274.319722"
"2017-02-15T05:00:00.000-0500","308.578056"
"2017-02-15T06:00:00.000-0500","316.756389"
"2017-02-15T07:00:00.000-0500","417.723611"
"2017-02-15T08:00:00.000-0500","841.546944"
"2017-02-15T09:00:00.000-0500","1067.051111"
"2017-02-15T10:00:00.000-0500","1109.526389"
"2017-02-15T11:00:00.000-0500","1087.352222"
"2017-02-15T12:00:00.000-0500","1045.260000"
"2017-02-15T13:00:00.000-0500","1285.351389"
"2017-02-15T14:00:00.000-0500","1064.570833"
"2017-02-15T15:00:00.000-0500","1067.725556"
"2017-02-15T16:00:00.000-0500","1055.146111"
"2017-02-15T17:00:00.000-0500","1014.010833"
"2017-02-15T18:00:00.000-0500","720.152500"
"2017-02-15T19:00:00.000-0500","732.987778"
"2017-02-15T20:00:00.000-0500","758.056111"
"2017-02-15T21:00:00.000-0500","799.688611"
"2017-02-15T22:00:00.000-0500","766.204722"
"2017-02-15T23:00:00.000-0500","722.300000"
"2017-02-16T00:00:00.000-0500","507.248333"
"2017-02-16T01:00:00.000-0500","424.247778"
"2017-02-16T02:00:00.000-0500","390.718056"
"2017-02-16T03:00:00.000-0500","364.996944"
"2017-02-16T04:00:00.000-0500","383.408889"
"2017-02-16T05:00:00.000-0500","414.637778"
"2017-02-16T06:00:00.000-0500","349.056667"
"2017-02-16T07:00:00.000-0500","542.903889"
"2017-02-16T08:00:00.000-0500","878.198056"
"2017-02-16T09:00:00.000-0500","1137.686389"
"2017-02-16T10:00:00.000-0500","1277.625278"
"2017-02-16T11:00:00.000-0500","1184.350278"
"2017-02-16T12:00:00.000-0500","923.879444"
"2017-02-16T13:00:00.000-0500","1066.437500"
"2017-02-16T14:00:00.000-0500","1290.296667"
"2017-02-16T15:00:00.000-0500","1026.999722"
"2017-02-16T16:00:00.000-0500","949.582500"
"2017-02-16T17:00:00.000-0500","857.506111"
"2017-02-16T18:00:00.000-0500","831.030278"
"2017-02-16T19:00:00.000-0500","720.440556"
"2017-02-16T20:00:00.000-0500","492.239167"
"2017-02-16T21:00:00.000-0500","508.844722"
"2017-02-16T22:00:00.000-0500","559.846667"
"2017-02-16T23:00:00.000-0500","332.631389"
"2017-02-17T00:00:00.000-0500","349.220833"
"2017-02-17T01:00:00.000-0500","237.833333"
"2017-02-17T02:00:00.000-0500","202.662778"
"2017-02-17T03:00:00.000-0500","232.843889"
"2017-02-17T04:00:00.000-0500","316.059167"
"2017-02-17T05:00:00.000-0500","338.066667"
"2017-02-17T06:00:00.000-0500","363.631389"
"2017-02-17T07:00:00.000-0500","460.921944"
"2017-02-17T08:00:00.000-0500","764.931111"
"2017-02-17T09:00:00.000-0500","931.416944"
"2017-02-17T10:00:00.000-0500","1032.328611"
"2017-02-17T11:00:00.000-0500","1247.801111"
"2017-02-17T12:00:00.000-0500","1159.197500"
"2017-02-17T13:00:00.000-0500","1282.267222"
"2017-02-17T14:00:00.000-0500","1183.746667"
"2017-02-17T15:00:00.000-0500","992.880278"
"2017-02-17T16:00:00.000-0500","791.148611"
"2017-02-17T17:00:00.000-0500","599.060278"
"2017-02-17T18:00:00.000-0500","487.915556"
"2017-02-17T19:00:00.000-0500","492.801111"
"2017-02-17T20:00:00.000-0500","413.024167"
"2017-02-17T21:00:00.000-0500","632.193056"
"2017-02-17T22:00:00.000-0500","493.108611"
"2017-02-17T23:00:00.000-0500","424.018889"
"2017-02-18T00:00:00.000-0500","384.328056"
"2017-02-18T01:00:00.000-0500","310.441944"
"2017-02-18T02:00:00.000-0500","205.145556"
"2017-02-18T03:00:00.000-0500","205.454167"
"2017-02-18T04:00:00.000-0500","253.227500"
"2017-02-18T05:00:00.000-0500","312.188889"
"2017-02-18T06:00:00.000-0500","321.928889"
"2017-02-18T07:00:00.000-0500","406.977778"
"2017-02-18T08:00:00.000-0500","452.448889"
"2017-02-18T09:00:00.000-0500","502.578333"
"2017-02-18T10:00:00.000-0500","489.765278"
"2017-02-18T11:00:00.000-0500","540.568333"
"2017-02-18T12:00:00.000-0500","510.270000"
"2017-02-18T13:00:00.000-0500","456.691944"
"2017-02-18T14:00:00.000-0500","494.579722"
"2017-02-18T15:00:00.000-0500","502.795556"
"2017-02-18T16:00:00.000-0500","429.950556"
"2017-02-18T17:00:00.000-0500","428.196667"
"2017-02-18T18:00:00.000-0500","478.975833"
"2017-02-18T19:00:00.000-0500","362.479167"
"2017-02-18T20:00:00.000-0500","366.515000"
"2017-02-18T21:00:00.000-0500","400.625833"
"2017-02-18T22:00:00.000-0500","374.313056"
"2017-02-18T23:00:00.000-0500","310.666667"
We use the following code to load and decompose this time series:
library("forecast")
data <- read.csv("data.csv")
x <- msts(data, seasonal.periods=c(24,168))
decom <- decompose(x[,2], "multiplicative")
plot(decom)
The decomposition looks like this:
The 'observed' and 'seasonal' components looks almost identical, the 'trend' doesn't seem right since it is rising up too sharply, and the 'random' component looks constant.
So we are not sure if we made a mistake in decomposing or loading this time series in R. Is there another way of decomposing this time series so that it makes more sense or is correct? Should we be loading the data another way so that the time stamps get properly assigned to the data values?
We have time series data with some seasonality from the past 4 years. We want to predict the general rise in trend next year. For this, we decomposed the time series and observed the trend line:
However, this trend line is placed in the middle of the values rather than the values themselves. We are not satisfied with simply extrapolating this trend line since it falls very short of expected traffic.
Since we are interested in only the general rise in trend and not the seasonality, we remove the seasonality from the components:
mydata <- read.csv("values.csv")
mydataseries <- ts(mydata, start=c(2012,1,1),frequency = 365.25
mydataseriescomponents <- decompose(mydataseries)
mydataseriesminusseasons <- mydataseries - mydataseriescomponents$seasonal
We are now trying to fit a loess() curve in R around this time series data minus the seasonal component, that is mydataseriesminusseasons:
855154881.9
1027395443
1132284155
944870172.3
898459083.9
845115286.7
204393180.2
-75788428.32
-184120868.7
-164634776
-190543808.7
-43973009.39
-452418843.2
-1065106918
-1194545584
-1250333168
-379435027.4
-151057609.1
134304962.6
37020062.65
-307740042.8
-309480234.5
-388529539.7
-379333445.3
-193124460
-663765015.3
-100597898.3
-327949890.1
-429500583.5
-1321506072
-1444202356
-369913100.7
-715237274.1
-83507361.25
-328296509.9
-409957935.1
-1351211680
-533631519.6
-882845870.8
-711202595.9
-147504975.3
-361087020.5
-392960561
-456709751.2
-1065209981
-2062128692
-1112973164
-914751976.5
-1377070656
-1903432323
-2110392180
-1984477186
-1434481986
-988902503.8
-944477878.3
-1388889111
-1559730054
-1668752977
-1590459585
-1528272998
-850923022
-542720361.8
-791860111.9
-1057854181
-852120155.6
-810625768.1
-56185632.59
576968488.7
691371629.9
160486150.2
-308533580.1
-261619133.2
-404620378.3
740114544.5
1006206606
622867052.1
-71219884.82
-39173777.42
-533631907.8
-709943766.3
-565909169.9
-968499911.2
-1056539190
-1266350530
-1445031918
-1579156208
-1550356091
-1316401212
-899907725.4
-681646243
-996858524.4
-1261573594
-1620842348
-1529532466
-1107218074
287538766
303061371.4
-382291371.7
-639757694.3
-737369705.5
-732118809.2
-393825621.1
-810602326.3
-1044759123
-1410535140
-1636325717
-1646415420
-1514426422
-1241825553
31448256.14
64762654.11
-513468522.6
-676115681.9
-191498426
-86743267.18
80585792.24
538395944.8
262807408.8
-156283609.7
-72157485.31
-56386961.34
-14257457.85
233362524.8
495465812.9
354441383.3
74975465.29
28985451.46
187381822.2
517857439.4
940857149.4
1397097814
1965769992
1735207534
1568036010
1496104390
1647402384
928936108
1372629124
1417356139
1168474219
1080545493
996524274.5
988026158.1
1060004940
1315522041
1444552768
1438503151
1174067300
1063743311
1086528293
1310565938
1542624917
1504331433
1280216655
1726223821
1670308928
1120574360
1084897870
1285908119
1232985139
1101293494
1081075441
881717495.1
975005126.7
1058436909
1290433280
1288259727
1038856967
1006240656
891910425.2
920601850.4
981585788.8
1536507833
1546018200
1149902811
1230460988
1191817042
1161287112
1273239958
1590385882
1538451838
1242359113
913747727.7
888013837.2
934884821.1
1198395868
1277044767
1235456131
963043028
925500611.4
921906159.7
957528730.9
934517634.5
1183155135
1155142736
893512199.3
829955361
839182104.7
904102148.6
972879836.6
1227504663
1192420215
904137203.4
944756516
1375037708
1328414157
1779424344
1921248556
1899629843
1773839270
1565431502
1592386775
1825650269
1404794363
1393784791
1416771770
1288386476
1289239680
815093905.4
681990799.1
783953618.4
1103067833
1182429773
933897907.8
874114515.6
787403408.5
860338795
1052657878
1297180989
1245476158
1014316130
1004606484
735958898.4
575505161.4
588750452.3
803692654.7
833093724.3
531996754.3
199110366.8
-18901281.1
-6413198.146
-33290860.64
252073940.6
203247618.9
-164091120.7
-501720846.4
-865543851.3
-856086326
-612355346.3
400846624.1
511862726
288735892.8
-127533264.3
-940372573.2
-155917893.1
-699989731.6
-320401187.5
-277824927.9
-705440125.7
-1042182377
-1206106831
-1339738778
-165282703.3
222304361.4
136773204.1
-224139914.3
-271723348.1
-288223577.8
-285482682.4
-1057479814
-1059799528
-960773269.6
-1378106942
-1682462197
-1880270405
-1877392694
-1621410466
-1218560480
387109224.3
85424610.03
-558048286.6
-432347510.8
-107370046
224698124.4
732906395.5
-523071744.4
-1239504492
-1798916179
-2065361083
-1987860160
-1725292219
-1109123667
-971275176.7
-1420498329
-1889158526
-1136864728
-1002777887
647298007.9
1277421457
248465769.8
-377527211.2
-724681515.2
-967478152.4
-947666627.1
-734506065.3
-408053802.2
-241421840.8
-363715586.3
-829237162.5
-929529173.2
-260432788.4
-67756618.13
242997207.2
567370574.9
128921994
-159670249.1
-226982681.8
-240623081
-26502753.8
311495394.1
477285225.3
198408156.8
-195753985.4
-271887709.5
-196538766.7
-72464893.44
180860168.9
360960891.9
147945699.2
-29352193.17
325127464.9
960490365.6
1453481987
1424677454
1207446280
537281902.1
-167977127.5
-505612366.5
-1460096451
-1554214240
-1472813276
-1158137635
-1079634747
-1400116741
-1623247577
-1720625509
-1291068926
-541823228.2
423680238
828606261.2
651175802
588260033.4
511022741
644493024.6
696908085.1
949150687.9
1037411745
754948966.3
790033725.6
1053226989
1170333305
1056602964
1081413405
1135864583
971795777.8
855154881.9
1027395443
1132284155
944870172.3
896319497.9
845115286.7
204393180.2
-75788428.32
-184120868.7
-164634776
-190543808.7
-43973009.39
-452418843.2
-1065106918
-1194545584
-1250333168
-379435027.4
-151057609.1
139705076.6
37020062.65
-307740042.8
-309480234.5
-388529539.7
-379333445.3
-193124460
1308430606
-100597898.3
-327949890.1
-429500583.5
-1321506072
-1444202356
-369913100.7
1419976593
180125360.7
-328296509.9
-409957935.1
-1351211680
-533631519.6
1246061777
1639641696
272442819.7
-361087020.5
-392960561
-456709751.2
1014735303
478499133.8
-748455756.5
-914751976.5
-1377070656
-1903432323
-2110392180
-1984477186
-1434481986
-988902503.8
-944477878.3
-1388889111
-1559730054
-1668752977
-1590459585
-1528272998
-850923022
-542720361.8
-791860111.9
-1057854181
-852120155.6
-810625768.1
-56185632.59
576968488.7
681069818.9
160486150.2
-308533580.1
-261619133.2
-404620378.3
740114544.5
1006206606
622867052.1
-71219884.82
-39173777.42
-533631907.8
-709943766.3
-565909169.9
1641890896
1588111061
880069519.6
1090752417
1278890698
1335767912
1519822543
1812984581
1334545973
426228457.6
456951496.9
1228693380
1312355639
1637418032
691968559
303061371.4
-382291371.7
-639757694.3
-737369705.5
-732118809.2
-408383535.1
1630144553
1548715666
747397223.2
884268460.1
1205537489
1226277745
1637844137
477586396.1
64762654.11
-513468522.6
-676115681.9
-191498426
-86743267.18
80585792.24
538395944.8
262807408.8
-156283609.7
-72157485.31
-56386961.34
-14257457.85
233362524.8
495465812.9
354441383.3
74975465.29
28985451.46
187381822.2
517857439.4
940857149.4
1397097814
1479492584
1206235886
1230335054
1209244303
1772074811
1693077942
1461745247
1417356139
1168474219
1080545493
996524274.5
988026158.1
1059643199
1314652245
1440434637
1438503151
1174067300
1063743311
1086528293
1310565938
1542624917
1504331433
1280216655
1726223821
1670308928
1863627651
1882123871
2055914335
1992301669
1579375771
1533925079
1762629244
1838997943
1897919645
2107505072
1997289608
1464337865
1415561153
1676756233
1700040307
1783398157
1624554189
1546018200
1149902811
1230460988
1191817042
1161373475
1273239958
1590385882
1538451838
1242359113
913747727.7
888013837.2
934884821.1
1198395868
1277044767
1235456131
963043028
925500611.4
921906159.7
957528730.9
934517634.5
1183155135
1151401692
893512199.3
829955361
839182104.7
904102148.6
972879836.6
1227504663
1192420215
904137203.4
944756516
1375037708
1328414157
1193178073
1253502729
1251928059
1185271006
1244858293
1231640212
1171269572
1343448619
1393784791
1416771770
1288386476
1289239680
815093905.4
681990799.1
783953618.4
1103067833
1182429773
933897907.8
874114515.6
787403408.5
860338795
1052657878
1297180989
1245476158
1014316130
1004606484
735958898.4
575505161.4
588750452.3
803692654.7
833093724.3
531996754.3
199110366.8
-18901281.1
-6413198.146
-33290860.64
252073940.6
203247618.9
-164091120.7
-501720846.4
-865543851.3
-856086326
-612355346.3
400846624.1
511862726
288735892.8
-127533264.3
-940372573.2
-155917893.1
-699989731.6
-320401187.5
-277824927.9
-705440125.7
-1042182377
-1206106831
-1339738778
-165282703.3
222304361.4
136773204.1
-224139914.3
-271723348.1
-288223577.8
-285482682.4
410687500.7
1631841798
1553281634
713309450.5
649367763.9
960215164.3
1049107976
1148989485
1678375251
1164709303
183895982
465208739.4
766073381.2
586658157
853178118.4
1317822533
1674419406
693138111.6
610057420.2
928861116.6
1021382975
1317392280
1950890283
1753467250
679132043.8
530667904.1
1923321662
2445945599
2224779498
2205640478
2617939193
1771677175
1773936492
2444894838
2401384689
2491268212
2581667225
2449579792
1593738389
1956098689
2378730864
235226517.6
-67756618.13
242997207.2
567370574.9
128921994
-159670249.1
-226982681.8
-240623081
-26502753.8
311495394.1
477285225.3
198408156.8
-195753985.4
-271887709.5
-196538766.7
-72464893.44
180860168.9
360960891.9
147945699.2
-29352193.17
325127464.9
960490365.6
1453481987
1424677454
1207446280
537281902.1
-167977127.5
-505612366.5
1404374892
1613823539
1849271413
1936762445
1513383047
1256267888
1553901607
1655449233
1979063830
2224098910
2147758870
1612601292
1277373178
1489383946
1406268621
1510782787
1555473157
1721503681
1473734831
1214127421
1427159815
1454163770
1559572239
1693448937
1686056516
1534649610
1402815411
1597472633
1479661974
1572474919
1758527502
1912156129
2007806540
2577055685
3079863351
3189154952
3084552356
3020184398
3019956688
2361199448
1906290720
1878596097
1894542086
54727454.63
-151057609.1
134304962.6
37020062.65
-307740042.8
-309480234.5
-388529539.7
-379333445.3
-193124460
-663765015.3
-100597898.3
-327949890.1
-429500583.5
1538626202
1943756793
142960155.3
-715237274.1
-83507361.25
-328296509.9
-409957935.1
1469349471
-6715352.565
-882845870.8
-711202595.9
-147504975.3
-361087020.5
-392960561
-456709751.2
-1065125015
1006714631
2153142496
1804378762
1673270778
2693842453
3029003743
3091803034
2506604564
2457560591
2027821010
1756470132
2064844611
2119623546
2162263280
2002164168
1694641809
616667238.2
178971439.1
187991217
342780020.4
452558045.9
1221341191
1928282804
1898438088
2350801273
3271266186
3102579205
3404316683
1296736764
1006206606
622867052.1
-71219884.82
-39173777.42
777976197.2
831608580.7
1173972977
574093131.8
145884449.2
125630390.6
140647407.2
-1948845.745
-20569346.72
170376510.8
416953573.6
394780276
210086267.6
240846310.9
-4692367.437
13267344.2
462459409.2
1638331860
1368251762
844946221.3
908678722.7
858991700.5
821130809.8
1087001122
501346560.7
49030467.37
-115293555.8
-42916860.95
-94506694.82
65744337.46
214422930.7
1246493179
948746467.1
450984956.4
906168925.1
55072855.99
-86742286.18
80586773.24
538396925.8
262808389.8
-156282628.7
-72156504.31
-56385980.34
-14256476.85
233363505.8
495466793.9
354442365.3
74976446.29
28986433.46
187382803.2
517858420.4
940858130.4
1397098796
1479493565
1206236868
1230336035
1209245284
1021481495
1358007248
1908140672
1690817796
1450430426
1573572004
1548289864
1518408336
1551340078
1800682764
1691240562
1675755235
1422581675
1551622923
1630779709
1361558060
1542625898
1504332415
1280217636
1726224802
1670309909
1120575341
1084898851
1285909100
1226741796
1101294475
1081076422
881718476.1
975006107.7
1058437890
1290434261
1288260708
1038857948
1006241637
891911406.2
920602831.4
981586769.8
1536508814
1546019181
1149903793
1230461969
1191818023
1161288092
1273240939
1590386863
1538452819
1242360094
913748708.7
888014818.2
934885802.1
1198396849
1277045748
1235457112
963044009
925501591.4
921907140.7
957529712.9
934518615.5
1183156116
1151402673
893513180.3
829956342
839183085.7
904103129.6
972880817.6
1227505644
1192421196
904138184.4
944757497
1375038689
1328415139
1193189782
1253504218
1251929547
1185272494
1244859781
1231641700
1171271060
1343450107
1393786279
1416773258
1288387964
1289241168
1276942382
1223342782
1265179173
1582950274
1549362846
1289741511
1522844687
1575762386
1623981295
1140018366
1297182477
1245477646
1014317618
1004607972
3339996446
2617836416
2598501271
2725463672
2379954942
2430902194
3387783330
4057325882
3941464221
4026010913
3593315188
3218647755
2899429341
3156298547
3453939489
3535652872
3957490786
2127115167
1652343230
1644069350
1408460965
3374914231
1354451507
3451778958
4125068975
3062203905
2860803149
3523217492
3446260128
4086491216
1353224655
1786887688
1329952369
1262946794
1434089723
1426765711
1394483892
3184736742
3585370070
2492338381
2870647454
3422458727
3496074936
3440427221
3488297885
3411694273
1862226333
2347786389
2984492965
2832984919
2706245540
2975365013
2750770215
2329108891
2668972592
3485974677
3498308730
3651172133
4020199587
3953317903
2733969884
2903235323
3953139670
4668898648
4652525612
4073702669
3715845753
3017343417
4181519935
4751974434
4619926728
4594101972
4732221475
4318140179
3780497707
4451918052
5012718317
4833179055
5653878208
5807608123
5396558840
4198373572
4884875793
5677377778
5912605893
5944449107
5747882280
5227572313
4478777171
4801671568
5862958412
6148995450
6002089979
5948770595
5519491673
4863435104
5079255850
5868770156
5542293262
4248733096
2766041977
2732273377
2763007960
3709017196
5826881003
5418281457
4464795375
4353979464
4041806357
3642750843
3991233296
4574288639
4505497973
4507525662
3759850718
2770466566
1884370202
2017997394
2536894291
2394368239
2561217637
2329522814
2238153751
1823017685
1985828850
2534460960
2292248472
2008277139
1792241233
1777656572
1763197595
1863541282
2165268053
2093475484
2045555081
1853852293
1858329332
1755509088
1713779365
1790957115
1574452597
1579659809
1670558649
1766876466
1623856630
2694719637
3768836252
3933201414
3980190714
4955559887
4938681336
4365493305
4568797166
5264823884
5274383182
5433866314
5417386015
5045165577
4013353224
4858457348
5313474135
5517720717
4442688396
4160415512
4888461743
3958104821
4567324340
5323056776
5488909281
4557331369
5223549360
4326783309
3764876526
4571173289
5423886480
5493146693
5626783987
4769215133
3238864341
3322242772
3840761593
4440231932
3952228746
3826102990
3642814617
3683433336
3290239564
3679644227
4401886050
4271007289
4331924299
4217934600
4322830334
3958867188
4735975510
5434096780
5704487461
5359613448
5223744170
3712806728
2381705672
2316848053
2396344551
1960261326
2098710139
1955760687
2933140424
2967171559
3746036475
5150516737
5103739176
4799974487
4940976107
4470787625
2874748403
3370617116
4116000776
3907376783
3879136871
3858305272
3498190930
2968939532
3482738547
4592541370
4548237451
4039300654
3954893868
3196099484
2977703338
3645589701
4866174649
5072864386
5232041565
5275606802
4693688082
3245094491
3790221336
4772983985
4581973930
4331144672
4167962637
3622317542
3760217425
4483667233
5577532419
5303025177
5677698961
5720893489
5385575901
4466914817
5021515141
5865735715
5703914224
5678717816
5600943246
5110447244
4590128626
4877035122
5442054864
5540200590
5229513831
4574668437
3734155348
2825747731
2665659550
3218611753
3177069031
3225833078
2857378098
2605242926
2290489544
2556941031
3052363819
3023655743
3139325913
3183875762
3084641745
2584707861
2573111682
2596449197
3119292036
3103807890
3003440326
3050225234
2639037382
2719271674
3174072606
2288642761
2407051251
2769659370
2792708736
2422258872
2550055714
3094896689
3167462954
3145311598
2982505987
2846929030
2410677820
2528516371
3317404595
3405548963
3264859256
3217887704
3076794348
2682319143
2752574869
3546644862
3387139453
3465822066
3527697761
3304648740
2671176465
2775904656
3369489444
3186975051
3265608930
3125970955
2336383605
2101672532
2227649209
3046717349
3161392531
3174174168
3069526988
3140929673
2396972936
2491933483
3274873818
3471396399
3449881421
3260944652
3059846681
2300326480
2410144424
3280639160
3165080129
1880734112
2026731745
1851573264
1593311358
1623039610
1888090770
1983714225
1990135314
1884610261
1966858510
1881518298
1817889199
2209334095
2213195958
3180360773
3506589476
3266458246
2314386847
2203488644
2979775043
2887785856
3029641480
2854946175
2971200632
2338656676
2508827357
3221768984
3271647981
1494100499
2557318665
2566743784
2024262236
2326858931
2898711691
2629767554
2418419575
2529673112
2517326919
2394071701
2882872031
3958018274
4398615549
4850186215
4769908627
3875047506
3686152334
3944845885
4407300286
5483421647
5150638137
5610203814
4608824221
3183456836
4173041229
5250468129
5281994707
5707036828
5352424541
5755606494
4561838923
5206514812
6017273753
5965257129
6031374315
6079040231
4379684817
2770833772
3855818791
4754914912
4592227424
4426284753
4410453960
4025381538
3174239722
3637497533
4441638488
4174099821
3906145103
3894032411
3032325960
2296152859
3634154800
5013642209
4862468183
4819578542
4516969809
3607317085
2438327317
3732908830
5107431888
4696140901
1856348267
1237864483
406427050.9
166776835.3
1498808575
1828048545
1624152578
1349901570
1420774156
998226407.7
1012022910
1532830520
1859891754
1422784584
1300680502
1969725485
1936125754
1730921235
2284540775
2480696530
2271292433
2177291835
2174315253
1943550394
1789789173
2208387982
2445973421
2180115879
2053590351
2057128187
1868753587
1794479025
2093710971
2310482091
1882157273
1506021669
1535469156
2038211764
2132884419
2539631965
2937476532
2237006540
1897259543
801631140.7
589473184.2
116334380.3
674275361.3
1282712559
1119202007
1004676722
781599593.7
1184057471
1405174402
2414122535
3215047803
3117104932
2843730513
2338714670
1830982498
1282357057
1398445510
1709185553
1343346425
1299455992
1382754660
1451688601
1355952002
1395566041
1646971917
1518132724
1378268909
1383505613
1477733701
1396182586
1340692285
1513095775
952400088.2
654084246.7
626929432.3
700786606
523798987.3
1212948425
1567710490
1072360130
1057312922
876650104.6
1532682661
1439342205
1801524855
2099113224
1992935512
2063753470
1849349346
1589462235
1341435771
1147947080
2071354378
2006092710
2105408195
1234206054
656144711.4
1208902786
1232216105
2213555415
2017146411
1991371378
994748835.5
1523018258
551904050.2
4489317425
7011882149
7509029269
7405531928
6627086822
5118361296
2929515389
4386298474
6193577031
6201888044
5600929516
5249637157
4071570693
3812427933
4814958529
6581889904
6706593436
6538328968
5770674289
5146640592
3869631764
5168489883
7218970135
7319257013
6818980598
6581026441
4463128268
2549197744
2751600290
3586655201
3073231312
2610229695
2664878334
2445857027
3333286739
5342397336
8218514365
7400486992
7351969323
6170498161
6166815740
4938259613
5123232548
6952344511
7484834076
7975757356
6042108897
3954139391
2561409558
3636287452
6659637045
6610145475
6303751643
5790815423
5286756045
532871596.2
2403662106
2933984545
2177296758
1954486433
1713519574
1459802901
4020142932
5383799348
6858179971
7112822894
6327294007
5759923625
5042533123
3796835736
5750880779
7453820307
7335397513
6962686301
7790660114
6724956363
5003169135
6701050938
7992041249
7756326177
7913301179
7741411043
6785177818
6284270117
6963921883
7785974652
7574222100
7588499293
5788919572
4105788142
2859825648
2924210471
4069907537
3895077405
3979654780
2075329893
1979403277
1632081713
1877890303
2412917344
3763581680
3726439732
3673898152
3345262416
2191053212
2548906553
3841133834
3846853011
3492242728
3479185981
3290714847
2514060721
2645599322
2791855040
3791586130
However, we are not familiar with the form of the loess() function and it seems to expect a formula which we do not know. We tried the following:
y <- c(mydata)
x <- 1:1614
lo <- loess(y~x)
We get the error: Error in model.frame.default(formula = y ~ x) :
invalid type (list) for variable 'y'
How do we fit a loess curve around the values to get the general trend line? Also, after removing the seasonal component we have some negative values for some reason. Would this affect the loess() curve?
I have a set of bivariate time series and want to resample them to the same length. I thought that it might be a good idea to use the mean length of all time series, since I wanted to avoid that some series will be shortened or extended too much. My first naive idea was using the resample method of the signal package, and resample each dimension of a series separately. I don't like this idea very much, since I have the fear that the alignment between the dimensions might suffer from the independent resampling, but I hoped this effect might be negligible.
My current problem is that the resampling of the data creates artifacts at the end and beginning of a series. It seems that the resample method assumes that the series starts from zero. Now I'm wondering if there is a more suitable resampling method which in the best case is readily available (in R) and maybe also supports bivariate time series.
Plot:
http://i.stack.imgur.com/3OwAt.png
Code example:
example <- c(-2014.1, -2014.1, -2014.1, -2014, -2014, -2013.9, -2013.9,
-2013.7, -2013.5, -2013.4, -2013.1, -2012.9, -2012.6, -2012.4,
-2012, -2011.7, -2011.4, -2011, -2010.5, -2010.1, -2009.5, -2009.1,
-2008.6, -2008, -2007.5, -2006.9, -2006.4, -2005.7, -2005.1,
-2004.4, -2003.7, -2003, -2002.4, -2001.5, -2000.7, -1999.9,
-1999.1, -1998.2, -1997.4, -1996.5, -1995.6, -1994.6, -1993.6,
-1992.6, -1991.7, -1990.7, -1989.7, -1988.9, -1987.9, -1986.9,
-1985.9, -1984.9, -1984, -1983, -1982.1, -1981.1, -1980.1, -1979.2,
-1978.2, -1977.2, -1976.4, -1975.4, -1974.4, -1973.4, -1972.4,
-1971.5, -1970.5, -1969.6, -1968.6, -1967.6, -1966.6, -1965.7,
-1964.7, -1963.9, -1962.9, -1961.9, -1960.9, -1959.9, -1958.9,
-1957.9, -1956.9, -1955.9, -1955, -1954, -1953, -1952.1, -1951.5,
-1951.1, -1950.6, -1950.1, -1949.6, -1949.2, -1948.7, -1948.2,
-1947.9, -1947.4, -1946.9, -1946.4, -1945.9, -1945.4, -1944.9,
-1944.4, -1943.9, -1943.4, -1943, -1942.5, -1942, -1941.5, -1941,
-1940.6, -1940.1, -1939.6, -1939.1, -1938.7, -1938.2, -1937.7,
-1937.2, -1936.7, -1936.2, -1935.7, -1935.4, -1934.9, -1934.4,
-1933.9, -1933.4, -1932.9, -1932.4, -1931.9, -1931.4, -1931,
-1930.5, -1930, -1929.5, -1929, -1928.6, -1928.1, -1927.6, -1927.1,
-1926.6, -1926.2, -1925.7, -1925.2, -1924.7, -1924.4, -1923.9,
-1923.4, -1922.9, -1922.4, -1921.9, -1921.4, -1920.9, -1920.4,
-1919.9, -1919.4, -1919, -1918.5, -1918, -1917.5, -1917, -1916.6,
-1916.1, -1915.6, -1915.1, -1914.6, -1914.2, -1913.7, -1913.2,
-1912.7, -1912.2, -1911.7, -1911.4, -1910.9, -1910.4, -1909.9,
-1909.4, -1908.9, -1908.4, -1907.9, -1907.5, -1906.9, -1906.5,
-1906, -1905.5, -1905, -1904.6, -1904, -1903.6, -1903.1, -1902.7,
-1902.2, -1901.7, -1901.2, -1900.7, -1900.4, -1899.9, -1899.4,
-1898.9, -1898.4, -1897.9, -1897.4, -1896.9, -1896.4, -1895.9,
-1895.2, -1895, -1894.5, -1894, -1893.6, -1893.1, -1892.6, -1892.1,
-1891.6, -1891.2, -1890.7, -1890.2, -1889.7, -1889.2, -1888.9,
-1888.4, -1887.9, -1887.4, -1886.9, -1886.4, -1885.6, -1885.4,
-1884.9, -1884.5, -1884, -1883.5, -1883, -1882.5, -1882.1, -1881.6,
-1881.1, -1880.6, -1880.2, -1879.7, -1879.2, -1878.7, -1878.4,
-1877.9, -1877.4, -1876.9, -1876.1, -1875.6, -1875.1, -1874.6,
-1874.1, -1873.6, -1873.2, -1872.7, -1872.2, -1871.7, -1871.4,
-1870.7, -1870.4, -1869.9, -1869.4, -1868.9, -1868.4, -1867.9,
-1867.4, -1867.2, -1866.4, -1866, -1865.5, -1865, -1864.5, -1864.1,
-1863.6, -1863.1, -1862.6, -1862.1, -1861.7, -1861.2, -1860.7,
-1860.2, -1859.7, -1859.4, -1858.9, -1858.4, -1857.9, -1857.4,
-1856.9, -1856.4, -1855.9, -1855.4, -1854.9, -1854.5, -1854,
-1853.5, -1853.1, -1852.6, -1852.1, -1851.6, -1851.1, -1850.7,
-1850.2, -1849.7, -1849.2)
plot(example, t="l", main="Original")
plot(resample(example,250,length(example)), t="l", main="Resampled")