Search code examples
rtime-serieswavelet

WaveletComp misreading data


Here's the structure of my data:

'data.frame':   275 obs. of  2 variables:
$ Date         : Date, format: "1993-07-05" "1993-08-30" "1993-09-27" "1993-10-25" ...
$ AverageOxygen: num  4.11 3.8 3.65 5.77 5.23 ...

I'm trying to get WaveletComp to analyze my wavelet using this code:

library(WaveletComp)
analyze.wavelet(WaveletSite1Oxygen, loess.span = 1/25,
            dt = 1, dj = 1/250,
            lowerPeriod = 2*dt,
            upperPeriod = floor(nrow(WaveletSite1Oxygen)/3)*dt,
            make.pval = TRUE, method = "white.noise", params = NULL,
            n.sim = 100,
            date.format = NULL, date.tz = NULL,
            verbose = TRUE)

For some reason, I'm getting this error which doesn't seem to make sense:

Error in analyze.wavelet(WaveletSite1Oxygen, loess.span = 1/25, dt = 1, : Some values in your time series do not seem to be interpretable as numbers.

I'm not sure how this is happening because all my variables are in the right format and there are no NAs.

Thank you for your help.

Here's the dput of the data

WaveletSite1Oxygen <- structure(list(Date = structure(c(8586, 8642, 8670, 8698, 8726, 
8754, 8789, 8817, 8845, 8873, 8915, 8951, 9006, 9034, 9062, 9091, 
9153, 9181, 9209, 9244, 9272, 9304, 9342, 9370, 9399, 9426, 9459, 
9524, 9559, 9587, 9622, 9706, 9734, 9762, 9797, 9825, 9860, 9888, 
9903, 9946, 10010, 10050, 10095, 10133, 10161, 10178, 10224, 
10252, 10280, 10308, 10339, 10417, 10469, 10497, 10525, 10553, 
10567, 10609, 10641, 10665, 10707, 10742, 10767, 10802, 10830, 
10858, 10893, 10907, 10984, 11012, 11040, 11054, 11159, 11187, 
11229, 11257, 11271, 11313, 11341, 11375, 11411, 11435, 11467, 
11495, 11509, 11552, 11580, 11636, 11664, 11734, 11762, 11797, 
11809, 11867, 11895, 11923, 11951, 11979, 12021, 12035, 12077, 
12105, 12133, 12160, 12189, 12231, 12259, 12273, 12315, 12343, 
12385, 12399, 12441, 12469, 12497, 12535, 12553, 12592, 12630, 
12658, 12686, 12714, 12742, 12770, 12805, 12833, 12861, 12903, 
12917, 12938, 12987, 13015, 13056, 13085, 13116, 13138, 13179, 
13201, 13232, 13259, 13287, 13323, 13358, 13386, 13413, 13442, 
13470, 13497, 13532, 13561, 13603, 13630, 13658, 13694, 13722, 
13750, 13778, 13792, 13846, 13862, 13896, 13925, 13967, 13995, 
14009, 14051, 14064, 14121, 14149, 14177, 14205, 14233, 14268, 
14296, 14310, 14352, 14380, 14450, 14474, 14506, 14548, 14575, 
14590, 14618, 14661, 14688, 14726, 14758, 14821, 14849, 14877, 
14905, 14933, 14960, 14995, 15024, 15038, 15093, 15121, 15135, 
15181, 15209, 15237, 15264, 15308, 15322, 15353, 15399, 15427, 
15455, 15483, 15510, 15539, 15580, 15608, 15636, 15666, 15692, 
15729, 15741, 15780, 15811, 15853, 15911, 15940, 15961, 15996, 
16024, 16052, 16101, 16150, 16178, 16218, 16276, 16303, 16331, 
16374, 16401, 16417, 16455, 16482, 16513, 16555, 16585, 16612, 
16638, 16667, 16706, 16723, 16752, 16778, 16805, 16840, 16891, 
16918, 16933, 16976, 17044, 17120, 17143, 17178, 17219, 17233, 
17261, 17289, 17347, 17373, 17401, 17460, 17515, 17547, 17583, 
17602, 17626, 17653), tzone = "UTC", tclass = "Date", class = "Date"), 
    AverageOxygen = c(4.11230769230769, 3.80128205128205, 3.64576923076923, 
    5.76538461538462, 5.23153846153846, 5.14807692307692, 4.26590909090909, 
    3.71666666666667, 4.35884615384615, 3.25769230769231, 4.85288461538462, 
    5.61923076923077, 4.35576923076923, 5.72884615384615, 7.22692307692308, 
    2, 4.21923076923077, 4.67211538461538, 5.125, 4.74230769230769, 
    4.28846153846154, 5.10384615384615, 6.06346153846154, 3.24230769230769, 
    6.07884615384615, 5.89615384615385, 4.54807692307692, 5.21442307692308, 
    5.48461538461538, 6.70769230769231, 5.36538461538461, 5.17483974358974, 
    5.95, 5.55384615384615, 5.67153846153846, 5.53769230769231, 
    5.78307692307692, 6.57307692307692, 6.49192307692308, 6.36153846153846, 
    6.71992307692308, 6.51936923076923, 6.41, 7.14782608695652, 
    6.11307692307692, 6.20961538461538, 6.85277777777778, 6.82277777777778, 
    6.82846153846154, 6.35384615384615, 5.15769230769231, 6.64, 
    6.39384615384615, 6.88179487179487, 6.44153846153846, 6.82192307692308, 
    7.45923076923077, 7.03730769230769, 7.01214285714286, 6.99326923076923, 
    6.83269230769231, 7.20188461538462, 5.94901602564103, 4.195, 
    5.11826923076923, 6.94230769230769, 6, 9.515, 7.95634615384615, 
    7.645, 6.72096153846154, 6.09538461538462, 6.65636639676113, 
    6.80596153846154, 6.19564102564103, 7.03442307692308, 6.52769230769231, 
    7.48740384615385, 7.22692307692308, 7.05307692307692, 6.06953846153846, 
    5.41384615384615, 7.17278846153846, 7.47373076923077, 7.1822792022792, 
    6.80788461538462, 7.24076923076923, 7.54961538461538, 5.55653846153846, 
    8.41923076923077, 6.75423076923077, 7.13653846153846, 7.00192307692308, 
    7.09538461538462, 7.29730769230769, 7.42903846153846, 5.87115384615385, 
    5.94153846153846, 6.42153846153846, 6.74269230769231, 5.88730769230769, 
    6.41692307692308, 6.82653846153846, 6.34096153846154, 6.19807692307692, 
    6.79384615384615, 6.56230769230769, 4.40576923076923, 6.54115384615385, 
    6.02884615384615, 5.75666666666667, 5.01076923076923, 5.55115384615385, 
    7.14961538461538, 5.77942307692308, 6.22141025641026, 6.66192307692308, 
    6.06788461538462, 5.91153846153846, 5.37692307692308, 5.61346153846154, 
    5.40192307692308, 6.41019230769231, 5.07961538461538, 5.09391025641026, 
    2.42012820512821, 1.75173076923077, 4.14705128205128, 4.44538461538462, 
    4.42269230769231, 2.94395833333333, 4.88153846153846, 5.15941483516484, 
    5.35596153846154, 5.26211538461538, 4.02961538461538, 2.60641254578755, 
    1.14916666666667, 4.67846153846154, 4.47653846153846, 3.97942307692308, 
    2.27812937062937, 1.98057692307692, 1.92730769230769, 4.65846153846154, 
    4.47173076923077, 5.02192307692308, 5.22423076923077, 4.07393162393162, 
    3.72826923076923, 3.01666666666667, 3.96634615384615, 4.85800480769231, 
    6.00442307692308, 6.44865384615385, 6.33692307692308, 5.90365384615385, 
    6.57846153846154, 5.57615384615385, 6.25384615384615, 5.31096153846154, 
    5.13022435897436, 4.98307692307692, 5.95038461538462, 4.89730769230769, 
    5.2225, 5.805, 5.91642081447964, 5.97115384615385, 5.25051282051282, 
    6.03519230769231, 5.66884615384615, 5.87538461538461, 6.06269230769231, 
    5.81807692307692, 5.94423076923077, 6.19153846153846, 5.54194762684124, 
    5.31923076923077, 6.35384615384615, 6.92051282051282, 7.19038461538462, 
    3.90384615384615, 7.64230769230769, 6.03589743589744, 6.51538461538462, 
    6.92820512820513, 6.81153846153846, 6.55897435897436, 6.36192307692308, 
    7.22307692307692, 6.10961538461538, 5.93653846153846, 6.85, 
    6.66538461538462, 5.12307692307692, 6.06153846153846, 6.42179487179487, 
    6.32051282051282, 5.85384615384615, 6.27307692307692, 7.02692307692308, 
    7.025, 6.02307692307692, 6.33173076923077, 6.47692307692308, 
    5.37884615384615, 2.38644688644689, 5.91538461538462, 5.31730769230769, 
    4.83461538461538, 1.25149572649573, 1.75757936507937, 2.47307692307692, 
    4.47115384615385, 4.81548717948718, 4.43502747252747, 5.33873626373626, 
    5.19423076923077, 5.90384615384615, 4.84038461538462, 5.45769230769231, 
    5.89487179487179, 1.63846153846154, 5.35576923076923, 7.03846153846154, 
    5.59230769230769, 5.84230769230769, 6.024, 3.81153846153846, 
    3.83846153846154, 5.7, 6.10769230769231, 5.32307692307692, 
    5.59423076923077, 6.86923076923077, 6.69028286528286, 6.57792022792023, 
    5.83846153846154, 3.90384615384615, 0.761111111111111, 3.08098290598291, 
    4.68205128205128, 4.51730769230769, 5.82692307692308, 1.52692307692308, 
    2.55769230769231, 2.41410256410256, 2.32142697881828, 2.16333333333333, 
    0.778571428571429, 1.40384615384615, 2.93846153846154, 2.74326923076923, 
    5.20769230769231, 3.86269230769231, 4.02076923076923, 2.32545833333333, 
    4.35038461538462, 5.60307692307692, 3.755, 5.00961538461539, 
    4.36307692307692, 3.245, 4.38769230769231, 3.26269230769231, 
    4.00121082621083, 4.79653846153846, 4.46518518518519, 5.34461538461538, 
    0.555384615384615, 2.92332867132867, 4.17307692307692, 4.87461538461538, 
    5.50230769230769)), class = "data.frame", row.names = c(NA, 
-275L))

Solution

  • Accodring to the documentation, the my.data parameter should be

    data frame of time series (including header, and dates as row names or as separate column named "date" if available)

    You have a column named "Date", not "date" (R is case sensitive). And then the my.series parameter says it expects

    name or column index indicating the series to be analyzed

    Since the default is 1, that means it will try to take the first column in your data set which is the Date column. But you really want the AverageOxygen column.

    We can create a new column with the right "date" name and analyze the correct column with

    analyze.wavelet(transform(WaveletSite1Oxygen, date=Date), my.series="AverageOxygen")