## Test Results in a table

Antonio Melieni

### Antonio Melieni (view profile)

さんによって質問されました 2019 年 5 月 22 日

さんによって 編集されました 2019 年 5 月 23 日

さんの 回答が採用されました
Hi
I need to performe an adf test for several columns of an array and need the results for all of the columns in one table.
Is that possible?
My idea is this:
for i = size(array_x,2)
end
end
any ideas?

#### 0 件のコメント

サインイン to comment.

## 1 件の回答

2019 年 5 月 22 日

2019 年 5 月 22 日
採用された回答

This should get you started. This solution only saves the h and pValue outputs - you can add in the stat and cValue variables by following my example. They are all scalar values so it should be fairly straightforward to add those in (I intentionally left them out so you'd have some practice).
One note: you specified row names but I added them as column names (I assume that's what you meant since you only had 4 names and the adftest() requires a sample size of at least 10).
% Create fake data
array_x = rand(40,5);
h = zeros(size(array_x,2),1); %Column vector!
pValue = h;
for i = size(array_x,2)
end
Please feel free to comment below with questions etc.

#### 4 件のコメント

2019 年 5 月 23 日
Typically tidy data principles suggest that rows of a table indicate different observations while columns of a table store different variables [1,2]. Of course you can store the data any way you want but if other people are working with the table, it's recommended to stick to the tidy data principles.
If you'd like to transpose the table in my answer, you'll just need to transpose the variables after the loop and specify the "RowNames" rather than "VariableNames". If you need help, share what you've got and I can help fix it.
Antonio Melieni

### Antonio Melieni (view profile)

2019 年 5 月 23 日
You gave me the right input to achiev what I needed :)
%Summary of this function goes here
% Detailed explanation goes here
array_x = table2array(array_x);
array_y = zeros(size(array_x,2),4);
for i = 1: size(array_x,2)
array_y(i,:) = [h,pValue,stat,cValue];
end
'VariableNames',{'Null_rejected','pValue','Test_Statistic','cValue'},...
'RowNames',{'EUR_USD','GBP_USD','USD_CHF','USD_JPY'});
end

2019 年 5 月 23 日
Nice work! You could do this if you want to save a line of code
for i = 1: size(array_x,2)