How to compare columns from two data sets in a loop

4 Ansichten (letzte 30 Tage)
Tomaszzz
Tomaszzz am 10 Mär. 2022
Beantwortet: Sourabh am 24 Jan. 2025
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 Kommentare
KSSV
KSSV am 10 Mär. 2022
What is ICC? What it does?
Tomaszzz
Tomaszzz am 10 Mär. 2022
Bearbeitet: Tomaszzz am 10 Mär. 2022
@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).

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Sourabh
Sourabh am 24 Jan. 2025
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:

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by