曼·肯德爾<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />大家好。 我正在嘗試運行曼肯德爾來測試時間趨勢是否顯著。 在 JMP 手冊或任何在線內容中都找不到它。 有人有主意嗎?
謝謝!
曼·肯德爾謝謝女士和戴夫! 我不確定 Kendall 的 Tau 和 Mann-Kendall 測試是否相同(和/或相關)。 感謝您提供有關多變量測試的信息以及腳本!
曼·肯德爾即使 Mann-Kendall 檢驗統計量和 Kendall Tau b 的定義經常用不同的術語描述(分別從時間序列和相關性角度),但據我所知,它們本質上是相同的。
下面是我很久以前寫的一個腳本。 它計算並顯示泰爾斜率並執行曼-肯德爾檢驗。 圖中顯示參數線性回歸線僅供比較。 我計劃通過包含“By”函數以及解釋季節性模式的可能性來概括該腳本。 但我還沒有時間去實現這些計劃。 我希望這能給你一些想法。
dt =當前數據表() ;
dlg =列對話框(
“根據數據表估計 Theil 斜率和 Kendall Tau” ||
查爾( dt <<得到名字) ,
伊蘇=列列表( “選擇Y” ,
麥克斯科爾( 1 ) ,
明科爾( 1 ) ,
數據類型(數字)
) ,
Xs =列列表( “選擇X” ,
麥克斯科爾( 1 ) ,
明科爾( 1 ) ,
數據類型(數字)
) ,
團體=列列表( “通過(不工作)” ,麥克斯科爾( 1 ) )
) ;
科利=柱子( dt , dlg [ “是” ] ) ;
列X =柱子( dt , dlg [ “×” ] ) ;
colGroup =柱子( dt , dlg [ “團體” ] ) ;
//泰爾斜率的計算
n = N 行( dt ) ;
連續下坡= J ( n , n , 。 ) ;
為了(我= 1 ,我< n ,我++,
為了( j =我+ 1 , j <= n , j ++,
連續下坡[我, j ] = (科利[ j ] -科利[我]) / (列X [ j ] -列X [我])
)
) ;
泰爾=分位數( 0.5 ,連續下坡) ;
//Kendall 的 Tau b 測試斜率是否不同於零
MV =多變量(
是(科利,列X ) ,
散點圖矩陣( 0 ) ,
多元相關性( 0 ) ,
肯德爾的頭( 1 )
) ;
//繪製數據並添加線性回歸和泰爾斜率
BIV =雙變量(
是(科利) ,
X (列X ) ,
擬合線( {線條顏色( “紅色的” )} ) ,
特別適合(坡(泰爾) , {線條顏色( “綠色的” )} ) ,
無形的
) ;
重組病毒= BIV <<報告;
重組病毒[ “線性擬合” ] <<像這樣關閉所有;
重組病毒[輪廓盒( 7 )] <<設置標題( 《泰爾斜坡》 ) ;
D b =報告( MV )[ “多元” ] <<家長;
D b <<前置(重組病毒) ;
D b [文本框( 4 )] <<設置文本( 《泰爾斜坡》 ) ;
重組病毒<<關閉窗口;
回复:曼·肯德爾我不確定 Mann-Kendall 檢驗與非參數相關性的 Kendall Tau 統計量的相關程度(如果有的話)。後者可以在多變量平台下訪問:分析>多變量方法,然後從多變量報告中選擇熱點中的非參數相關性。
如果測試完全不同,我會對您對此方法的任何參考感興趣。我正在考慮構建一個插件來實現為水文學領域開發的多種方法(例如赫斯特指數)
問候
戴夫
回覆:曼恩·肯德爾你好,這是對此腳本的更新,它涵蓋了使用大類別範例指定按角色(有 2 個層級)中的列的情況。
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dlg = Column Dialog(
"Estimate Theil slope and Kendall Tau from Data Table " ||
Char( dt << get name ),
Ys = ColList( "Select Y",
maxcol( 1 ),
mincol( 1 ),
Datatype( numeric )
),
Xs = ColList( "Select X",
maxcol( 1 ),
mincol( 1 ),
Datatype( numeric )
),
Group = ColList( "By", maxcol( 1 ) )
);
colY = Column( dt, dlg["Ys"] );
colX = Column( dt, dlg["Xs"] );
colGroup = Column( dt, dlg["Group"] );
//create subset data tables when By Role is used
subdt = dt << Subset(
By( :sex ),
All rows,
Selected columns only( 0 ),
);
//hide subset data tables, for 2 levels of the Group column in the By Role
subdt[1] << Show Window(0);
subdt[2] << Show Window(0);
//Calculation of Theil-Sen slope: A robust non-parametric estimate of trend magnitude.
theil = {}; //create empty list call 'theil'to store Theil-Sen slopes
for (k = 1, k <= Nitems(subdt), k++,
curY = Column( subdt[k], dlg["Ys"] );
curX = Column( subdt[k], dlg["Xs"] );
n = N Rows( subdt[k] );
slopes = J( n, n, . ); //this is initialized not as an empty matrix but it's full of missing values
For( i = 1, i < n, i++,
For( j = i+1, j <= n, j++,
slopes[i, j] = (curY[j] - curY[i]) / (curX[j] - curX[i])
)
);
insert into(theil, Quantile( 0.5, slopes )); //calculate the median of all the slopes
);
new window("windowname",
/*Kendall's Tau b to test if slope differs from zero. Analogous to the Mann-Kendall significance test, which Outputs the S statistic and p-value.*/
mv = dt << Multivariate(
Y( colY, colX ),
Scatterplot Matrix( 0 ),
Correlations multivariate( 0 ),
Kendall's Tau( 1 ), /*see above*/
By(colGroup)
);
//Plot data and add linear regression and Theil's slope
biv = dt << Bivariate(
Y( colY ),
X( colX ),
By(colGroup),
Fit Line( {Line Color( "Red" )} ),
//invisible
);
);
//Plot Theil's Slopes using Fit special in Bivariate report
biv[1] << Fit Special( Slope( theil[1] ), {Line Color( "Green" )});
biv[2] << Fit Special( Slope( theil[2] ), {Line Color( "Green" )});
rbiv = biv << Report;
rbiv[1]["Linear Fit"] << close all like this;
//all of the second linear fit outline boxes under an outline box that contains the word "sex" in the title is what I want
tsb = rbiv << Xpath("(//OutlineBox[text()='Linear Fit'])[2]"); //this returns the list of display boxes titled "Linear Fit" that I want to change to "Thiel's slope" and then I am capturing this reference with the variable name tsb
tsb << set title( "Theil's Slope" );