如何將行與 0 和 1 進行比較以找出兩種疾病的患病率和聚類情況?您好,我是 JMP 的新用戶且沒有經驗,正在撰寫我的博士論文。 我根本不知道如何比較我的部分數據,我需要幫助。 我的數據由 146 列組成,分別為 146 種醫療狀況為 1 或 0(是/否)。 我有大約 14000 行(患者)來比較這些數據。 我需要找出同一個人的兩種疾病最常見組合的順序。 我怎樣才能做到這一點?
非常感謝幫助,
艾瑪
分析回复:如何比較行與 0 和 1 以找出兩種醫療狀況的患病率和聚類情況?你好@EmmaLT ,
我想我知道如何做你問的事情,但如果你能分享你的一些數據會有所幫助——如果需要,你可以將它匿名。 它不需要是整個數據集,只是一個子集,這樣我就可以更好地了解數據的結構,因為這可能會影響如何進行分析。
DS
回复:如何比較行與 0 和 1 以找出兩種疾病的患病率和聚類情況?我創建了一個示例腳本,它生成一個示例數據表來運行分析。我只創建了 100 行數據,因為創建數據對需要一段時間。結果表提供了發現每種醫療條件組合的患者人數。

如果您一次在所有 14000 名患者上運行該腳本,將花費大量時間。您可以輕鬆地在數據的子集上運行它,然後組合結果表。
Names Default To Here( 1 );
dt = New Table( "raw Data" );
dt << add rows( 100 );
dt << New Column( "Patient", set each value( Row() ) );
Try( dt << delete columns( "Column 1" ) );
For( i = 1, i <= 146, i++,
dt << New Column( "Med Cond " || Char( i ),
set each value( Round( Random Uniform( 0, 1 ), 0 ) )
)
);
// Create the paired data table
dtPair = New Table( "Pairs",
New Column( "Patient" ),
New Column( "First Med Cond", Character ),
New Column( "Second Med Cond", Character )
);
//Populate the Pairs Table
For( theRow = 1, theRow <= N Rows( dt ), theRow++,
For( theFirstCond = 2, theFirstCond <= N Cols( dt ), theFirstCond++,
If( Column( dt, theFirstCond )[theRow] == 1,
thePatient = dt:Patient[theRow];
firstCond = (Column( dt, theFirstCond )) << get name;
For( theSecondCond = theFirstCond + 1, theSecondCond <= N Cols( dt ),
theSecondCond++,
If( Column( dt, theSecondCond )[theRow] == 1,
dtPair << add row( 1 );
pairRow = N Rows( dtPair );
dtPair:Patient[pairRow] = thePatient;
dtPair:First Med Cond[pairRow] = firstCond;
dtPair:Second Med Cond[pairRow] = (Column( dt, theSecondCond )) << get name;
)
);
)
)
);
dtSummary = dtPair << Summary(
Group( :First Med Cond, :Second Med Cond ),
Freq( "None" ),
Weight( "None" )
);
dtSummary << sort( by(N Rows), order(descending), replace table(11));回复:如何比較行與 0 和 1 以找出兩種疾病的患病率和聚類情況?出現的是“同一個人兩種疾病最常見組合的順序"可能意味著幾個不同的分析目標。 但是,無論隱含的分析是什麼,我都強烈建議先查看數據“中”的內容。
一種方法是使用“Cols > Utilities > Combine Columns...”來創建一個新列,其中包含每個患者在每種情況下的狀態。 然後您可以使用“Graph > Graph Builder”來製作這個新列的樹狀圖,並通過工具提示檢查結果。 如果您不確定如何執行此操作的詳細信息,請嘗試在線文檔. 請注意,在如此多的條件下,這可能只是一團糟。
作為新用戶,您可能對編寫腳本不感興趣。 但是下面的腳本模擬了一些數據,並製作了Treemap。 由於隨機性,您每次看到的內容可能會有所不同。 但是運行此代碼應該會生成如下圖:

要運行腳本,請執行“文件 > 新建 > 新腳本”,將代碼粘貼到出現的窗口中,然後執行“編輯 > 運行腳本”。
NamesDefaultToHere(1);
// Generate some fake binary data for each condition (maximum possible incidence for one condition is 20% of the patients):
// This is unrepresentative since the incidences of the conditions are treated as independent, but the in practice this may not
// be the case
nr = 1400; // Number of patients
nc = 15; // Number of conditions
m = J(nr, nc, 0);
for(c=1, c<=nc, c++,
incidence = RandomInteger(0, Round(0.2 * nr));
m[RandomIndex(nr, incidence), c] = 1;
);
dt = asTable(m);
dt << setName("Fake Incidence Data");
// Use 'Combine Columns' to make a binary string for each patient indicating what conditions they have
cols = dt << getColumnNames;
dt << combineColumns(columns(Eval(cols)), ColumnName("Patient Condition"), Delimiter( "" ), MultipleResponse(0));
// Make a Treemap of the patient conditions
dt << Graph Builder(
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( :Patient Condition ) ),
Elements( Treemap( X, Legend( 1 ) ) )
);
// Aggregate the patient comnditions to a new table and sort it (descending)
//dt2 = dt << Summary(Group(:Patient Condition));
//dt2 << Sort(By(:N Rows), ReplaceTable, Order(Descending));