Hello All,
I am new to Mathematica (I've got around 50 hours of experience) and have had several challenges with it for some reason. I have only used Matlab and it's pretty much all I know how to program in, but with some help here I hope to expand my horizon:)
Problem: Currently, I am trying to create an ARMA (or ARIMA) model for
1.) time series data voltage (input),
2.) time series data Power (output).
From here, I am trying to obtain a transfer function to analyze the data in the frequency domain as Power as a function of voltage.
Challenge 1: I have had a hard time finding a way to use mathematica's models because it appears that they only want to take a single time series, not two time series as input, output. My code so far:
Load Modeling
Import Test2 Data:
In[1]:=
SetDirectory["/Users/Andrew_Miller/Desktop"]
Out[1]= "/Users/Andrew_Miller/Desktop"
In[3]:=
S := Import["Volt_mag_test2.xls", "Data"][[1]] // TableForm
Plot Imported Data:
In[4]:= T0 := 1710; T1 := 1725
In[5]:= RPT1 := S[[1, T0 ;; T1, {1, 3}]]; ReactPT1 := S[[1, T0 ;; T1, {1, 4}]]; A :=
S[[1, T0 ;; T1, 1 ;; 2]]
In[7]:= indices = TimeSeriesResample[
TimeSeries[TimeSeriesThread[QuantityMagnitude, {A, RPT1}],
MetaInformation -> {"Load" -> {"Voltage", "Real"}}]]
Out[7]= TemporalData[TimeSeries, {{{{543.79, 273.4914067735215}, {540.3338203592821,
272.12198107766017`}, {532.6544156626537, 265.4166177015815}, {
526.2233892215608, 261.2387807179397}, {527.9234850299387,
271.74342744421557`}, {536.7913855421593, 288.6956167678963}, {
545.0298203592713, 294.68876757004415`}, {548.046994011972,
290.05481266135587`}, {546.857638554219, 283.89108711466736`}, {
544.8291197604829, 280.63655380563586`}, {543.852485029942,
280.40649940236517`}, {543.7258373493978, 282.2533359049174}, {
543.8029281437124, 283.7083317961021}, {543.959323353293,
284.2454407743577}, {544.0871686746985, 285.9421489447387}, {
543.9417005988029, 288.18057891457306`}}}, {{28.45, 28.698999999999952`,
0.01659999999999684}}, 1, {"Continuous", 1}, {"Discrete", 1}, 2, {
ValueDimensions -> 2,
ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1},
MetaInformation -> {"Load" -> {"Voltage", "Real"}}}}, False, 10.]
indices["Properties"]
{"Dates", "FirstTime", "LastTime", "Load", "Path", "PathFunction", \
"PathLength", "Times", "ValueDimensions", "Values"}
In[9]:= indices["Values"]
Out[9]= {{543.79, 273.491}, {540.334, 272.122}, {532.654, 265.417}, {526.223,
261.239}, {527.923, 271.743}, {536.791, 288.696}, {545.03,
294.689}, {548.047, 290.055}, {546.858, 283.891}, {544.829,
280.637}, {543.852, 280.406}, {543.726, 282.253}, {543.803,
283.708}, {543.959, 284.245}, {544.087, 285.942}, {543.942, 288.181}}
In[11]:= indices["Path"]
Out[11]= {{28.45, {543.79, 273.491}}, {28.4666, {540.334,
272.122}}, {28.4832, {532.654, 265.417}}, {28.4998, {526.223,
261.239}}, {28.5164, {527.923, 271.743}}, {28.533, {536.791,
288.696}}, {28.5496, {545.03, 294.689}}, {28.5662, {548.047,
290.055}}, {28.5828, {546.858, 283.891}}, {28.5994, {544.829,
280.637}}, {28.616, {543.852, 280.406}}, {28.6326, {543.726,
282.253}}, {28.6492, {543.803, 283.708}}, {28.6658, {543.959,
284.245}}, {28.6824, {544.087, 285.942}}, {28.699, {543.942, 288.181}}}
ListPlot[indices]
ListPlot[TimeSeriesMap[Part[#, 1, 2] &, CorrelationFunction[indices, {13}]],
Filling -> Axis, PlotStyle -> Purple]
(*Clear[x0,y0];
Manipulate[Grid[{{ListLinePlot[{S[[1,T0;;T1,1;;2]],S[[1,T0;;T1,{1,3}]],S[[1,\
T0;;T1,{1,4}]]},PlotLegends\[Rule]{"Voltage(M)","Real Power(MW)","Reactive \
Power(MVAR)"},Epilog\[Rule]{{Blue,Opacity[0.1],Rectangle[{x0-\[Delta],y0-\
\[Gamma]},{x0+\[Delta],y0+\[Gamma]}]}}],"Full \
Plot"},{ListLinePlot[{S[[1,T0;;T1,1;;2]],S[[1,T0;;T1,{1,3}]],S[[1,T0;;T1,{1,4}\
]]},Axes\[Rule]False,GridLines\[Rule]Automatic,AspectRatio\[Rule]1,Frame\
\[Rule]True,Filling\[Rule]Axis,PlotRange\[Rule]{{x0-\[Delta],x0+\[Delta]},{y0-\
\[Gamma],y0+\[Gamma]}}],"Zoom View"}}],{{\[Delta],3,"X Zoom \
Level"},10^-20,5},{{x0,0,"X Center"},0,30},{{\[Gamma],3,"Y Zoom \
Level"},10^-5,520},{{y0,0,"Y Center"},0,600}]*)
ARIMA Model:
In[8]:= estP = EstimatedProcess[indices, ARIMAProcess[1, 1, 0]]
Out[8]= ARIMAProcess[{-0.483135, -0.107094}, {{{0.100286, 0.50265}, {-1.15912,
1.12133}}}, {1, 1}, {}, {{6.72731, 10.2865}, {10.2865, 17.5061}}]
The way I defined indices is based on an example that I saw on this forum, but I am just not sure of what the output of the ARIMA model means. I don't believe, however, that it is taking one time series as input and another as output. It is my understanding that the "EstimatedProcess" is fitting the ARIMAProcess model parameters, but is it taking one time series as input and another as output?
Challenge 2: Plotting in 2D in mathematica does not have a zoom button? In my code you can see a commented part where I adapted a code I found online to my needs, but it performs horribly anyways. Any ideas on how to improve 2d plotting? Specifically, zooming capabilities?
Ultimately, I would like to have both time domain ARMA (ARIMA) models and transfer function frequency domain model based. Any help is much appreciated.
Regards, Andrew