How to compare columns from two data sets in a loop

4 ビュー (過去 30 日間)
Tomaszzz
Tomaszzz 2022 年 3 月 10 日
回答済み: Sourabh 2025 年 1 月 24 日
Hi all,
I want to compare columns from two data sets in a loop using the ICC function. Is there a way to simplify what I am doing below?
%Import csv file with data
sq_dot1 = importfile('sq_dot1.csv');
sq_dot2 = importfile('sq_dot2.csv');
% variable 1
var1=[sq_dot1(:,1),sq_dot2(:,1)];
[var1_r, var1_LB, var1_UB, var1_F, var1_df1, var1_df2, var1_p]=ICC(var1,'C-k',0.05,0.5);
var1_SD= std(var1(:,1)) + std(var1(:,2))/2;
SEM_var1=var1_SD*sqrt(1-var1_r);
% variable 2
var1=[sq_dot1(:,2),sq_dot2(:,2)];
[var2_r, var2_LB, var2_UB, var2_F, var2_df1, var2_df2, var2_p]=ICC(var2,'C-k',0.05,0.5);
var2_SD= std(var2(:,1)) + std(var2(:,2))/2;
SEM_var2=var2_SD*sqrt(1-var2_r);
% repeat for remaining 52 variables
%save results as a table with rows as variables
row1 = var1
row2 = var 2
row3 = var 3 etc
% and column headers as outcomes
r, LB, UB, F, df1, df2, p, SEM
  2 件のコメント
KSSV
KSSV 2022 年 3 月 10 日
What is ICC? What it does?
Tomaszzz
Tomaszzz 2022 年 3 月 10 日
編集済み: Tomaszzz 2022 年 3 月 10 日
@KSSVThanks. interclass corrleation coefficient; describes how strongly units in the same group resemble each other; so in this case how strongly q_dot1(:,1) resembles sq_dot2(:,1).

サインインしてコメントする。

回答 (1 件)

Sourabh
Sourabh 2025 年 1 月 24 日
The most efficient way to perform the comparison would be to use a “for” loop to iterate over the number of variables.
Within the "for" loop, extract the corresponding data for each column from the two datasets. Then, calculate the Intraclass Correlation Coefficient (ICC), Standard Deviation (SD), and Standard Error of Measurement (SEM). Additionally, save the results for each variable into a "table" with preallocated space.
Preallocation improves performance by avoiding dynamic resizing during the loop, which can be computationally expensive.
For more information on “for” loop, please refer the following documentation:
For information on how to create a “table” with preallocated space and store results in it, kindly refer the following documentation:

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by