注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
我上学的时候反正统计是不怎么写unit test, 所谓的functional test是靠人来看的,比如结果是否"make sense" - 这个定义很虚啊。。。。
所以想请教一下有计算机背景的同学,如果你也写统计计算的程序(不一定是R package级别的),经常一个任务就是:给你一个data set要用如此这般的方法分析,得到一些结论。
但是统计里面问题是,针对原来的数据,你是不知道result的。
i don't mean testing the output of base or other R packages. I don't think you need to test the output from glm() is correct. 但是如果model specification (i.e. the parameters, or model)设置的不对,这些才是出bug的地方,比如你本来想include subset,但是你忘记了,这就是个很隐藏的bug. 或者有两个名字接近的变量,在model里面写错了,就是错。
或者你有一个procedure that takes a few steps, like read data, clean it up, impute missing values, fit a few different models and see what's best. Select that best, and report results in tables and graphs,
如果用计算机里面unit test的想法,应该是找一个很小的数据,你可以人工的知道它结果应该如何,用来做test case。
但是以上描述的这个过程,你事先如何知道哪个情况可以用来做测试呢?因为难以预测数据里面什么东西会interesting
即使是unit test,一般说test boundary and risky 的情况。但是统计里面,什么是boundary case and risk? 统计里面的结论经常不是代码不跑,而是跑出来的东西不make sense --- how do you define "sense" into a self-testing test case, that runs and prints "OK" every time you run it?
当然,应该break that procedure up,每个步骤都是单独的,可以被测试,unit test probably would find typos etc fast.
.--
但是整个过程需要functional test,可是统计数据的结论经常是未知 的,怎么能找到合适的 whole test cases呢?
|