Compare average monthly stock return data
Ältere Kommentare anzeigen
I would like to compare the average of the monthly stock return data listed in the 41x1 cell array 'DS_10T' with the data listed in the cell array 'DS_10B'.
As there are some NaNs within my data I hope that one can somehow not factor them into the averages.
I attached a short version of the relevant data as my original dataset would need significantly more memory, because it includes a lot more stocks.
Even tough every cell array contains 41 tables with data from different timeframes I would only need a comparison of the overall average monthly return out of all tables in 'DS_10T' versus the overall average monthly return of all tables of 'DS_10B' in the following format:

Where "Sell" depicts the average monthly returns of the 'DS_10B' array, "Buy" the average monthly returns of the 'DS_10T' array and Buy-Sell the difference between the two values. The numbers in parentheses can be ignored for now.
13 Kommentare
"I would only need a comparison of the overall average monthly return out of all tables in 'DS_10T' ..."
OK, define what this means, precisely...when I look at the data, I see an inconsistent set of dates in each; the first has all of 2010, the second the first 3Q of 2010 but then Q1 of 2011.
But, I also note that there are different numbers of data columns with different column names in each one -- so what can one average over?
Me no follow, sorry... :)
Fabian Niederreiter
am 29 Mär. 2021
dpb
am 29 Mär. 2021
"... want to compare the overall average monthly return of all stocks in 'DS_10T' to the overall average monthly return of all stocks in 'DS_10B'. Hereby we do not longer need to pay attention to the dates (lines)..."
If you don't pay attention to dates, then you'll have a global average of all months for all years??? That is, that would be one number for each variable. How many results do you expect?
You can average over issues/stocks ok (although I don't know as I can see what that could possibly mean (so to speak) once have done?)
Fabian Niederreiter
am 29 Mär. 2021
Fabian Niederreiter
am 30 Mär. 2021
dpb
am 30 Mär. 2021
Sorry, I've been tied up getting ready for annual meeting tomorrow -- I'll try to get a chance to take a look this evening, maybe...I think I understand the Q? now altho it'll take some effort to handle the various forms in each.
You don't have the whole thing in one great big table from which you created these cell arrays by any chance, do you? If the data exist in the whole first, instead of this, it's probably going to be a lot simpler to work there instead is one additional thought/question...
Fabian Niederreiter
am 30 Mär. 2021
dpb
am 31 Mär. 2021
We just need a list of which IDs are wanted to be analyzed...
Annual meeting is over (whew!) but I need a little time to decompress...
Fabian Niederreiter
am 1 Apr. 2021
dpb
am 1 Apr. 2021
Your former response was throwing away the time factor and averaging across all months/years to get a single average???
Fabian Niederreiter
am 1 Apr. 2021
Fabian Niederreiter
am 5 Apr. 2021
Fabian Niederreiter
am 6 Apr. 2021
Antworten (1)
dpb
am 29 Mär. 2021
0 Stimmen
See the optional 'nanflag' argument to mean--
M = mean(___,nanflag) specifies whether to include or omit NaN values from the calculation for any of the previous syntaxes. mean(A,'includenan') includes all NaN values in the calculation while mean(A,'omitnan') ignores them.
cellfun and an anonymous function should let you do this in one line, methinks. :)
I didn't explore the big table in depth, but I'd guess you could probably also do all the analyses directly with the table itself with the use of grouping variables and rowfun and perhaps varfun
Kategorien
Mehr zu Tables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!