Tag Info

Hot answers tagged

18

This site has exactly what you want here, already in Mathematica code. One example here:


16

Based on @b.gatessucks answer and on @RahulNarain comment tip, I created this functions for the multiplicative decompose case. I changed @b.gatessucks method for seasonality to keep it closer from R method, and used TemporalData to easily handle time interval. ...


13

The following seems a little more elegant. data = Import["http://www.massey.ac.nz/~pscowper/ts/cbe.dat"]; ts = TemporalData[data[[2 ;; -1, 1]], {"1958", Automatic, "Month"}]; DateListPlot[ts["Path"]] TemporalData can also store multiple paths. ts2= TemporalData[Transpose[data[[2 ;; -1]]], {"1958", Automatic, "Month"}]; DateListPlot[ts2["Paths"]]


13

One of the new operations on TimeSeries objects is TimeSeriesWindow. I think it does what you need. ts = WeatherData["KP60", "Temperature", {{2013, 7, 1}, {2013, 9, 30}}]; DateListPlot[TimeSeriesWindow[ts, {{2013, 8, 1}, {2013, 8, 14}}]]


11

You could use RunScheduledTask or its relatives for this. For example, to append a random integer to catch once every two seconds you could do something like catch = {}; task = RunScheduledTask[AppendTo[catch, RandomInteger[10]], 2]; You could also use CreateScheduledTask which is similar to RunScheduledTask except that the task won't be started ...


11

So this generates the heatmap: << Calendar` year = 1990; yearLen = DaysBetween[{year, 1, 1}, {year, 12, 31}] + 1; data = RandomReal[1, yearLen]; days = Map[DayOfWeek[{year, 1, #}] &, Range[3, 9]]; day1 = Position[days, DayOfWeek[{year, 1, 1}]][[1, 1]]; dayn = Position[days, DayOfWeek[{year, 12, 1}]][[1, 1]]; Paddata = Join[ConstantArray[100, day1 ...


10

There are basically two methods. The first is to use the ARProcess function (or ARMAProcess or ARIMAProcess as needed) introduced in version 9. The answers to this question should be helpful. Here is a small example that modifies the example in the documentation to show how to plot the resulting TemporalData using DateListPlot rather than ListPlot: you ...


9

This is as designed but an argument could be made for making some tweaks to it. The driving concern was to preserve options (e.g. ResamplingMethod) where it makes sense. If options are contained in one and only one object that option is kept as is. If an option is shared among objects the combined object inherits the first occurrence (MetaInformation for ts1 ...


8

While you come back with a version 9 solution here is an old school approach : The first entry is labels so I removed it : rawData = Import["http://www.massey.ac.nz/~pscowper/ts/cbe.dat"][[2 ;;]]; Added the dates to the imported data : they are monthly dates starting {1958, 1, 1} : data = Transpose[{NestList[DatePlus[#, {1, "Month"}] &, {1958, 1, ...


8

The three best-known tests for stationarity (or rather, unit roots) in time series econometrics are: Dickey-Fuller including Augmented Dickey-Fuller Phillips-Perron KPSS There are also Bayesian tests of unit roots, as implemented in this conference presentation. If you have access to JSTOR or another way of getting at old journals, this article might be ...


8

Here are two approaches. We'll create a second dataset by shifting the given data by two months: blossom = {{4, 3}, {4, 22}, {4, 15}, {4, 2}, {4, 18}, {4, 20}, {4, 12}, {3, 30}, {4, 4}, {4, 24}, {4, 26}, {3, 4}, {4, 26}, {4, 13}, {5, 1}, {4, 4}, {4, 8}, {4, 18}, {4, 9}, {4, 19}, {4, 10}, {4, 20}, {4, 3}, {4, 4}, {3, 21}, {4, 19}, {4, 15}, ...


8

Calling Wolfram|Alpha is not generally an efficient way to retrieve bulk data; where possible, it is better to use a built in data function. Part of the problem is figuring out what to submit to Wolfram|Alpha. In the code you supplied, the issue begins with Wolfram|Alpha returning Missing[NotAvailable]. WolframAlpha["AAPL ...


7

Here's a line right out of the help for CellularAutomaton. ListLinePlot[Accumulate[(-1)^CellularAutomaton[30, {{1}, 0}, {500, {{0}}}]]]


7

The links provide you with everything you need I think. The goal of this answer is to show you that even though it's not built in, a discrete STFT is quite easy and short to code. This would take the DFT of the data set partitioned into chunks of length 2^13, with half a window overlap, and a rectangular window STFT[r_]:= Fourier /@ Partition[r, 2^13, ...


6

After some study, I think that I found out how to answer it using: data = TemporalData[salesData,{{2010,1},{2012,11},"Month"}]; proc=EstimatedProcess[salesData,SARIMAProcess[{},1,{},{12,{a},1,{b}},v]]; forecast=TimeSeriesForecast[proc, data,{14}]; DateListPlot[N@{data["Path"],forecast["Path"]} ,AspectRatio->0.2 ,Joined-> True ,PlotStyle ...


6

Wolfram has renamed the LogLikelihood function in the Time Series package to LogLikelihoodFunction. But they have apparently forgotten to update the documentation.


5

Straightforward approach with controlling related heights. Needs["HierarchicalClustering`"] SeedRandom@2; data = RandomVariate[NormalDistribution[], {10, 20}]; height = 50; label = ListPlot[#, Axes -> False, Joined -> True, ImageSize -> {300, height}, AspectRatio -> height/300] & /@ data; Edit I'm sorry my previous ...


