Prev: Dynamic window popup question
Next: problem with the usage or implemetation of EllipticF[x,m] and
From: Sharing the Jazz on 13 Jun 2010 18:53 Hi, I import a dataset of three variable from excel to mathematica. The input works but i don't know how to work on it, for example plot it, analyze stationarity. The problem is that they are on this form and Mathematica (with Time Series application) doesn't work. {{{"Year", "Price", "Dividend"}}, {{1871., 77.2276, 4.52234}}, {{1872., 83.2615, 4.51085}}, ..... {{2009., 888.75, 28.7598}}} Can someone help me in start using this data? Thank you very much, Matteo HEC-Paris
From: Christopher Arthur on 15 Jun 2010 02:27 Probably the double braces are confusing the program. try this: Flatten/@data and use the result (such that 'data' is the entire spreadsheet). Chris Sharing the Jazz a =E9crit : > Hi, > I import a dataset of three variable from excel to mathematica. The > input works but i don't know how to work on it, for example plot it, > analyze stationarity. The problem is that they are on this form and > Mathematica (with Time Series application) doesn't work. > > {{{"Year", "Price", "Dividend"}}, {{1871., 77.2276, > 4.52234}}, {{1872., 83.2615, 4.51085}}, ..... {{2009., 888.75, > 28.7598}}} > > Can someone help me in start using this data? > > Thank you very much, > > Matteo > HEC-Paris > > >
From: Sjoerd C. de Vries on 15 Jun 2010 02:28 Hi Matteo, First you have to throw away the text headers using Drop or Take. Are you sure that each data triplet has two sets of curly brackets around it? It looks unusual, not what I normally get when I import from Excel. Assuming you put the rest of the dataset in the variable data I'd suggest getting rid of the extra layer of brackets using Flatten: data = Flatten[data, 1] If you want to plot Price against Year you could use ListPlot or DateListPlot as follows: ListPlot[Transpose[{ data[[All,1]], data[[All,2]] } ] . data[[All,1]] takes the first column of the dataset and data[[All,2]] takes the second. Putting them in a new list with { } and using Transpose makes it a list with data pairs. An alternative approach would be: ListPlot[Transpose[{ Transpose[data][[1]], Transpose[data][[1]] } ] Cheers -- Sjoerd On Jun 14, 12:53 am, Sharing the Jazz <formenti.mat...(a)gmail.com> wrote: > Hi, > I import a dataset of three variable from excel to mathematica. The > input works but i don't know how to work on it, for example plot it, > analyze stationarity. The problem is that they are on this form and > Mathematica (with Time Series application) doesn't work. > > {{{"Year", "Price", "Dividend"}}, {{1871., 77.2276, > 4.52234}}, {{1872., 83.2615, 4.51085}}, ..... {{2009., 888.75, > 28.7598}}} > > Can someone help me in start using this data? > > Thank you very much, > > Matteo > HEC-Paris
From: sibir on 15 Jun 2010 02:30 You have to get rid of some curly brackets, e.g. with Flatten In[1]:= t={{{"Year","Price","Dividend"}},{{1871.,77.2276,4.52234}}, {{1872.,83.2615,4.51085}},{{2009.,888.75,28.7598}}}; In[2]:= Flatten[t,1] Out[2]= {{Year,Price,Dividend},{1871.,77.2276,4.52234}, {1872.,83.2615,4.51085},{2009.,888.75,28.7598}}
From: Bob Hanlon on 15 Jun 2010 02:31 dateFromYear[dyr_?NumericQ] := Module[{yr = IntegerPart[dyr]}, DatePlus[{yr, 1, 1}, FractionalPart[dyr]* DateDifference[ {yr, 1, 1}, {yr + 1, 1, 1}]]] data = { {{"Year", "Price", "Dividend"}}, {{1871., 77.2276, 4.52234}}, {{1872., 83.2615, 4.51085}}, {{2009., 888.75, 28.7598}}}; {year, price, dividend} = Rest /@ Transpose[Flatten[data, 1]]; ListLinePlot[Thread[{year, price}]] DateListPlot[ Thread[{ dateFromYear /@ year, price}], Joined -> True] FindFit[Thread[{year, price}], a + m*(yr - year[[1]]), {a, m}, yr] {a->77.3042,m->5.88005} ListLinePlot[Thread[{year, dividend}]] DateListPlot[ Thread[{ dateFromYear /@ year, dividend}], Joined -> True] FindFit[Thread[{year, dividend}], a + m*(yr - year[[1]]), {a, m}, yr] {a->4.42878,m->0.176307} Bob Hanlon ---- Sharing the Jazz <formenti.matteo(a)gmail.com> wrote: ============= Hi, I import a dataset of three variable from excel to mathematica. The input works but i don't know how to work on it, for example plot it, analyze stationarity. The problem is that they are on this form and Mathematica (with Time Series application) doesn't work. {{{"Year", "Price", "Dividend"}}, {{1871., 77.2276, 4.52234}}, {{1872., 83.2615, 4.51085}}, ..... {{2009., 888.75, 28.7598}}} Can someone help me in start using this data? Thank you very much, Matteo HEC-Paris
|
Pages: 1 Prev: Dynamic window popup question Next: problem with the usage or implemetation of EllipticF[x,m] and |