Tag Info

Hot answers tagged

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 ...


11

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"]]


11

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. ...


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 ...


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

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 ...


6

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, ...


5

After some study, I think that I found out how to answer it using: data = TemporalData[salesData,{{2010,1},{2012,11}}]; 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 -> ...


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

Here is a worked example: We take as our data 10000 samples from a Normal Distribution with mean 1 and standard deviation 3: data = RandomVariate[NormalDistribution[1, 3], 10^4]; We then try to work backwards to see what the data says about the distribution - taking as an assumption that it came from a Normal Distribution, we see which paramaters are ...


4

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, ...


3

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}, ...


3

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 ...


2

Using image processing and trying to keep the code compact. The whole problem is that the genius who devised this chart made the alignments artificially (and IMHO unnecessarily) complicated dates = Most@NestWhileList[DatePlus[#, 1] &, {1997, 1, 1}, Developer`CalendarData[#, "Year"] == 1997 &]; (*random ...


2

More an extended comment than a complete answer or "how to". Vialiy's comment and the few pages Stephen Wolfram writes on the subject in A New Kind of Science, certainly provide a good place to start. Adding some basic understanding of types of participants might improve your chances of analyzing this problem with CellularAutomaton. Within any ...


2

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 ...


2

My literal implementation taken directly from the equations is below: ClearAll[gk]; gk[z_,k_]:=Module[{n,s2k,dk,s21,d1}, n = Length@z; dk[t_] := z[[t+k]]-z[[t]]; s2k = Sum[(dk[t]-Sum[dk[t],{t,n-k}]/(n-k))^2,{t,n-k}]/(n-k-1); d1[t_] := z[[t+1]]-z[[t]]; s21 = Sum[(d1[t]-Sum[d1[t],{t,n-1}]/(n-1))^2,{t,n-1}]/(n-2); s2k/s21 ] and this will generate ...


2

The package loads with a few errors eg. SetDelayed::write: Tag CovarianceFunction in CovarianceFunction[ARModel[phi_,sigma2_],n_] is Protected. >> SetDelayed::write: Tag CovarianceFunction in CovarianceFunction[MAModel[theta_,sigma2_],n_] is Protected. >> SetDelayed::write: Tag CovarianceFunction in ...


2

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`, ...


2

The command ARProcess requires that the input term $e_t$ be a zero mean white noise with a specified variance. What you are trying to do is to have your input term be $10+e_t$ which is clearly not zero mean. What you can do is to change variables. In your case, if you define a new process $z_t=y_t - 25$ then it will be the same as the $y_t$ process. To see ...


1

Here's a guess at what you're after: SeedRandom[1]; data = Accumulate[RandomReal[{-0.2, 0.2}, 300]]; thirds = Partition[data, 100]; interps = Interpolation /@ thirds; myplot = ListLogLinearPlot[thirds]; DynamicModule[{pos = MapThread[{Log@#, #2[#]} &, {{5, 16, 50}, interps}]}, LocatorPane[ Dynamic[pos, (pos = MapThread[ Function[{pt, ...


1

To put Leonids comment into an answer: Please see the blog-post of Mike Honeychurch at ibnhconsulting.blogspot.ru. This should help you.


1

I don't know if it is OK to answer your own question, but I thought I would give an answer as to what I ultimately ended up with. This is essentially based on Verbeia's answer. I've added a option for how many lags to calculate since calculating the variance for lags up to $n-1$ doesn't make much sense, since the number of data points you have decrease ...



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