4

Lag differences are not the same as second-differencing etc, so Differences is not the right approach. test2 = Array[f, 10] In[23]:= Differences[test2, 3] Out[23]= {-f[1] + 3 f[2] - 3 f[3] + f[4], -f[2] + 3 f[3] - 3 f[4] + f[5], -f[3] + 3 f[4] - 3 f[5] + f[6], -f[4] + 3 f[5] - 3 f[6] + f[7], -f[5] + 3 f[6] - 3 f[7] + f[8], -f[6] + 3 ...


4

There are a couple issues here worth touching on, I think. Firstly, you are making things overly complicated for your self. Mathematica has a built in function for generating data from a random process, called RandomFunction. You can easily use it and a time series model to generate data, like so: armodel = ARProcess[{0.5469865826154379`, ...


4

I think your modeldata generation should be y[[t]] = whitenoise + (a1*y[[t-1]]) + (a2*y[[t-2]]) + (a3*y[[t-3]]) + (a4*y[[t-4]]) since for an AR(4) model, the current value is a linear combination of four previous values plus the current value of the noise. Also, after looking at the plot of processdata, I observed strong trend and seasonality, so you ...


4

This looks like very useful function for e.g. economic time series. If this can be done easily in R does it need to be done in Mathematica? With the qualifier that this is my first day testing 9 he is my attempt at the alternative: Needs["RLink`"] InstallR[]; data = REvaluate["{ url <- \"http://www.massey.ac.nz/~pscowper/ts/cbe.dat\" CBE ...


4

This appears to work in the 9.0.1 release: DateListPlot[gasPrices]


4

Does the following direct implementation of your expressions work for you? ClearAll[data, dif, dbar, var, variogram]; dif[list_] := Table[(list[[k + 1 ;;]] - list[[;; -(k+1)]]), {k, Length[list] - 1}] var[list_] := Variance /@ (Most@(dif[list])); variogram[list_] := (#/First@#) &@var[list]; usage data = Accumulate[RandomReal[{-1, 1}, ...


4

My interest piqued, I went back to my original code, from 2002 (ok, not quite 15 years). Simon's comment was correct. The problem in the modified version of the code (not mine) was that it changed the obsolete command AppendRows to Join instead of Join[##,2]. This version produces the expected format result in version 9, and does so in a fraction of a ...


4

With[{data = #}, MapThread[{#1, #2} &, {(#1 + DateList[#2]*{0, 0, 0, 1, 1, 1}) & @@@ Tuples[{data[[2 ;;, 1]], Rest[data[[1]]]}], Flatten[data[[2 ;;, 2 ;;]]]}]] &[rawdata] All those excess characters... Here's the Twitterized version: Transpose@{(#1 + DateList[#2]*{0, 0, 0, 1, 1, 1}) & @@@\ Tuples@{#[[2 ;;, 1]], #[[1, 2 ...


4

Here is an approach using rawdata in the question: ans = Module[{time, dates, dt, values}, time = ToExpression /@ (StringSplit[#, ":"] & /@ Rest@First@rawdata); dates = rawdata[[2 ;;, 1]]; values = rawdata[[2 ;;, 2 ;;]]; dt = Map[Function[x, Join[x[[1 ;; 3]], #, {0}] & /@ time], dates]; Flatten[MapThread[{#1, #2} &, {dt, ...


4

TemporalData needs to assume equal dimensionality of series in order to distinguish between the case of a single multivariate series and multiple univariate series. There is no workaround to this limitation so you will need to stick to a list of TimeSeries objects. Also, to avoid extrapolation you can always use a different setting for ResamplingMethod. ...


4

It is not TimeSeriesWindow that is making your code slow. What is slowing down your function is the conversion of the data received from FinancialData from a List to a TimeSeries object. If this conversion is done before TimeSeriesWindow is applied, e.g. by tsData=TimeSeries[data] Than TimeSeriesWindow[tsData,{{2013,8,22},{2013,8,26}}] is even faster ...


3

I am not so sure that this is an unreasonable forecast given the model structure you have assumed. Mathematica does not make it easy to extract fitted values from the model using the model["SomeProperty'] construct, which is a pity. (Or maybe I missed that bit in the documentation.) When you check the best fit model, it is clear that the seasonal MA ...


3

Yes, there is a way. We will illustrate this using the following example. data = Table[{3 + i + RandomReal[{-3, 7}], i + RandomReal[{-2, 5}]}, {i, 1, 20}]; model = LinearModelFit[data, x, x] (* ANOVA table *) model["ANOVATable"] $\begin{array}{l|lllll} \text{} & \text{DF} & \text{SS} & \text{MS} & \text{F-Statistic} & ...



Only top voted, non community-wiki answers of a minimum length are eligible