Brown-Mood Median Test

对于两独立样本尺度中的位置参数(中位数)检验问题:

\(H_0: med_x = med_y\)   \(H_1=med_x > med_y\)

在\(H_0\)假设下,两组数据具有相同的中位数

对于X,Y两组数据组成的两个数组,进行中位数比较。

核心是比较\(med_xy\) 和\(med_x\) \(med-y\)的关系。

X Y sum
>\(M_{xy}\) A B t
<\(M_{xy}\) C D (m+n)-(A+B)
\(\sum\) m n m=n=A+B+C+D

when m,n,t are fixed.

则A的密度函数如下:

\(P(A=k)=\frac{\binom{m}{k}\binom{n}{n-k}}{\binom{m+n}{t}}\), k\(\leqslant\) min{m,t}

以下是Brown-Mood R代码

  1. #Brown-Mood median test
  2. BM.test <- function(x,y,alt)
  3. {
  4. xy <- c(x,y)
  5. md.xy <-median(xy)
  6. t <- sum(xy > md.xy)
  7. lx <- length(x)
  8. ly <- length(y)
  9. lxy <- lx + ly
  10. A <- sum(x > md.xy)
  11. if(alt == "greater")
  12. {w <- 1 - phyper(A,lx,ly,t)}
  13. else if (alt == "less")
  14. {w <- phyper(A,lx,ly,t)}
  15. conting.table = matrix(c(A,lx-A,lx,t-A,ly-(t-A),ly,t,lxy-t,lxy),3,3)
  16. col.name <- c("X","Y","X+Y")
  17. row.name <- c(">MXY","<MXY","TOTAL")
  18. dimnames(conting.table)<-list(row.name,col.name)
  19. list(contingencu.table=conting.table,p.value = w)
  20. }

这里要特别注意phyper()函数的参数中关于 lower.tail = TRUE 和 FALSE的定义,防止出现多余计算。

\[phyper(q,m,n,k) = \frac{\binom{m}{k}\binom{n}{n-k}}{\binom{m+n}{t}}, k\leqslant min(m,t)
\]

大样本计算时,趋于正态分布:

binom 分布的 $$E[X] = μ = t\cdot\frac{m}{m+n}$$

\[D[x]
\]

example:

  1. x <- c(698,688,675,656,655,648,640,639,620)
  2. y <- c(780,754,740,712,693,680,621)
  3. BM.test(x,y,"less")
  4. $contingencu.table
  5. X Y X+Y
  6. >MXY 2 6 8
  7. <MXY 7 1 8
  8. TOTAL 9 7 16

Brown Mood Median Test的更多相关文章

  1. No.004:Median of Two Sorted Arrays

    问题: There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the ...

  2. [LeetCode] Find Median from Data Stream 找出数据流的中位数

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no ...

  3. [LeetCode] Median of Two Sorted Arrays 两个有序数组的中位数

    There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...

  4. Applying vector median filter on RGB image based on matlab

    前言: 最近想看看矢量中值滤波(Vector median filter, VMF)在GRB图像上的滤波效果,意外的是找了一大圈却发现网上没有现成的code,所以通过matab亲自实现了一个,需要学习 ...

  5. 【leetcode】Median of Two Sorted Arrays

    题目简述: There are two sorted arrays A and B of size m and n respectively. Find the median of the two s ...

  6. Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing

    B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...

  7. 【leedcode】 Median of Two Sorted Arrays

    https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 and num ...

  8. Find Median from Data Stream

    常规方法 超时 class MedianFinder { vector<int> coll; public: MedianFinder(){ } void heapfu(vector< ...

  9. 数据结构与算法(1)支线任务8——Find Median from Data Stream

    题目如下:(https://leetcode.com/problems/find-median-from-data-stream/) Median is the middle value in an ...

随机推荐

  1. Ionic Framework - Getting 'ionic start [appName]' Working Behind a Proxy

    This is a quick hacky way to get the ionic start [appName] command working from behind a proxy. I ra ...

  2. Visual Studio 2017 15.7 下的.NET Core

    Visual Studio 2017 15.7版本发布,对.NET Core项目的主要相关改变如下, 同时对Xamarin.Android和iOS项目的支持上也做了较大改进. 一. .NET Core ...

  3. JeeSite数据分页与翻页

    本文章介绍的是JeeSite开源项目二次开发时的一些笔记,对于没有使用过JeeSite的可以不用往下看了,因为下面的代码是跟JeeSite二次开发相关的代码,不做JeeSite的二次开发,以下代码对您 ...

  4. Lintcode399 Nuts & Bolts Problem solution 题解

    [题目描述] Given a set of n nuts of different sizes and n bolts of different sizes. There is a one-one m ...

  5. 《Complete Guide to Value Investing》读书总结

    大好的周末,决定写一篇读书笔记.:) 最近读了一些股票估值以及价值投资相关的文章和书籍.今天将其中的一本做一些笔记以及简单的总结. 该书名为<Complete Guide to Value In ...

  6. NSURLSession 所有的都在这里(二)

    前面一篇我们说了什么? 这是这个关于NSURLSession的第二篇文章,第一篇再加上这篇文章,就大概的把NSURLSession的API以及一些简单使用我们也就说的差不多了,这篇文章总结哪些点呢?相 ...

  7. ML.NET指南

    ML.NET是一个免费的.开源和跨平台的机器学习框架,使您能够构建定制的机器学习解决方案,并将它们集成到您的. net应用程序.本指南提供了许多关于与ML.NET合作资源. 关于ML.NET的更多信息 ...

  8. 利用webmagic获取天猫评论

    引言 爬取商品信息 爬取商品评论 数据清洗 1. 引言 现代网页往往其HTML只有基本结构,而数据是通过AJAX或其他方法获取后填充,这样的模式对爬虫有一定阻碍,但是熟练以后获取并不困难,本文以爬取天 ...

  9. 5月11日——IOS下如何检测用户是否安装微信

    执行如下代码: var  WXApi  =  plus.ios.import("WXApi"); var  isWXInstalled  =  WXApi.isWXAppInsta ...

  10. Git的一些操作

    前言 记录一些经常需要用到的命令. 私钥.公钥的生成(默认在C盘用户文件下生成) ssh-keygen -t rsa //rsa加密 拉取远程分支并与本地分支合并 git pull [url] 上述效 ...