﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-人在江湖-随笔分类-BI</title><link>http://www.blogjava.net/vcycyv/category/48805.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 10 Dec 2015 06:12:58 GMT</lastBuildDate><pubDate>Thu, 10 Dec 2015 06:12:58 GMT</pubDate><ttl>60</ttl><item><title>自录pentaho视频教程</title><link>http://www.blogjava.net/vcycyv/archive/2011/11/28/365060.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Mon, 28 Nov 2011 13:58:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/11/28/365060.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/365060.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/11/28/365060.html#Feedback</comments><slash:comments>27</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/365060.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/365060.html</trackback:ping><description><![CDATA[<p>Pentaho是一个开源的BI套件。这段时间自己学习了一下，录了个视频demo它的用法，demo了ETL工具，action sequence, Metadata的管理，report designer, weka。也提到了一点儿warehousing的理论，一共90分钟。</p>
<p>youku地址：<br /> </p><div>http://v.youku.com/v_show/id_XNDQwOTYyNDY0.html?from=s1.8-1-1.2&nbsp;</div>
<div>
<div>如果链接失效了，可以给我发邮件<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#118;&#99;&#121;&#99;&#121;&#118;&#64;&#49;&#54;&#51;&#46;&#99;&#111;&#109;">vcycyv@163.com</a>&nbsp;&nbsp;<br />
</div>
</div>
<p>&nbsp;书的下载地址：<a title="http://115.com/file/aqv7r05e#" href="http://115.com/file/aqv7r05e#">http://115.com/file/aqv7r05e#<br />
</a></p>
<p>
</p><img src ="http://www.blogjava.net/vcycyv/aggbug/365060.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-11-28 21:58 <a href="http://www.blogjava.net/vcycyv/archive/2011/11/28/365060.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>神经网络</title><link>http://www.blogjava.net/vcycyv/archive/2011/09/25/359481.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Sun, 25 Sep 2011 15:29:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/09/25/359481.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/359481.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/09/25/359481.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/359481.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/359481.html</trackback:ping><description><![CDATA[<p>神经网络模型特点：</p> <p>训练模型的时间比较长；对于训练数据没涵盖到的数据，也有比较好的预测能力。相对于决策树，它处理连续型的输入输出能力比较好。神经网络模型不容易解释。</p> <p>神经网络分三层，input layer, hidden layer和output layer. 理论上hidden layer可以有任意多层，在实际中，往往只有一层被使用。</p> <p>对输入数据的每个属性进行标准化可以提高训练速度。对于连续型的属性，往往每个domain value一个input unit. 如果是classification,对于二值型的output, 可以用一个output unit（0，1）表示。如果有多个class, 每种class可以用一个output unit.</p> <p>hidden layer里放多少unit往往是慢慢尝试出来的。</p> <p>贴书上的图，看文字叙述很难懂，但是看一个具体的例子是怎么算的数就比较容易：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb.png" width="697" height="487"></a> </p> <p>其中：<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_1.png" width="143" height="47"></a> 是算某一个节点输入值的. Wij是权重值，每个节点的初始权重值是随机的，往往是-1到1或者-0.5到0.5，<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_16.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_7.png" width="20" height="21"></a> 是Bias.</p> <p>算某个节点的output，是这样算的：<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_2.png" width="125" height="60"></a> ， 这样可以得到一个0到1之间的数，range比较小。</p> <p>神经网络的大致思路是，如果经过神经网络后预测的值不对，就返回来调整hidden layer units的权重，做错了事就回头反思一下，直到总做对事为止。</p> <p>计算误差的方式，output layer：<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_3.png" width="217" height="28"></a>&nbsp; <a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_4.png" width="353" height="19"></a> </p> <p>hidden layer:<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_5.png" width="207" height="41"></a> ,其中Wjk是从j到下一层的k节点的权重。所以这个过程叫backpropagate.</p> <p>backpropagate是为了修改权重和bias。</p> <p>修改权重：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_14.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_6.png" width="146" height="58"></a> </p> <p>其中l叫learning rate, 通常是0到1之间的数。</p> <p>修改bias:</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_18.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_8.png" width="103" height="60"></a> </p> <p>神经网络结束调节可以有多种，比如<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_20.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_9.png" width="35" height="22"></a> 足够小，或者misclassification足够小或者已经走过了预先设定那么多次的epochs</p> <p>例子：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_22.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_10.png" width="583" height="571"></a> </p> <p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p></p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_24.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/51c0b7431acb_E358/image_thumb_11.png" width="368" height="457"></a></p> <p>神经网络往往被批评可解释性不好，一种解释的方式是sensitivity analysis.就是x如果减5%，y会增加8%这种风格。</p><img src ="http://www.blogjava.net/vcycyv/aggbug/359481.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-09-25 23:29 <a href="http://www.blogjava.net/vcycyv/archive/2011/09/25/359481.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>决策树</title><link>http://www.blogjava.net/vcycyv/archive/2011/09/18/358938.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Sun, 18 Sep 2011 15:27:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/09/18/358938.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/358938.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/09/18/358938.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/358938.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/358938.html</trackback:ping><description><![CDATA[<p>分类问题使用决策树有一些好处，比如不需要太多domain知识。Learning和分类的过程也比较快。</p> <p>&nbsp;</p> <p>决策树的算法需要三个参数：被分类的对象， 对象的属性列表， 属性的选择算法(attribute_selection_method)，学习决策树，主要是学习属性选择算法。</p> <p>&nbsp;</p> <p>Data Mining Concepts and Techniques书里对决策树的构建过程阐述的很清晰，书可以在之前的博客找到： <a title="http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html" href="http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html">http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html</a></p> <p>(1)&nbsp;&nbsp;&nbsp; create a node N;<br>(2)&nbsp;&nbsp;&nbsp; if tuples in D are all of the same class, C then<br>(3) return N as a leaf node labeled with the class C;<br>(4)&nbsp;&nbsp;&nbsp; if attribute list is empty then<br>(5) return N as a leaf node labeled with the majority class in D; // majority voting<br>(6)&nbsp;&nbsp;&nbsp; apply Attribute selection method(D, attribute list) to ﬁnd the “best” splitting criterion;<br>(7)&nbsp;&nbsp;&nbsp; label node N with splitting criterion;<br>(8)&nbsp;&nbsp;&nbsp; if splitting attribute is discrete-valued and<br>multiway splits allowed then // not restricted to binary trees<br>(9) attribute list = attribute list - splitting attribute; // remove splitting attribute<br>(10)&nbsp; for each outcome j of splitting criterion<br>// partition the tuples and grow subtrees for each partition<br>(11)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let D j be the set of data tuples in D satisfying outcome j; // a partition<br>(12)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if D j is empty then<br>(13) attach a leaf labeled with the majority class in D to node N;<br>(14)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else attach the node returned by Generate decision tree(D j , attribute list) to node N;<br>endfor<br>(15)&nbsp; return N;  <p>生成的树是否是binary的主要取决于属性的选择算法(attribute_selection_method)，比如gini index算法生成的tree就是binary的，information gain生成的没有这样的限制。  <p><font size="4"><strong>关于算法：</strong></font>  <p>information gain:  <p>给对象集合D的某一个对象分组所需要的information可以这样算：  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb.png" width="207" height="60"></a>  <p>其中Pi代表任一对象属于类别Ci的概率  <p>如果用某个属性A来分D,经过A把D分成几组之后，给某一个对象分组所需要的information表述如下（看不懂没关系，下面有例子）  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_1.png" width="244" height="64"></a>  <p>information gain就可以这样算：  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_6.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_2.png" width="227" height="43"></a>  <p>例子：  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_8.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_3.png" width="466" height="369"></a>  <p></p> <p></p> <p></p> <p>The class label attribute, buys computer, has two distinct values (namely, {yes, no}); therefore, there are two distinct<br>classes (that is, m = 2). Let class C1 correspond to yes and class C2 correspond to no.There are nine tuples of class yes and ﬁve tuples of class no. A (root) node N is createdfor the tuples in D. To ﬁnd the splitting criterion for these tuples, we must compute the information gain of each attribute. We ﬁrst compute the expected information needed to classify a tuple in D:  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_10.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_4.png" width="376" height="47"></a>  <p>Next, we need to compute the expected information requirement for each attribute. Let’s start with the attribute age. We need to look at the distribution of yes and no tuples for each category of age. For the age category youth, there are two yes tuples and three no tuples. For the category middle aged, there are four yes tuples and zero no tuples. For the category senior, there are three yes tuples and two no tuples.  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_12.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_5.png" width="310" height="160"></a>  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_14.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_6.png" width="364" height="30"></a> </p> <p>Similarly, we can compute Gain(income) = 0.029 bits, Gain(student) = 0.151 bits, and Gain(credit rating) = 0.048 bits. Because age has the highest information gain among the attributes, it is selected as the splitting attribute.  <p>&nbsp; <p>Gain ratio简述：  <p>information gain在处理多值属性的时候效果不好，比如如果有一个属性是product_id,那么经过他分所有对象之后，每个对象自成一组，也就是说每个组都是pure的，所以分组后的info（D）就是0，所以用product_id分组自然gain的值最大，但是显然这样分组没意义。Gain ratio相当于调整了information gain, 它用比值来计算而不是减法。具体在书里有例子，不详述。  <p>Gini index:  <p>Gini index是用来算impurity of D的。上面说过，这种算法是binary split的。举个binary split的例子：  <p>if income has three possible values, namely {low,<br>medium, high}, then the possible subsets are {low, medium, high}, {low, medium}, {low,high}, {medium, high}, {low}, {medium}, {high}, and {}. We exclude the power set,{low, medium, high}, and the empty set from consideration since, conceptually, they do not represent a split.  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_16.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_7.png" width="154" height="58"></a>  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_18.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_8.png" width="323" height="61"></a>  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_20.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_9.png" width="244" height="43"></a>  <p></p> <p></p> <p>示例：</p> <p>there are nine tuples belonging to the class buys computer = yes and the remaining ﬁve tuples belong to the class buys computer = no.  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_22.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_10.png" width="290" height="47"></a>  <p>To ﬁnd the splitting criterion for the tuples in D, we need to compute the gini index for each attribute. Let’s start with the attribute income and consider each of the possible splitting subsets. Consider the subset {low, medium}. This would result in 10 tuples in partition D1 satisfying the condition “income 属于{low, medium}.” The remaining four tuples of D would be assigned to partition D2 . The Gini index value computed based on this partitioning is  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_24.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2dfe854b575f_F376/image_thumb_11.png" width="393" height="155"></a>  <p></p> <p>类似地可以算出来其他Income的subset, 在扩展到可以类似算age 之类的attribute。</p> <p>&nbsp;</p> <p><strong><font size="4">关于Prune：</font></strong></p> <p><font size="2">为了去掉噪音和outlier,需要修剪(prune) tree.有两种修剪方法：preprune和postprune. </font></p> <p><font size="2">preprune就是一边split tree，一边算着统计量，比如information gain, 或者gini index之类的，一旦算出来的值够不到threshold,就停下来变成叶子节点。</font></p> <p><font size="2">postprune就是把tree grow完了之后，再从底向上剪掉一些分支。剪掉分支的算法叫cost complexity, 它主要基于Leaf的个数和error rate. 就是算一个node如果prune它和保留它之间哪个cost complexisty更大，如果prune之后cost complexity更小了，就prune它。注意算cost complexity要基于一个单独的data set, 不用training dataset, 也不用validation data set.</font></p> <p><font size="2">往往认为postprune可靠性更好一些。 实际中，preprune和postprune可以结合在一起使用。</font></p> <p><font size="2"></font>&nbsp;</p> <p>Data Mining techniques for Marketing Sales and Customer Relationship Management这本书提出了两个需要注意的地方：</p> <p>1. 经过某次split之后的生成两个leaf节点，他们可能是同一个category的。只是概率不一样，但是都过了threshold.</p> <p>2. binary tree可以分target是多个category的。反过来，多值tree也可以给binary target的分类。</p> <p><font size="2"></font></p><img src ="http://www.blogjava.net/vcycyv/aggbug/358938.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-09-18 23:27 <a href="http://www.blogjava.net/vcycyv/archive/2011/09/18/358938.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>cluster聚类分析</title><link>http://www.blogjava.net/vcycyv/archive/2011/09/16/358782.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Fri, 16 Sep 2011 04:55:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/09/16/358782.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/358782.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/09/16/358782.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/358782.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/358782.html</trackback:ping><description><![CDATA[<p>聚类分析被称之为unsupervised分析，一个跟它相似的概念是分类(classification)模型，不同的是，分类模型预先知道一共有几个类别，每个类别的定义是什么，所以叫做supervised。聚类分析预先不知道目标分成哪几类。往往在实际中，先用cluster分成一些类，然后有了这些类之后，可以再可以做classification分析，就是所谓的two steps analytisis.</p> <p>聚类分析的算法主要基于&#8220;距离&#8221;的计算。聚类之后的结果要尽量保证每个segment内部的对象之间距离要短， segment之间的距离要长。这篇博客的内容总结自Han Jiawei的书，这本书可以在这篇博客里找到： <a href="http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html">分享读书笔记Data Mining Concepts and Techniques</a>&nbsp;</p> <p><font size="3"><strong>关于距离：</strong></font></p> <p><font size="2">如果有n个对象，每个对象有p个属性，那么可以得到这样一个矩阵：</font></p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb.png" width="217" height="132" /></a> </p> <p>距离通常是用另一个变形后的矩阵来做的：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_1.png" width="244" height="151" /></a> </p> <p>其中d(2,1)表示第二个对象和第一个对象之间的距离。</p> <p><strong>对于连续型变量(interval)的</strong>，通常要对数据预先做标准化&#8220;standardiz&#8221;，方式如下：</p> <p>1. 算mean absolute deviation.</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/Image(9)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(9)" border="0" alt="Image(9)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/Image(9)_thumb.png" width="323" height="44" /></a></p> <p>2. 得出标准度量(不知道怎么翻译，standardized measurement)</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/Image(10)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(10)" border="0" alt="Image(10)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/Image(10)_thumb.png" width="158" height="60" /></a></p> <p>3.最后结果：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/Image(11)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(11)" border="0" alt="Image(11)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/Image(11)_thumb.png" width="351" height="59" /></a></p> <p>&nbsp;</p> <p>对于二值型(binary)的, 有两种，一种是均衡型的（symmetric），另一种是非均衡型的(asymmetric),均衡指的是yes or no两种状态权重一样。比如如果你没有性别歧视的话，性别是均衡的二值变量。如果通过一系列症状诊断一个人是否生病了，yes比no的权重要大的多。</p> <p>两种形式都通过下面这个2x2的表来算距离：</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_6.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_2.png" width="361" height="120" /></a> </p> <p>对于均衡型的，</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_3.png" width="180" height="50" /></a> </p> <p>对于非均衡型的</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_10.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_4.png" width="151" height="61" /></a> </p> <p>&nbsp;</p> <p>对于类别型（categorical）的变量，比较简单</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_12.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_5.png" width="149" height="56" /></a> </p> <p>where m is the number of matches (i.e., the number of variables for which i and&nbsp; j are<br />in the same state), and p is the total number of variables.  </p><p>&nbsp;</p> <p>对于顺序型（ordinal）的变量，要先把顺序map成[0.0，1.0]之间的数，然后按interval的方式来算。直接上截图，因为太多数学符号了</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_14.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_6.png" width="614" height="278" /></a> </p> <p>书上对每种计算基本都有例子。</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>关于聚类方法：</p> <p>有partitioning, hierarchical, density-based, grid-based, model-based, clustering High-Dimensional, Constraint-Based.</p> <p>Partitioning方法：</p> <p>代表方法是K-means:</p> <p>它的大致算法是，选定K值（最后要分成多少组）后，任选K个object作为cluster的中心，然后对每个其他的对象计算离哪个中心最近，就归到哪个cluster里，最后从每个cluster中找到新的中心，然后这样重复计算，直到聚类没有变化为止。</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_16.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_7.png" width="422" height="136" /></a> </p> <p>&nbsp;</p> <p>Hierarchical方法：</p> <p>分agglomerative和Divisive两种，前者是自底向上的，就是一个一个object merge出一个segment,后者相反，自顶向下的。 上面说的K-means方法有时候和hierarchical联在一起用，因为K-means需要k作为参数，这个参数还挺重要的，极大影响了聚类的结果，可以先用hierarchical看看大致分几类合理，然后再用K-means。</p> <p>&nbsp;</p> <p>Density-based方法：</p> <p>基于距离的算法segment都是类球形的，density-based克服了这个问题。他的理念基本上是，一个对象为中心画个圆，看看圈近来的对象过没过threshold.</p> <p>&nbsp;</p> <p>Grid-Based:</p> <p>它是从上往下分层，底层grid粒度更细。它的特点是是scalability比较好。没细看理论，但是看图能感觉个大概。</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_18.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/cluster_84F5/image_thumb_8.png" width="487" height="147" /></a> </p> <p>&nbsp;</p> <p>&nbsp;</p> <p> Constraint-Based:</p> <p>有的时候用户清楚应用的需求，想要指引聚类的过程，比如每个cluster size的range, 不同对象不用的权重等等。这就用到constraint-based聚类分析。这个也没细看，还有另外的clustering high-dimensional data, model based clustering都没怎么看，也许以后再写一篇&#8220;再访聚类分析&#8221;。下一篇会关于决策树。</p><img src ="http://www.blogjava.net/vcycyv/aggbug/358782.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-09-16 12:55 <a href="http://www.blogjava.net/vcycyv/archive/2011/09/16/358782.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>线性回归</title><link>http://www.blogjava.net/vcycyv/archive/2011/09/11/358462.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Sun, 11 Sep 2011 14:24:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/09/11/358462.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/358462.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/09/11/358462.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/358462.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/358462.html</trackback:ping><description><![CDATA[<p>线性回归主要用最小二乘法得到直线并进行预测。线性回归真正复杂的地方在于检验，这篇博客主要总结线性回归的检验。</p> <p>这篇文字涉及到的检验主要包括拟合优度检验，标准差检验，整体自变量显著性检验-F检验，单个系数显著性检验-t检验。</p> <p>线性回归有一元线性回归和多元线性回归，先说一元的。</p> <p>&nbsp; <p><font size="4"><strong>拟合优度检验</strong>：</font> <p>对样本回归直线与样本观测值之间拟合程度的检验。用判定系数（可决系数）检验，R2 <p>对于 <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image" border="0" alt="Image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image_thumb.png" width="107" height="32"></a> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(1)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(1)" border="0" alt="Image(1)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(1)_thumb.png" width="406" height="57"></a> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(2)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(2)" border="0" alt="Image(2)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(2)_thumb.png" width="280" height="32"></a> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(3)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(3)" border="0" alt="Image(3)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(3)_thumb.png" width="470" height="266"></a> <p>如果Yi=Ŷi 即实际观测值落在样本回归“线”上，则拟合最好。 <p>可认为，“离差”全部来自回归线，而与“残差”无关。 <p>对于所有样本点，则需考虑这些点与样本均值离差的平方和,可以证明： <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(4)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(4)" border="0" alt="Image(4)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(4)_thumb.png" width="314" height="112"></a> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(5)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(5)" border="0" alt="Image(5)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(5)_thumb.png" width="537" height="208"></a> <p>Tss = ESS + RSS <p>Y的观测值围绕其均值的总离差(total variation)可分解为两部分：一部分来自回归线(ESS)，另一部分则来自随机势力(RSS)。 <p>在给定样本中，TSS不变， <p>如果实际观测点离样本回归线越近，则ESS在TSS中占的比重越大，因此 <p>拟合优度：回归平方和ESS/Y的总离差TSS <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(6)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(6)" border="0" alt="Image(6)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/Image(6)_thumb.png" width="386" height="201"></a> <p>&nbsp;</p> <p><strong><font size="4">标准差检验：</font></strong></p> <p>估计标准误差主要是为了估计总体方差。</p> <p>所谓估计标准误差是指估计值与观察值的平均差异程度, 用( S) 表示。而 S 2是总体方差( σ 2 ) 的无偏估计量, 即σ^ 2 =S 2 =Σe i的平方 /(n- 2)。该指标的意义是: S 越小表明实际观测点与所拟和的样本回归线的离差程度越小,&nbsp;&nbsp; 即回归线具有较强的代表性; 反之, S 越大表明实际观 测 点 与 所 拟和的样本回归线的离差程度越大,&nbsp;&nbsp; 即回归线的代表性较差。 <p><img alt="s=\sqrt{\frac{\sum(y_t-\widehat{y}_t)^2}{n-k}}" src="http://wiki.mbalib.com/w/images/math/f/b/7/fb7609749c07009629446d2a49fa66f1.png"> <p>　　式中： <p><i>y</i><sub><i>t</i></sub>——因变量第t期的观察值； <p><img alt="\widehat{y}_t" src="http://wiki.mbalib.com/w/images/math/9/a/a/9aaa59104c4b339a77a06026fc54c3df.png">——因变量第t期的估计值； <p>　　n——观察期的个数； <p>　　k——自由度，为变量的个数(包括因变量和自变量)。 <p>　　判断回归标准差能否通过检验，仍用以下公式：式中： <p><img alt="\frac{s}{\overline{y}_t}\times100%" src="http://wiki.mbalib.com/w/images/math/6/3/8/6383aa28b9eef25164b335d4692db04e.png"> <p>　　s——回归标准差； <p><img alt="\overline{y}_t" src="http://wiki.mbalib.com/w/images/math/2/3/3/233619cf0cd3f90ffccc10bc9518c981.png">——因变量观察值的平均值。 <p>　　当依此式计算出的值小于15%，说明预测模型通过了回归标准差检验。 <p>&nbsp; <p><strong><font size="4">一元相关系数检验：</font></strong> <p>　　在<a href="http://wiki.mbalib.com/wiki/%E5%9B%9E%E5%BD%92%E5%88%86%E6%9E%90%E9%A2%84%E6%B5%8B%E6%B3%95">回归分析预测法</a>中，需要对Ｘ、Ｙ之间相关程度作出判断，这就要计算<a href="http://wiki.mbalib.com/wiki/%E7%9B%B8%E5%85%B3%E7%B3%BB%E6%95%B0">相关系数</a>Ｙ，其公式如下： <p><img alt="r=\frac{\sum(x_i-\bar{X})(Y_i-\hat{y})}{\sqrt{\sum(x_i-\bar{x})^2\sum(y_i-\bar{y})^2}}=\frac{S_{xy}}{\sqrt S_{xx}\bullet{S_{yy}}}" src="http://wiki.mbalib.com/w/images/math/4/4/5/445d3ba26535cca298fa9de2b52c694f.png"> <p>　　相关系数r的特征有： <p>　　①相关系数取值范围为：-1≤r≤1 。 <p>　　②r与b符合相同。当r&gt;0，称正线性相关，<i>X</i><sub><i>i</i></sub>上升，<i>Y</i><sub><i>i</i></sub>呈线性增加。当r&lt;0，称负线性相关，<i>X</i><sub><i>i</i></sub>上升，<i>Y</i><sub><i>i</i></sub>呈线性减少。 <p>　　③|r|=0，X与Y无线性相关关系；|r|=1，完全确定的线性相关关系；0&lt;|r|&lt;1，X与Y存在一定的线性相关关系；|r|&gt;0.7，为高度线性相关；0.3&lt;|r|≤0.7，为中度线性相关；|r|≤0.3，为低度线性相关。 <p><img alt="r=\frac{S_{xy}}{\sqrt{S_{xx}\bullet S_{yy}}}" src="http://wiki.mbalib.com/w/images/math/7/4/4/744cad2354cc8f0f13fbbb7da1016846.png"> <p>&nbsp; <p><strong><font size="4">整体自变量显著性检验-F检验 &amp; 单个系数显著性检验-t检验</font></strong> <p>这两种检验方式在一元中意义是一致的，回归分析中的假设检验包括变量之间的线性关系检验和参数的显著性检验两个内容。前者检验的是解释变量 与被解释变量 能否用一个线性模型来表示，后者检验的是回归模型中的每一个解释变量对被解释变量的影响程度。这两种检验在顺序上是不能颠倒的。 <p>F检验： <p>根据数从线性回归模型可以看到，如果变量X和Y之间的线性关系是显著的，那么解释变量X的变化必然引起被解释变量Y的显著变化，此时，<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_thumb_1.png" width="22" height="26"></a> 一定不为0。否则被解释变量Y的变化将不依赖于解释变量X的变化，而仅仅依赖于随机误差项。因此，变量之间线性关系的检验问题可以转化为检验<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_6.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_thumb_2.png" width="22" height="26"></a> 是否为0。由此我们可以给出以下假设： <p>原假设 : <a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_thumb_1.png" width="22" height="26"></a>=0&nbsp;&nbsp;&nbsp; 备择假设 : <a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_thumb_1.png" width="22" height="26"></a>≠0 <p>如果原假设成立，那么统计量 <p>&nbsp; <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_thumb.png" width="244" height="83"></a>  <p>服从自由度为(k , n-k-1)的F分布 <p>如果计算出的<i>F</i>值大于在给定的显著性水平<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_thumb_3.png" width="20" height="18"></a> 下的临界值<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_10.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/2d646dfe4bb2_FAD9/image_thumb_4.png" width="72" height="26"></a> ，则拒绝接受备择假设，说明解释变量对被解释变量有显著影响，即两者线性关系显著。 <p>&nbsp; <p>t检验： <p>构造出了一个比较复杂的t函数，没理解，参考中，多元线性回归分析预测法和多元线性回归模型拟合优度假设检验都写了具体公式，与F检验类似，也是t值大于临界值时，解释变量有显著影响。 <p>&nbsp; <p>另外，多元线性回归分析预测法也提到了另外两种预测，粗略地看了一下： <p>多重共线性判别 <p>若某个回归系数的t检验通不过，可能是这个系数相对应的自变量对因变量的影平不显著所致，此时，应从回归模型中剔除这个自变量，重新建立更为简单的回归模型或更换自变量。也可能是自变量之间有共线性所致，此时应设法降低共线性的影响。 <p>&nbsp; <p>当回归模型是根据动态数据建立的，则<a href="http://wiki.mbalib.com/wiki/%E8%AF%AF%E5%B7%AE">误差</a>项e也是一个<a href="http://wiki.mbalib.com/wiki/%E6%97%B6%E9%97%B4%E5%BA%8F%E5%88%97">时间序列</a>，若误差序列诸项之间相互独立，则误差序列各项之间没有相关关系，若误差序列之间存在密切的相关关系，则建立的回归模型就不能表述自变量与因变量之间的真实变动关系。D.W检验就是误差序列的自相关检验。检验的方法与一元线性回归相同。 <p><strong><font size="4">参考：</font></strong></p> <h3>一元线性回归预测法:</h3> <p><a href="http://wiki.mbalib.com/wiki/%E4%B8%80%E5%85%83%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E9%A2%84%E6%B5%8B%E6%B3%95">http://wiki.mbalib.com/wiki/%E4%B8%80%E5%85%83%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E9%A2%84%E6%B5%8B%E6%B3%95</a></p> <p>[ppt]一元线性回归模型的统计检验: <a href="http://wenku.baidu.com/view/ca151ff6f61fb7360b4c65d0.html?from=related">http://wenku.baidu.com/view/ca151ff6f61fb7360b4c65d0.html?from=related</a></p> <h3>二元线性回归分析预测法：</h3> <p><a href="http://wiki.mbalib.com/wiki/%E4%BA%8C%E5%85%83%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E5%88%86%E6%9E%90%E9%A2%84%E6%B5%8B%E6%B3%95">http://wiki.mbalib.com/wiki/%E4%BA%8C%E5%85%83%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E5%88%86%E6%9E%90%E9%A2%84%E6%B5%8B%E6%B3%95</a></p> <h3>多元线性回归模型拟合优度假设检验：<a href="http://wenku.baidu.com/view/32b4bcea6294dd88d0d26b6d.html">http://wenku.baidu.com/view/32b4bcea6294dd88d0d26b6d.html</a></h3> <h3>回归估计标准误差与可决系数的比较：<a href="http://wendang.baidu.com/view/110fc16548d7c1c708a1456b.html?from=related">http://wendang.baidu.com/view/110fc16548d7c1c708a1456b.html?from=related</a></h3> <p>【doc】第三章 一元线性回归 <a href="http://wenku.baidu.com/view/3b3bdbbdc77da26925c5b0fa.html">http://wenku.baidu.com/view/3b3bdbbdc77da26925c5b0fa.html</a>&nbsp;</p> <p>多元线性回归分析预测法：<a href="http://wiki.mbalib.com/wiki/%E5%A4%9A%E5%85%83%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E5%88%86%E6%9E%90%E9%A2%84%E6%B5%8B%E6%B3%95">http://wiki.mbalib.com/wiki/%E5%A4%9A%E5%85%83%E7%BA%BF%E6%80%A7%E5%9B%9E%E5%BD%92%E5%88%86%E6%9E%90%E9%A2%84%E6%B5%8B%E6%B3%95</a></p><img src ="http://www.blogjava.net/vcycyv/aggbug/358462.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-09-11 22:24 <a href="http://www.blogjava.net/vcycyv/archive/2011/09/11/358462.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>矩阵与SAS IML浅尝辄止</title><link>http://www.blogjava.net/vcycyv/archive/2011/09/09/358331.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Thu, 08 Sep 2011 23:54:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/09/09/358331.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/358331.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/09/09/358331.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/358331.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/358331.html</trackback:ping><description><![CDATA[<p></p> <p><strong><font size="3">基本概念：</font></strong></p> <p>转置矩阵：</p> <p>如果把<i>m</i><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001_3.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001_thumb.gif" width="14" height="14"></a><i>n</i>阶矩阵<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image002_2.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image002_thumb.gif" width="74" height="24"></a>的第<i>i</i>行改为第<i>i</i>列，第<i>j</i>列改为第<i>j</i>行，就可得到一个新的<i>n</i><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001%5B1%5D.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001[1]" border="0" alt="clip_image001[1]" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001%5B1%5D_thumb.gif" width="14" height="14"></a><i>m</i>矩阵，记作<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image003_2.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image003" border="0" alt="clip_image003" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image003_thumb.gif" width="21" height="17"></a>，称为<i>A</i>的<b>转置</b><b>(</b><b>矩阵</b><b>)</b>，具体表示如下</p> <p>若<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image004_2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image004_thumb.jpg" width="177" height="106"></a>，则<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image005_2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image005" border="0" alt="clip_image005" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image005_thumb.jpg" width="179" height="107"></a> <p>显然，<i>n</i>阶方阵的转置仍是<i>n</i>阶方阵，而且对任何矩阵<i>A</i>，有<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/image_thumb.png" width="70" height="25"></a>  <p>&nbsp; <p>矩阵的乘法： <p>设<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001%5B6%5D.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001[6]" border="0" alt="clip_image001[6]" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001%5B6%5D_thumb.gif" width="153" height="36"></a>分别是<i>m</i>×<i>n</i>, <i>n</i>×<i>p</i>矩阵,则矩阵<i>A</i>与<i>B</i>的乘积是一<i>m</i>×<i>p</i>矩阵，记为 <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image002%5B4%5D.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002[4]" border="0" alt="clip_image002[4]" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image002%5B4%5D_thumb.gif" width="207" height="98"></a>, <p>其中乘积矩阵<i>C</i>中第<i>i</i>行第<i>k</i>列处元素为  <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image003%5B4%5D.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image003[4]" border="0" alt="clip_image003[4]" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image003%5B4%5D_thumb.gif" width="390" height="101"></a>, <p></p> <p></p> <p>并非任何两个矩阵都可以进行: 一个基本的条件是A的列数必须与B的行数相同 <p>矩阵的乘法是不可交换的，或者说，交换之后结果通常不同。 <p>&nbsp; <p>单位矩阵<strong>：</strong></p> <p>它是个方阵,除左上角到右下角的对角线(称为主对角线)上的元素均为1以外全都为0,即<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001%5B8%5D.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image001[8]" border="0" alt="clip_image001[8]" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/SASIML_6F9E/clip_image001%5B8%5D_thumb.gif" width="133" height="97"></a>.</p> <p>&nbsp;</p> <p>逆矩阵：</p> <p>设<i>A</i>是<i>n</i>阶方阵,若存在<i>n</i>阶矩阵<i>B</i>使得<i>AB</i>=<i>BA</i>=<i>I</i><i><sub>n</sub></i>,则称<i>A</i>是可逆的,或说<i>A</i>是可逆矩阵,而<i>B</i>称为<i>A</i>的逆矩阵.可以证明,这样的逆矩阵是唯一的,因此可记为<i>A<sup>-</sup></i><sup>1</sup>，而且只需要<i>B</i>满足一个方程<i>AB</i>=<i>I</i><i><sub>n</sub></i>或<i>BA</i>=<i>I</i><i><sub>n</sub></i>就是<i>A</i>的逆了． <p>&nbsp; <p><b><font size="3">基本语法：</font></b> <p>The following statement assigns a 3 × 2 matrix literal to the matrix Z:<br>z={1&nbsp; 2,&nbsp; 3&nbsp; 4,&nbsp; 5&nbsp; 6};<br>Here is the resulting matrix:<br>Z<br>1 2<br>3 4<br>5 6<br>The following statement creates a matrix W that is three times the matrix Z:<br>w=3#z;<br>Here is the resulting matrix:<br>W<br>3 6<br>9 12<br>15 18 <p>A repetition factor can be placed in brackets before a literal element to have the<br>element repeated. For example, the following two statements are equivalent:<br>answer={[2]&nbsp;&nbsp;&nbsp; ’Yes’,&nbsp; [2]&nbsp;&nbsp;&nbsp; ’No’};<br>answer={’Yes’&nbsp; ’Yes’,&nbsp; ’No’&nbsp; ’No’}; <p>J function: J(&nbsp; nrow&lt;,ncol&lt;,value&gt; &gt; ); <p>I function: I(&nbsp; dimension ); <p>Index vector: <p><font color="#0000ff">&gt;&nbsp;&nbsp;&nbsp; r=1:5;<br></font>R<br>1&nbsp; row 5&nbsp; cols&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (numeric)<br>1 2 3 4 5<br><font color="#0000ff">&gt;&nbsp;&nbsp;&nbsp; s=10:6;<br></font>S<br>1&nbsp; row 5&nbsp; cols&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (numeric)<br>10 9 8 7 6<br><font color="#0000ff">&gt;&nbsp;&nbsp;&nbsp; t=’abc1’:’abc5’;<br></font>T<br>1&nbsp; row 5&nbsp; cols&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (character,&nbsp; size&nbsp; 4)<br>abc1&nbsp; abc2&nbsp; abc3&nbsp; abc4&nbsp; abc5 <p><b></b>&nbsp; <p><b><font size="3">解方程组：</font></b> <p>3x1 − x2 + 2x3&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp; 8<br>2x1 − 2x2 + 3x3&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp; 2<br>4x1 + x2 − 4x3&nbsp;&nbsp;&nbsp; =&nbsp;&nbsp; 9 <p><b>proc</b> <b>iml</b>; <p>reset print; <p>&nbsp;&nbsp; a={<b>3</b> -<b>1</b> <b>2</b>, <p><b>2</b> -<b>2</b> <b>3</b>, <p><b>4</b> <b>1</b> -<b>4</b>}; <p>&nbsp;&nbsp; c={<b>8</b>,<b>2</b>,<b>9</b>}; <p>&nbsp;&nbsp; x=inv(a)*c; <p><b>quit</b>; <p>解为3，5，2</p><img src ="http://www.blogjava.net/vcycyv/aggbug/358331.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-09-09 07:54 <a href="http://www.blogjava.net/vcycyv/archive/2011/09/09/358331.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>时间序列</title><link>http://www.blogjava.net/vcycyv/archive/2011/09/07/358155.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Wed, 07 Sep 2011 01:44:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/09/07/358155.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/358155.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/09/07/358155.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/358155.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/358155.html</trackback:ping><description><![CDATA[<p><strong>相关概念：</strong> </p><p>相对误差（Relative Error）：<a><font color="#000000">绝对误差</font></a>与真值的比值 </p><p>所谓残差（residual error），应该是在回归时，实际y值与回归曲线得到的理论y值之间的差值。 标准残差，就是各残差的标准方差。 </p><p>异方差性（heteroscedasticity ）是为了保证回归参数估计量具有良好的统计性质，经典线性回归模型的一个重要假定是：总体回归函数中的随机误差项满足同方差性，即它们都有相同的方差。如果这一假定不满足，则称线性回归模型存在异方差性。 </p><p>条件方差（Conditional variance）：只要把原来求方差时的概率密度函数换成条件密度函数就行了意义就是当X发生时，Y发生的方差 </p><p>自相关函数（Autocorrelation function，缩写ACF）： </p><p>将一个有序的随机变量系列与其自身相比较，这就是自相关函数在统计学中的定义。每个不存在相位差的系列，都与其自身相似，即在此情况下，自相关函数值最大。如果系列中的组成部分相互之间存在相关性（不再是随机的），则由以下相关值方程所计算的值不再为零，这样的组成部分为自相关。 </p><dl> <dd><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image" border="0" alt="Image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image_thumb.png" width="244" height="39" /></a> </dd><dd><em>E</em> ......... 期望值。  </dd><dd><em>X</em><sub><em>i</em></sub> ........ 在t(i)时的随机变量值。  </dd><dd>&#956;<sub><em>i</em></sub> ........ 在t(i)时的预期值。  </dd><dd><em>X</em><sub><em>i</em> + <em>k</em></sub> .... 在t(i+k)时的随机变量值。  </dd><dd>&#956;<sub><em>i</em> + <em>k</em></sub> .... 在t(i+k)时的预期值。  </dd><dd>&#963;<sup>2</sup> ......... 为方差。</dd></dl> <p>所得的自相关值R的取值范围为[-1,1],1为最大相关值，-1则为最大不相关值。 </p><p>白噪声序列： </p><p>随机变量X（t）（t=1，2，3&#8230;&#8230;），如果是由一个不相关的随机变量的序列构成的，即对于所有S不等于T，随机变量Xt和Xs的协方差均为零，则称其为纯随机过程。对于一个纯随机过程来说，若其期望和方差均为常数，则称之为白噪声过程。白噪声过程的样本实称成为白噪声序列，简称白噪声。之所以称为白噪声，是因为他和白光的特性类似，白光的光谱在各个频率上有相同的强度，白噪声的谱密度在各个频率上的值相同。 </p><p>差分：差分有前向差分和后向差分。前向差分：函数的前向差分通常简称为函数的差分。对于函数，如果： </p><dl> <dd><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(2)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(2)" border="0" alt="Image(2)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(2)_thumb.png" width="218" height="25" /></a>，</dd></dl> <p>则称<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(3)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(3)" border="0" alt="Image(3)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(3)_thumb.png" width="57" height="25" /></a>为的一阶前向差分。只所以称为前向差分是因为以x为参考点，x+1在x的前面。逆向差分：对于函数f(x)，如果： </p><dl> <dd><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(4)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(4)" border="0" alt="Image(4)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(4)_thumb.png" width="224" height="25" /></a></dd></dl> <p>则称<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(5)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(5)" border="0" alt="Image(5)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(5)_thumb.png" width="61" height="27" /></a>为的一阶逆向差分。 </p><p><strong>时间序列的特征</strong> </p><p>非平稳性（nonstationarity，也译作不平稳性，非稳定性）：即时间序列变量无法呈现出一个长期趋势并最终趋于一个常数或是一个线性函数 </p><p>波动幅度随时间变化（Time－varying Volatility）：即一个时间序列变量的方差随时间的变化而变化 </p><p>虽然单独看不同的时间序列变量可能具有非稳定性，但按一定结构组合后的新的时间序列变量却可能是稳定的，即这个新的时间序列变量长期来看，会趋向于一个常数或是一个线性函数。例如，时间序列变量X(t)非稳定，但其二阶差分却可能是稳定的；时间序列变量X(t)和Y(t)非稳定，但线性组合X(t)-bY(t)却可能是稳定的。 </p><p>时间序列分析通常是把各种可能发生作用的因素进行分类，传统的分类方法是按各种因素的特点或影响效果分为四大类：(1)长期趋势；(2)季节变动；(3)循环变动；(4)不规则变动。 </p><p><strong>时间序列预测法种类</strong>， </p><p><strong>1. 简单序时平均数法<a><font color="#000000">算术平均法</font></a></strong> </p><p><strong>2. 移动平均法：</strong>移动平均法是一种简单平滑预测技术，它的基本思想是：根据时间序列资料、<strong>逐项推移</strong>，依次计算包含一定项数的序时平均值，以反映长期趋势的方法。 </p><p>分为简单移动平均法，加权移动平均法。 一般而言，最近期的数据最能预示未来的情况，因而权重应大些。 </p><h4>移动平均法的优缺点</h4> <p>　　使用移动平均法进行预测能平滑掉需求的突然波动对预测结果的影响。但移动平均法运用时也存在着如下问题： </p><p>　　1、 加大移动平均法的期数（即加大n值）会使平滑波动效果更好，但会使预测值对数据实际变动更不敏感； </p><p>　　2、 移动平均值并不能总是很好地反映出趋势。由于是平均值，预测值总是停留在过去的水平上而无法预计会导致将来更高或更低的波动； </p><p>　　3、 移动平均法要由大量的过去数据的记录。 </p><p>使用移动平均法时，主要是要定下来N（用几个时期预测下个时期）是多少，实际中可以取多个N然后比相对误差。 </p><p><strong>3. 指数平滑法：</strong>所有预测方法中，指数平滑是用得最多的一种。简单的全期平均法是对<a><font color="#000000">时间数列</font></a>的过去数据一个不漏地全部加以同等利用；移动平均法则不考虑较远期的数据，并在<a><font color="#000000">加权移动平均法</font></a>中给予近期资料更大的权重；而指数平滑法则兼容了全期平均和移动平均所长，不舍弃过去的数据，但是仅给予逐渐减弱的影响程度，即随着数据的远离，赋予逐渐收敛为零的权数。也就是说指数平滑法是在<a><font color="#000000">移动平均法</font></a>基础上发展起来的一种<a><font color="#000000">时间序列分析预测法</font></a>，它是通过计算指数平滑值，配合一定的时间序列预测模型对现象的未来进行<a><font color="#000000">预测</font></a>。其原理是任一期的指数平滑值都是本期实际观察值与前一期指数平滑值的加权平均。 </p><p>指数平滑法的基本公式是：<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(6)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(6)" border="0" alt="Image(6)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(6)_thumb.png" width="205" height="24" /></a> 式中，</p><ul> <li><em>S</em><sub><em>t</em></sub>--时间t的平滑值；  </li><li><em>y</em><sub><em>t</em></sub>--时间t的实际值；  </li><li><em>S</em><sub><em>t</em> &#8722; 1</sub>--时间t-1的平滑值；  </li><li>a--平滑常数，其取值范围为[0,1]；</li></ul> <p>指数平滑常数取值至关重要。平滑常数决定了平滑水平以及对预测值与实际结果之间差异的响应速度。平滑常数a越接近于1，远期实际值对本期平滑值影响程度的下降越迅速；平滑常数a越接近于 0，远期实际值对本期平滑值影响程度的下降越缓慢。由此，当时间数列相对平稳时，可取较大的a；当时间数列波动较大时，应取较小的a，以不忽略远期实际值的影响。 </p><p>据平滑次数不同，指数平滑法分为：一次指数平滑法、<a><font color="#000000">二次指数平滑法</font></a>和三次指数平滑法等。当<a><font color="#000000">时间数列</font></a>无明显的趋势变化，可用一次指数平滑预测。 </p><h5>（一） 一次指数平滑预测</h5> <p>　　当<a><font color="#000000">时间数列</font></a>无明显的趋势变化，可用一次指数平滑预测。其预测公式为： </p><p>　　yt+1'=ayt+(1-a)yt' 式中， </p><ul> <li>yt+1'--t+1期的预测值，即本期（t期）的平滑值St ；  </li><li>yt--t期的实际值；  </li><li>yt'--t期的预测值，即上期的平滑值St-1 。</li></ul> <p>　　该公式又可以写作：yt+1'=yt'+a(yt- yt')。可见，下期预测值又是本期预测值与以a为折扣的本期实际值与预测值误差之和。 </p><h5>（二） 二次指数平滑预测</h5> <p>　　二次指数平滑是对一次指数平滑的再平滑。它适用于具线性趋势的<a><font color="#000000">时间数列</font></a>。其预测公式为： </p><p>　　yt+m<em>=(2+am/(1-a))yt'-(1+am/(1-a))yt</em>=(2yt'-yt<em>)+m(yt'-yt</em>) a/(1-a) </p><p>　　式中，yt<em>= ayt-1'+(1-a)yt-1</em> </p><p>　　显然，二次指数平滑是一直线方程，其截距为：(2yt'-yt<em>)，斜率为：(yt'-yt</em>) a/(1-a),自变量为预测天数。 </p><h5>（三） 三次指数平滑预测</h5> <p>　　三次指数平滑预测是二次平滑基础上的再平滑。其预测公式是： </p><p>　　yt+m<strong>=(3yt'-3yt<em>+yt</em></strong><em>)+[(6-5a)yt'-(10-8a)yt</em>+(4-3a)yt<strong>]*am/2(1-a)2+</strong> (yt'-2yt<em>+yt'</em>)*a2m2/2(1-a)2 </p><p>　　式中，yt<strong>=ayt-1<em>+(1-a)yt-1</em></strong> </p><p>　　它们的基本思想都是：预测值是以前观测值的加权和，且对不同的数据给予不同的权，新数据给较大的权，旧数据给较小的权。 </p><p><a name=".E6.A1.88.E4.BE.8B.E4.B8.80:.E6.8C.87.E6.95.B0.E5.B9.B3.E6.BB.91.E6.B3.95.E5.9C.A8.E9.94.80.E5.94.AE.E9.A2.84.E7.AE.97.E4.B8.AD.E7.9A.84.E5.BA.94.E7.94.A8.07UNIQ1c31b978507e7322-nowiki-0000002B-QINU1.07UNIQ1c31b978507e7322-nowiki-0000002C-QINU"><br /></a> </p><h5>案例:指数平滑法在销售预算中的应用</h5> <p>　　某软件公司A为例。给出2000-2005年的历史销售资料，将数据代入指数平滑模型。预测2006年的销售额，作为销售预算编制的基础。 </p><p>　　由散点图示可知。根据经验判断法。A公司2000-2005年销售额时间序列波动很大。<a><font color="#000000">长期趋势</font></a>变化幅度较大，呈现明显且迅速的上升趋势，宜选择较大的&#945;值，可在05-O.8间选值，以使预测模型灵敏度高些，结合试算法取0.5，0.6,0.8分别测试。经过第一次指数平滑后，数列呈现直线趋势，故选用二次指数平滑法即可。 </p><p>试算结果见下表。根据偏差平方的均值(MSE)最小，即各期实际值与预测值差的平方和除以总期数．以最小值来确定理的取值的标准，经测算当&#945; = 0.6时，<em>M</em><em>S</em><em>E</em><sub>1</sub> = <em>l</em>445.4；当&#945; = 0.8时，<em>M</em><em>S</em><em>E</em><sub>2</sub>=10783.7；当&#945; = 0.5时，<em>M</em><em>S</em><em>E</em><sub>3</sub> = 1906.1。因此选择&#945; = 0.6来预测2006年4个季度的销售额。  </p><p><a href="http://wiki.mbalib.com/wiki/Image:A%E5%85%AC%E5%8F%B82000-2005%E5%B9%B4%E9%94%80%E5%94%AE%E9%A2%9D%E6%95%B0%E5%88%97%E6%95%A3%E7%82%B9%E5%9B%BE.jpg"><img alt="A公司2000-2005年销售额数列散点图" src="http://wiki.mbalib.com/w/images/7/74/A%E5%85%AC%E5%8F%B82000-2005%E5%B9%B4%E9%94%80%E5%94%AE%E9%A2%9D%E6%95%B0%E5%88%97%E6%95%A3%E7%82%B9%E5%9B%BE.jpg" width="500" longdesc="/wiki/Image:A%E5%85%AC%E5%8F%B82000-2005%E5%B9%B4%E9%94%80%E5%94%AE%E9%A2%9D%E6%95%B0%E5%88%97%E6%95%A3%E7%82%B9%E5%9B%BE.jpg" height="409" /></a> </p><p>　　2005年第四季度<img alt="S_t^{(1)}" src="http://wiki.mbalib.com/w/images/math/5/c/2/5c2f495ad0869994a3e7dcaf10908650.png" />=736.8;<img alt="S_t^{(2)}" src="http://wiki.mbalib.com/w/images/math/3/1/a/31a3aac99dd5668600b6a1f9435a661b.png" />=679.5;；可以求得<img alt="\alpha_{2005}=2S_t^{(1)}-S_t^{(2)}=2\times736.8-679.5=794.1" src="http://wiki.mbalib.com/w/images/math/d/e/d/dede04dad842e2eb7ce9a89c6b8f63de.png" />；<img alt="b_{2005}=\alpha(s_t^{(1)}-S_t^{(2)})/(1-\alpha)=0.6" src="http://wiki.mbalib.com/w/images/math/c/0/b/c0b30f4b04c44a8befadab7fbe8e9604.png" />=(736.8-679.5)/0.4=85.9则预测方<em>Y</em><sub>2005 + <em>T</em></sub> = 794.1 + 85.9<em>T</em>,因此，2006年第一、二、三、四季度的预测值分别为：  </p><p><a href="http://wiki.mbalib.com/wiki/Image:A%E5%85%AC%E5%8F%B82000-2005%E5%B9%B4%E9%94%80%E5%94%AE%E9%A2%9D%E6%8C%87%E6%95%B0%E5%B9%B3%E6%BB%91%E8%A1%A8.jpg"><img alt="A公司2000-2005年销售额指数平滑表" src="http://wiki.mbalib.com/w/images/c/cb/A%E5%85%AC%E5%8F%B82000-2005%E5%B9%B4%E9%94%80%E5%94%AE%E9%A2%9D%E6%8C%87%E6%95%B0%E5%B9%B3%E6%BB%91%E8%A1%A8.jpg" width="500" longdesc="/wiki/Image:A%E5%85%AC%E5%8F%B82000-2005%E5%B9%B4%E9%94%80%E5%94%AE%E9%A2%9D%E6%8C%87%E6%95%B0%E5%B9%B3%E6%BB%91%E8%A1%A8.jpg" height="322" /></a> </p><p><em>Y</em><sub>1</sub> = 794.1 + 85.9 = 800(万元)  </p><p><img alt="Y_2=794.1+85.9\times2=965.9" src="http://wiki.mbalib.com/w/images/math/4/b/8/4b88de483fbc5f7bc884061cc5e2195e.png" />(万元)  </p><p><img alt="Y_3=794.1+85.9\times3=1051.8" src="http://wiki.mbalib.com/w/images/math/b/d/5/bd5e0f6503a69fb010aa6d7ac62a4f99.png" />(万元)  </p><p><img alt="Y_4=794.1+85.9\times4=1137.7" src="http://wiki.mbalib.com/w/images/math/b/b/4/bb4c1bfcafd68ba78e6610835f0b9118.png" />(万元)  </p><p>　　综上所述，本案例首先根据销售历史资料，给出数列散点图。再根据散点图的特征选择二次指数平滑法，通过对&#945;的试算，确定符合预测需要的&#945;值，最后根据指数平滑模型计算出2006年14季度的销售预测值，作为销售预算的基础。  </p><p>&nbsp; </p><p><strong>典型模型</strong>包括arch模型，arima模型等 </p><p><strong>arch模型</strong>： </p><p>ARCH模型的基本思想是指在以前信息集下，某一时刻一个噪声的发生是服从正态分布。该正态分布的均值为零，方差是一个随时间变化的量(即为条件异方差)。并且这个随时间变化的方差是过去有限项噪声值平方的线性组合(即为自回归)。这样就构成了自回归条件异方差模型。 </p><p>　　由于需要使用到条件方差，我们这里不采用恩格尔的比较严谨的复杂的数学表达式，而是采取下面的表达方式，以便于我们把握模型的精髓。见如下数学表达： </p><p>　　Yt = &#946;Xt＋&#949;t (1)其中， </p><ul> <li>Yt为被解释变量，  </li><li>Xt为解释变量，  </li><li>&#949;t为误差项。</li></ul> <p>　　如果误差项的平方服从AR(q)过程，即&#949;t2 =a0＋a1&#949;t－12 ＋a2&#949;t－22 ＋ &#8230;&#8230; ＋ aq&#949;t－q2 ＋&#951;t t =1,2,3&#8230;&#8230; (2)其中， </p><p>　　&#951;t独立同分布，并满足E（&#951;t）= 0, D(&#951;t)= &#955;2 ,则称上述模型是自回归条件异方差模型。简记为ARCH模型。称序列&#949;t 服从q阶的ARCH的过程，记作&#949;t －ARCH(q)。为了保证&#949;t2 为正值，要求a0 &gt;0 ,ai &#8805;0 i=2,3,4&#8230; 。 </p><p>　　上面（1）和（2）式构成的模型被称为回归－ARCH模型。ARCH模型通常对主体模型的随机扰动项进行建模分析。以便充分的提取残差中的信息，使得最终的模型残差&#951;t成为白噪声序列。 </p><p>　　从上面的模型中可以看出，由于现在时刻噪声的方差是过去有限项噪声值平方的回归，也就是说噪声的波动具有一定的记忆性，因此，如果在以前时刻噪声的方差变大，那么在此刻噪声的方差往往也跟着变大；如果在以前时刻噪声的方差变小，那么在此刻噪声的方差往往也跟着变小。体现到期货市场，那就是如果前一阶段期货合约价格波动变大，那么在此刻市场价格波动也往往较大 </p><p>GARCH模型是一个专门针对金融数据所量体订做的回归模型 </p><p><strong>arima模型：</strong> </p><p>Autoregressive Integrated Moving Average Model。 ARIMA（p，d，q）称为差分自回归移动平均模型，AR是自回归, p为自回归项; MA为移动平均，q为移动平均项数，d为时间序列成为平稳时所做的差分次数。 </p><p>ARIMA模型预测的基本程序 </p><p>&nbsp;&nbsp;&nbsp; （一）根据时间序列的<a><font color="#000000">散点图</font></a>、自相关函数和偏自相关函数图以ADF<a><font color="#000000">单位根检验</font></a>其<a><font color="#000000">方差</font></a>、趋势及其季节性变化规律，对序列的平稳性进行识别。一般来讲，经济运行的时间序列都不是平稳序列。 </p><p>　　（二）对非平稳序列进行平稳化处理。如果数据序列是非平稳的，并存在一定的增长或下降趋势，则需要对数据进行差分处理，如果数据存在异方差，则需对数据进行技术处理，直到处理后的数据的自相关函数值和偏相关函数值无显著地异于零。 </p><p>　　（三）根据时间序列模型的识别规则，建立相应的模型。若平稳序列的偏相关函数是截尾的，而自相关函数是拖尾的，可断定序列适合AR模型；若平稳序列的偏相关函数是拖尾的，而自相关函数是截尾的，则可断定序列适合MA模型；若平稳序列的偏相关函数和自相关函数均是拖尾的，则序列适合<a><font color="#000000">ARMA模型</font></a>。 </p><p>　　（四）进行<a><font color="#000000">参数估计</font></a>，检验是否具有统计意义。 </p><p>　　（五）进行<a><font color="#000000">假设检验</font></a>，诊断残差序列是否为白噪声。 </p><p>　　（六）利用已通过检验的模型进行<a><font color="#000000">预测分析</font></a>。 </p><p>取对数可以消除数据波动变大趋势，对数列进行一阶差分，可以消除数据增长趋势性和季节性。 </p><p>一个例子： </p><p>备件消耗预测ARIMA(p,d,q)模型实质是先对非平稳的备件消耗历史数据Yt进行d（d＝0,1,dots,n）次差分处理得到新的平稳的数据序列Xt，将Xt拟合ARMA(p,q)模型，然后再将原d次差分还原，便可以得到Y_t的预测数据。其中，ARMA(p,q)的一般表达式为： </p><p><img alt="X_t=\varphi_1X_{t-1}+\ldots+\varphi_pX_{t-p}+\epsilon_t-\theta_1\epsilon_{t-1}-\ldots-theta_q\epsilon_{t-q},t\in Z" src="http://wiki.mbalib.com/w/images/math/f/b/0/fb0adee6dd2269a954a825eb9de6b593.png" />　　(1) </p><p>　　式中，前半部分为自回归部分，非负整数p为自回归阶数，<img alt="\varphi_1,\ldots,\varphi_p" src="http://wiki.mbalib.com/w/images/math/a/3/4/a34ff7b33cb6b9dee064215437f52349.png" />为自回归系数，后半部分为滑动平均部分，非负整数q为滑动平均阶数，<img alt="\theta_1,\ldots,\theta_q" src="http://wiki.mbalib.com/w/images/math/8/c/a/8ca3c0a8391fe0f3cfd2e04d8396ca91.png" />为滑动平均系数；<em>X</em><sub><em>t</em></sub>为备件消耗数据相关序列，&#949;<sub><em>t</em></sub>为WN(0,&#963;<sup>2</sup>)。 </p><p>　　当q=0时，该模型成为AR(p)模型：<img alt="X_t=\varphi_1X_{t-1}+\ldots+\varphi_pX_{t-p}+\epsilon_t,t\in Z" src="http://wiki.mbalib.com/w/images/math/5/6/e/56e25e893374d05ee58655362dd1e65e.png" />　　(2) </p><p>　　当p＝0时，该模型成为MA(q)模型：<img alt="X_t=\epsilon_t-\theta_1\epsilon_t-1-\ldots-\theta_q\epsilon_{t-q},t\in Z" src="http://wiki.mbalib.com/w/images/math/2/1/b/21b22616803ec48d24a4d5f1ea8d7440.png" />　　(3) </p><p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/%E5%A4%87%E4%BB%B6.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="备件" border="0" alt="备件" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/%E5%A4%87%E4%BB%B6_thumb.jpg" width="244" height="216" /></a> </p><p>所谓零均值化处理就是取前N组（或全部）数据作为观测数据，进行零均值化处理，即：<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(7)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(7)" border="0" alt="Image(7)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(7)_thumb.png" width="117" height="27" /></a>，得到一组预处理后的新序列<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(8)_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Image(8)" border="0" alt="Image(8)" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/Image(8)_thumb.png" width="26" height="27" /></a>。 </p><p><strong>SAS与arima：</strong> </p><p>sas 有proc arima. 分为三个阶段： </p><p>identification: 识别候选arima模型。 </p><p>estimation and diagnositic checking: 为模型估计参数，并提供诊断统计信息帮助判断模型是否好。 </p><p>forcasting: 预测未来值。 </p><p>&nbsp; </p><p>这里有一个proc arima的例子： <a href="http://www.docin.com/p-46241714.html">http://www.docin.com/p-46241714.html</a> </p><p>贴一下代码，生成data set的部分略有改动，copy&amp;paste pdf的数据到txt中，然后批量输入data set. 方便生成data set </p><p>filename input "c:\temp\sun.txt";<br />data exp1;<br />&nbsp;&nbsp; infile input;<br />&nbsp;&nbsp; input a1 @@;<br />&nbsp;&nbsp; year=intnx('year','1jan1742'd,_n_-1); <br />&nbsp;&nbsp; format year year4.; <br />run;  </p><p>proc gplot data=exp1; <br />&nbsp; symbol i=spline v=star h=2 c=green; <br />&nbsp; plot a1*year; <br />run;  </p><p>proc arima data=exp1; <br />&nbsp; identify var=a1 nlag=24; <br />run;  </p><p>estimate p=3; <br />run;  </p><p>forecast lead=6 interval=year id=year out=out; <br />run; <br />proc print data=out; <br />run;  </p><p>vcycyv: </p><p>1. nlag取24，在图上看是一个w型。 </p><p>2. 书上做identification步骤之后，得出结论：&#8220;观察输出结果。初步识别序列为 AR(3)模型。&#8221; 不确定这个结论是怎么得出来的，1. 怎么算截尾，怎么算拖尾？2. AR（3）里那个3是怎么出来的？对第二个问题瞎猜一下，是看ACF图观察出来三个值能推出来第四个值么？ </p><p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/SeriesCorrPanel_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SeriesCorrPanel" border="0" alt="SeriesCorrPanel" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/eb155942bb65_8972/SeriesCorrPanel_thumb.png" width="448" height="337" /><br /><br /></a>问了学统计的同事，解答了上面两个问题，还是需要继续理解：<br /><div><span style="font-size:10.0pt;font-family: 宋体;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black;">截尾：是指在</span><span style="font-size:10.0pt; font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black;">ACF</span><span style="font-size:10.0pt;font-family:宋体;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black;">或</span><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black;">PACF</span><span style="font-size:10.0pt;font-family:宋体;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black;">图中自相关系数和偏自相关系数在滞后的前几期内处于置信区间之外，而滞后的系数基本上都落入置信区间内，且逐渐趋于</span><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black;">0.<br /> </span><span style="font-size:10.0pt;font-family:宋体;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;; color:black;">拖尾：是指在</span><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black;">ACF</span><span style="font-size: 10.0pt;font-family:宋体;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black;">或</span><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black;">PACF</span><span style="font-size:10.0pt;font-family:宋体;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black;">图中自相关系数和偏自相关系数有指数型、正弦型或震荡型衰减的波动。且都不会落入置信区间内。<br />至于那个3，</span><span style="font-size:10.0pt;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black">因为</span><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black">PACF</span><span style="font-size:10.0pt;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black">图上可以看出当为</span><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black">3</span><span style="font-size:10.0pt;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black">时，不在置信区间内</span></div><div>  <p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:10.0pt;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black">就是那时开始不在蓝框内了</span></p>  <p style="margin:0cm;margin-bottom:.0001pt"><span style="font-size:10.0pt;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black">并且</span><span style="font-size:10.0pt;font-family:&quot;Segoe UI&quot;,&quot;sans-serif&quot;;color:black">ACF</span><span style="font-size:10.0pt;Segoe UI&quot;;Segoe UI&quot;;Segoe UI&quot;;color:black">图此时为拖尾</span></p></div></p><p>参考： </p><p><a href="http://wiki.mbalib.com/wiki/%E6%97%B6%E9%97%B4%E5%BA%8F%E5%88%97%E9%A2%84%E6%B5%8B%E6%B3%95">http://wiki.mbalib.com/wiki/%E6%97%B6%E9%97%B4%E5%BA%8F%E5%88%97%E9%A2%84%E6%B5%8B%E6%B3%95</a> </p><p><a href="http://wiki.mbalib.com/wiki/%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E6%B3%95">http://wiki.mbalib.com/wiki/%E7%A7%BB%E5%8A%A8%E5%B9%B3%E5%9D%87%E6%B3%95</a> </p><p><a href="http://wiki.mbalib.com/wiki/%E6%8C%87%E6%95%B0%E5%B9%B3%E6%BB%91%E6%B3%95">http://wiki.mbalib.com/wiki/%E6%8C%87%E6%95%B0%E5%B9%B3%E6%BB%91%E6%B3%95</a> </p><p><a href="http://zh.wikipedia.org/wiki/%E6%97%B6%E9%97%B4%E5%BA%8F%E5%88%97">http://zh.wikipedia.org/wiki/%E6%97%B6%E9%97%B4%E5%BA%8F%E5%88%97</a> </p><p><a href="http://zh.wikipedia.org/wiki/%E8%87%AA%E7%9B%B8%E5%85%B3%E5%87%BD%E6%95%B0">http://zh.wikipedia.org/wiki/%E8%87%AA%E7%9B%B8%E5%85%B3%E5%87%BD%E6%95%B0</a> </p><p><a href="http://wiki.mbalib.com/wiki/ARIMA%E6%A8%A1%E5%9E%8B">http://wiki.mbalib.com/wiki/ARIMA%E6%A8%A1%E5%9E%8B</a> </p><p><a href="http://www.docin.com/p-46241714.html">http://www.docin.com/p-46241714.html</a> </p><p>SAS help  </p><img src ="http://www.blogjava.net/vcycyv/aggbug/358155.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-09-07 09:44 <a href="http://www.blogjava.net/vcycyv/archive/2011/09/07/358155.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>分享读书笔记 Data Mining Concepts and Techniques</title><link>http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Mon, 05 Sep 2011 00:40:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/357967.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/357967.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/357967.html</trackback:ping><description><![CDATA[<p>Data Mining涵盖的内容非常多，学着学着就走进乱石阵，看不到大的picture了，Data Mining Concepts and Techniques是本经典的好书，虽然有些细节并不详尽，（如果详尽就变成圣经了）可以用它来把data mining的知识点结成一张网。它包括数据的预处理，frequent patterns,decision tree, netural network, regression, clustering, time series等等很多方面。用XMind做了读书笔记，XMind是思维导图软件， 在之前的博客中略有介绍： <a href="http://www.blogjava.net/vcycyv/archive/2011/03/18/346513.html"><font color="#0000ff">工作中用到的一些免费软件</font></a> 先上一个缩略图，</p> <p><a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/DataMiningConceptsandTechniques_7A6B/image_2.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/DataMiningConceptsandTechniques_7A6B/image_thumb.png" width="945" height="538"></a> </p> <p>这本书可以在这里找到：</p> <p><a title="http://storage.live.com/items/D8B11F9BF86FECFA!1358" href="http://storage.live.com/items/D8B11F9BF86FECFA!1358">http://storage.live.com/items/D8B11F9BF86FECFA!1358</a> （下载之后把文件后缀名改成.pdf即可， skydrive换成html5之后，外链很不方便！）</p> <p>&nbsp;</p> <p>笔记可以在这里找到：</p> <p><a title="http://storage.live.com/items/D8B11F9BF86FECFA!1374" href="http://storage.live.com/items/D8B11F9BF86FECFA!1374">http://storage.live.com/items/D8B11F9BF86FECFA!1374</a> （下载之后把文件后缀名改成.xmind即可，用XMind软件打开，软件可以在这里下载：<a href="http://www.xmind.net/">http://www.xmind.net/</a>）</p><img src ="http://www.blogjava.net/vcycyv/aggbug/357967.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-09-05 08:40 <a href="http://www.blogjava.net/vcycyv/archive/2011/09/05/357967.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Basel2模型验证二：Kendall tau</title><link>http://www.blogjava.net/vcycyv/archive/2011/08/28/357440.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Sun, 28 Aug 2011 07:11:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/08/28/357440.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/357440.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/08/28/357440.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/357440.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/357440.html</trackback:ping><description><![CDATA[<p>Kendall tau是用来度量关联关系的。</p> <p>(引自wikipedia:<a title="http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficient" href="http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficient">http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficient</a>)</p> <p>==============================================</p> <p>Let (<i>x</i><sub>1</sub>, <i>y</i><sub>1</sub>), (<i>x</i><sub>2</sub>, <i>y</i><sub>2</sub>), …, (<i>x</i><sub><i>n</i></sub>, <i>y</i><sub><i>n</i></sub>) be a set of joint observations from two random variables <i>X</i> and <i>Y</i> respectively, such that all the values of (<i>x</i><sub><i>i</i></sub>) and (<i>y</i><sub><i>i</i></sub>) are unique. Any pair of observations (<i>x</i><sub><i>i</i></sub>, <i>y</i><sub><i>i</i></sub>) and (<i>x</i><sub><i>j</i></sub>, <i>y</i><sub><i>j</i></sub>) are said to be <i>concordant</i> if the ranks for both elements agree: that is, if both <i>x</i><sub><i>i</i></sub> &gt; <i>x</i><sub><i>j</i></sub> and <i>y</i><sub><i>i</i></sub> &gt; <i>y</i><sub><i>j</i></sub> or if both <i>x</i><sub><i>i</i></sub> &lt; <i>x</i><sub><i>j</i></sub> and <i>y</i><sub><i>i</i></sub> &lt; <i>y</i><sub><i>j</i></sub>. They are said to be <i>discordant</i>, if <i>x</i><sub><i>i</i></sub> &gt; <i>x</i><sub><i>j</i></sub> and <i>y</i><sub><i>i</i></sub> &lt; <i>y</i><sub><i>j</i></sub> or if <i>x</i><sub><i>i</i></sub> &lt; <i>x</i><sub><i>j</i></sub> and <i>y</i><sub><i>i</i></sub> &gt; <i>y</i><sub><i>j</i></sub>. If <i>x</i><sub><i>i</i></sub> = <i>x</i><sub><i>j</i></sub> or <i>y</i><sub><i>i</i></sub> = <i>y</i><sub><i>j</i></sub>, the pair is neither concordant nor discordant. <p>The Kendall τ coefficient is defined as: <dl> <dd><img alt="\tau = \frac{(\text{number of concordant pairs}) - (\text{number of discordant pairs})}{\frac{1}{2} n (n-1) } ." src="http://upload.wikimedia.org/math/4/4/4/444a10977baf56039a0e3fe8a62e355a.png"></dd></dl> <p><sup>=========================================================</sup></p> <p>同一篇文章继续引用关于ties:</p> <p><sup>=========================================================</sup></p> <p>A pair {(<i>x</i><sub><i>i</i></sub>, <i>y</i><sub><i>i</i></sub>), (<i>x</i><sub><i>j</i></sub>, <i>y</i><sub><i>j</i></sub>)} is said to be <i>tied</i> if <i>x</i><sub><i>i</i></sub> = <i>x</i><sub><i>j</i></sub> or <i>y</i><sub><i>i</i></sub> = <i>y</i><sub><i>j</i></sub>; a tied pair is neither concordant nor discordant. When tied pairs arise in the data, the coefficient may be modified in a number of ways to keep it in the range [-1, 1]: <p>Tau-b statistic, unlike tau-a, makes adjustments for ties and is suitable for <a href="http://en.wikipedia.org/w/index.php?title=Square_table&amp;action=edit&amp;redlink=1">square tables</a>. Values of tau-b range from −1 (100% negative association, or perfect inversion) to +1 (100% positive association, or perfect agreement). A value of zero indicates the absence of association. <p>The Kendall tau-b coefficient is defined as: <dl> <dd><img alt="\tau_B = \frac{n_c-n_d}{\sqrt{(n_0-n_1)(n_0-n_2)}}" src="http://upload.wikimedia.org/math/3/a/9/3a934fa9f450d662f1c6af0b5e1bffb1.png"></dd></dl> <p>where <dl> <dd><img alt="\begin{array}{ccl}
n_0 &amp; = &amp; n(n-1)/2\\
n_1 &amp; = &amp; \sum_i t_i (t_i-1)/2 \\
n_2 &amp; = &amp; \sum_j u_j (u_j-1)/2 \\
t_i &amp; = &amp; \mbox{Number of tied values in the } i^{th} \mbox{ group of ties for the first quantity} \\
u_j &amp; = &amp; \mbox{Number of tied values in the } j^{th} \mbox{ group of ties for the second quantity}
\end{array}
" src="http://upload.wikimedia.org/math/5/d/9/5d9b761126863a985440b7865c9b0f48.png"></dd></dl> <p></p> <p>================================================</p> <p>靠，搞了半天才理解，上面公式中所谓n<font size="1">c, <font size="3">n</font>d</font><font size="3">里面的c和d，指的是concordant和discordant.</font></p> <p><font size="3">在sas中计算Kendall tau-2比较简单，直接用proc freq就行，原来proc freq如此强大啊。</font></p> <p><font size="3">sas程序举例：</font></p> <p>data color;<br>&nbsp;&nbsp; input Region Eyes $ Hair $ Count @@;<br>&nbsp;&nbsp; label Eyes&nbsp; ='Eye Color'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hair&nbsp; ='Hair Color'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Region='Geographic Region';<br>&nbsp;&nbsp; datalines;<br>1 blue&nbsp; fair&nbsp;&nbsp; 23&nbsp; 1 blue&nbsp; red&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp; 1 blue&nbsp; medium 24<br>1 blue&nbsp; dark&nbsp;&nbsp; 11&nbsp; 1 green fair&nbsp;&nbsp; 19&nbsp; 1 green red&nbsp;&nbsp;&nbsp;&nbsp; 7<br>1 green medium 18&nbsp; 1 green dark&nbsp;&nbsp; 14&nbsp; 1 brown fair&nbsp;&nbsp; 34<br>1 brown red&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp; 1 brown medium 41&nbsp; 1 brown dark&nbsp;&nbsp; 40 <br>1 brown black&nbsp;&nbsp; 3&nbsp; 2 blue&nbsp; fair&nbsp;&nbsp; 46&nbsp; 2 blue&nbsp; red&nbsp;&nbsp;&nbsp; 21<br>2 blue&nbsp; medium 44&nbsp; 2 blue&nbsp; dark&nbsp;&nbsp; 40&nbsp; 2 blue&nbsp; black&nbsp;&nbsp; 6<br>2 green fair&nbsp;&nbsp; 50&nbsp; 2 green red&nbsp;&nbsp;&nbsp; 31&nbsp; 2 green medium 37<br>2 green dark&nbsp;&nbsp; 23&nbsp; 2 brown fair&nbsp;&nbsp; 56&nbsp; 2 brown red&nbsp;&nbsp;&nbsp; 42<br>2 brown medium 53&nbsp; 2 brown dark&nbsp;&nbsp; 54&nbsp; 2 brown black&nbsp; 13<br>;  <p>proc freq data = color noprint ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>tables&nbsp; eyes*hair / measures&nbsp; noprint ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>weight count;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>output out=output KENTB;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>test KENTB;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>run;  <p>&nbsp;</p> <p><font size="3">另外跟Kendall tau有点儿关联的是Somer’s D，但是搜索了一下没看到公式，反正Somer’s D也可以用sas proc freq直接算，方法类似。</font></p> <p>Somers' <i>D</i>(<i>C</i>|<i>R</i>) and Somers' <i>D</i>(<i>R</i>|<i>C</i>) are asymmetric modifications of tau-<i>b</i>.Somers' <i>D</i> differs from tau-<i>b</i> in that it uses a correction only for pairs that are tied on the independent variable.</p><img src ="http://www.blogjava.net/vcycyv/aggbug/357440.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-08-28 15:11 <a href="http://www.blogjava.net/vcycyv/archive/2011/08/28/357440.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Basel2模型验证一：Hosmer&amp;ndash;Lemeshow test</title><link>http://www.blogjava.net/vcycyv/archive/2011/08/21/356974.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Sat, 20 Aug 2011 23:37:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/08/21/356974.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/356974.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/08/21/356974.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/356974.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/356974.html</trackback:ping><description><![CDATA[<p>一，基础概念：</p> <p>Probability of default(PD)：PD是巴塞尔协议中一个重要的参数，它用来计算某个客户或某批具有相似特征的客户贷款不还的概率。</p> <p>&nbsp;</p> <p>Hosmer&#8211;Lemeshow test：PD中众多统计检验的其中一种，评估预测值与实际值在各个分组（subgroup, pool, bin）中拟合程度。</p> <p>&nbsp;</p> <p>自由度：自由度是指随机变量中所含独立随机变量的个数<i>n</i>．如果这些独立随机变量受到<i>k</i>个约束条件的限制，那么自由度就变为<i>n-k</i>．</p> <p>&nbsp;</p> <p>概率密度函数：是一个描述这个随机变量的输出值在某一个确定的取值点附近的可能性的函数。</p> <p>&nbsp;</p> <p>卡方（<i>&#967;</i><sup>2</sup>）分布：</p> <p>设<i>X</i><sub>1</sub>, <i>X</i><sub>2</sub>,&#8230;,<i>X</i><sub><i>n</i></sub>是相互独立的随机变量且均服从标准正态分布<i>N</i>(0，1)，则随机变量  <p><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#967;</i><sup>2</sup>=<i> X</i><sub>1</sub><sup>2</sup>+<i>X</i><sub>2</sub><sup>2</sup>+&#8230;+<i>X</i><sub><i>n</i></sub>  <p>的分布称为服从自由度为<i>n</i>的<b><i>&#967;</i><sup>2</sup>分布</b>，记为<i>&#967;</i><sup>2</sup>～<i>&#967;</i><sup>2</sup>(<i>n</i>)  <p>卡方分布的密度函数图为：  <p>&nbsp;<a href="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/Basel2HosmerLemeshowtest_5DE7/kafang_desity_2.gif"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="kafang_desity" border="0" alt="kafang_desity" src="http://www.blogjava.net/images/blogjava_net/vcycyv/WindowsLiveWriter/Basel2HosmerLemeshowtest_5DE7/kafang_desity_thumb.gif" width="368" height="238"></a>  <p>&nbsp;</p> <p>二， Hosmer&#8211;Lemeshow test的使用方法</p> <p>Hosmer&#8211;Lemeshow test 的统计量是: <dl> <dd><img alt=" H = \sum_{g=1}^{n} \frac{(O_g - E_g)^2}{N_g \pi_g (1-\pi_g)} .\,\!" src="http://upload.wikimedia.org/math/9/d/9/9d991d3b1d7da4a6c87447f72aabaeb6.png"></dd></dl> <p>这里 <i>O<sub>g</sub></i>, <i>E<sub>g</sub></i>, <i>N<sub>g</sub></i>, and <i>&#960;<sub>g</sub></i> 示观察到的事件，预期的事件，观察数, 预测的第<i>g</i><sup>th</sup>组的风险（在PD模型中，）， <em>n</em>是组数. 这个统计量符合自由度为n-2或n的卡方分布。 <p></p> <p>其他统计量都很直白，解释一下<i>E<sub>g</sub></i>的计算：实际应用中，可以用当前分组的违约概率 x 当前分组的观测值数目。</p> <p>有了统计量的值之后，下一步计算就要依靠&#8220;这个统计量符合自由度为n-2或n的卡方分布&#8221;了。那么什么时候用自由度为n，什么时候用自由度为n-2呢。在书Basel2 risk parameters里有这样一段解释在321页。这本书可以在我的skydrive里找到<a href="https://skydrive.live.com/?cid=D8B11F9BF86FECFA&amp;id=D8B11F9BF86FECFA%211346&amp;sc=documents#">https://skydrive.live.com/?cid=D8B11F9BF86FECFA&amp;id=D8B11F9BF86FECFA%211346&amp;sc=documents#</a>：</p> <p>&#8220;When using the HSLS statistic as a measure of fit in the process of model finding, then <br>we say &#8220;in-sample&#8221;, because the model estimation sample and the sample on which the <br>measure of fit is computed are identically. In this case the distribution is F2 with G  2 <br>degrees&nbsp; of&nbsp; freedom.&nbsp; When&nbsp; using&nbsp; the&nbsp; HSLS&nbsp; statistic&nbsp; for&nbsp; backtesting,&nbsp; we&nbsp; say&nbsp; &#8220;out-of-<br>sample&#8221;,&nbsp; because&nbsp; there&nbsp; is&nbsp; no&nbsp; observation&nbsp; coexistent&nbsp; in&nbsp; the&nbsp; estimation&nbsp; sample&nbsp; and&nbsp; the <br>validation sample. &#8221; <p>如果理解没错的话，在建模验证阶段，自由度是n-2, 模型建好之后，自由度都是n。 <p>卡方检验P值的计算方式是1 - 特定自由度下卡方的的CDF，详见wikipedia：<a title="http://en.wikipedia.org/wiki/Chi-square_distribution" href="http://en.wikipedia.org/wiki/Chi-square_distribution">http://en.wikipedia.org/wiki/Chi-square_distribution</a>中Table of <i>&#967;</i><sup>2</sup> value vs P value部分</p> <p>CDF指的是Cumulative distribution function，就是分布函数，详见wikipedia: <a title="http://en.wikipedia.org/wiki/Cumulative_distribution_function" href="http://en.wikipedia.org/wiki/Cumulative_distribution_function">http://en.wikipedia.org/wiki/Cumulative_distribution_function</a></p></p>  <img src ="http://www.blogjava.net/vcycyv/aggbug/356974.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-08-21 07:37 <a href="http://www.blogjava.net/vcycyv/archive/2011/08/21/356974.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>敏捷不能当饭吃</title><link>http://www.blogjava.net/vcycyv/archive/2011/07/18/354498.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Mon, 18 Jul 2011 00:00:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/07/18/354498.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/354498.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/07/18/354498.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/354498.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/354498.html</trackback:ping><description><![CDATA[<p>喜欢敏捷的很多想法，喜欢它务实的态度。我说“敏捷不能当饭吃”，当然不是说敏捷无用，相反，我倒是挺推崇敏捷的。之前有两篇文字都涉及到一些对敏捷的看法。一篇是 <a href="http://www.blogjava.net/vcycyv/archive/2011/01/30/343784.html"><font color="#0000ff">与神对话</font></a>，另一篇是 <a href="http://www.blogjava.net/vcycyv/archive/2011/01/30/343787.html"><font color="#0000ff">对敏捷的一些想法</font></a>。只是看到很多人好像敏捷是他爷爷写的一样，龟孙子似地迷信和追捧敏捷，把工作一条一条跟书上描述的对照，一旦工作中实际操作跟书上有不一致，口诛笔伐，吐沫拳头无影腿就一齐上来了，那就太过了。敏捷跟太极拳一样，是一种思想精髓，它的一招一式体现在实际工作中灵活运用敏捷原则，敏捷并无特定套路。Scrum等流程是敏捷的一种成功案例，这个案例在特定环境下工作得非常好，但那只是特定环境而已。敏捷大师们自己也总提醒，很多项目采用敏捷开发，仍然一塌糊涂，是因为应用敏捷并不简单。 <p>Kent Beck是敏捷的发起者之一，很多敏捷的发起者后来都写了关于敏捷的书，但Kent Beck的书是最有影响力的，它的Extreme programming explained – embrace change可以在<a href="http://www.blogjava.net/vcycyv/archive/2011/02/14/344298.html"><font color="#0000ff">这篇博客</font></a>中找到。这本书主要阐述敏捷的一系列理念，对实践描述的并不具体。scrum之类讲敏捷流程的书，对实践操作的环节就会讲的很具体。<strong>先了解并接受敏捷的理念，再去看敏捷流程的话，比较容易理解流程背后的用意是什么</strong>，只有深刻理解了敏捷精神，才能比较好的实践敏捷。而现实情况很多时候不是这样，直接学习流程总是比较省事儿，于是scrum就被当成圣经直接拿来就用了，人家mc hotdog早就说过，“照单全收的盲从，就像在吃屎”。我相信通常情况下，scrum的实践在一个项目组，只有一小部分能用得上，当然，这已经是件很伟大的事情了。在一些常见的工作环境中，有些scrum的想法并不适用。 <p>一个方面是，scrum强调“全功能团队”，每个人了解产品的每一个feature；团队人数在敏捷中是有限制的。但如果一个负责某个产品的团队就是有12，3个人，那么怎么办？ 再拆成两个敏捷团队以适应敏捷对人数的要求？垂直划分feature提供了细化团队的机会，但产品不总能清晰地一刀切成两半，尤其还要考虑各个程序员有不同的专长，甚至根本用的不是同一种编程语言，如果团队只有一个c程序员，一个js程序员，一个pl/sql程序员，其他做java，那么切分项目组的方式是跟c有关的一组，跟js有关的另一组？底层架构和公共模块都不容易竖切。如果产品比较大并且不易细分，大家都了解每个feature是很难做到的。如果产品使用的技术比较繁杂，pl/sql, js, java, c样样都用，全功能团队怎么实现？js的程序员跟c程序员也讲不到一块儿去啊。我可以理解scrum的想法，也认同它的道理，但是在实际工作中，如果确实人数对不上敏捷的要求，或者程序员的技术特长分散在不同层面，这很难照搬scrum的实践。人多开会费时间，效果又不好，鸡同鸭讲，各说各的。写c的人才不关心js有什么技术瓶颈呢。 <p>还有，scrum想了个招儿，用打扑克的方式沟通需求和帮助定schedule。这是建立在全功能团队的基础上的，上面已经论述过了，如果产品比较大，程序员没法兼顾所有story，那成本太大了，打扑克也只能流于形式，尤其术业有专攻，唯一的c程序员的工作只有他自己估计才有意义。更实际的问题是，当你知道story具体需求的时候，还不足以估计出时间，程序员必须知道“怎么做”才能估出来比较靠谱的时间。<strong>很多时候需要做一些research的工作以及一点儿prototype才好估时间</strong>，在这样的情况下，你非逼我出张牌，我只能出“问号”。 有时候，虽然我不需要做prototype, 但我确实也不能在5分钟之内理清思路, 知道用什么approach更合理，那么我怎么办，告诉大家容我想想，等我一会儿？技术问题本来也不应该规定在5分钟之内出个计划，非逼我出计划倒也没问题，但是随后我就得重做计划。还有一个问题，大家一起打牌，A知道这工作十有八九落在B头上，A可能出于好心多估时间，B可能为了面子少估时间，这些人为因素如何排除掉？ <p>敏捷强调单元测试，这肯定是没错的。问题是，各个团队之间容易开始攀比覆盖率，其实程序员心里都明白，<strong>覆盖率的欺骗性很强，单元测试的有效性更重要</strong>。如果单元测试又没贡献于驱动开发，也没贡献于质量保证（简单的api，诸如getter/setter之类的api就是这样，不用测试驱动直接就知道怎么写了，写了手动测试一遍就知道写的没错，code以后也不可能改），那么就没必要写这种单元测试，写这种单元测试的唯一好处是，成本低，比较容易贡献覆盖率。麻烦在于，太多弱智这么说，咱们敏捷了，单元测试覆盖率应该向某某弱智team看齐，于是人在江湖，身不由己，开始对付覆盖率。好吧，scrum其实也没说具体百分比，这不是scrum的错。 <p>我绝对不想抨击敏捷或者scrum，我觉得这都是很出色的想法。只是听了太多“这不是敏捷”这种话，<strong>是不是敏捷根本不重要，能优化流程，让工作更有效才重要</strong>。我喜欢敏捷的地方在于，敏捷强调以人为本，尊重程序员的各种诉求。正视design不能一蹴而就的现实。承认长期计划不靠谱。强调优先级，决定优先级的时候从性价比的角度考虑。scrum的很多实践也很实用，比如backlog应该包含的内容等等不一一罗列。敏捷不是一门玄奥难懂的技术，不需要花钱找培训机构受教育。敏捷的出发点就是务实，用务实的态度拥抱敏捷就足够好。套用二八原则，scrum的实践在实际中也许只需要吸收20%，却能取得80%的效果，剩下那20%要靠基于敏捷精神的创造力。</p><img src ="http://www.blogjava.net/vcycyv/aggbug/354498.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-07-18 08:00 <a href="http://www.blogjava.net/vcycyv/archive/2011/07/18/354498.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>从此混迹商业智能 -- 像统计专业毕业的一样思考</title><link>http://www.blogjava.net/vcycyv/archive/2011/07/11/354073.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Mon, 11 Jul 2011 00:46:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/07/11/354073.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/354073.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/07/11/354073.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/354073.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/354073.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp; Java用来解决业务问题，实现商业价值。我们工作的过程，总会接触并接受一些领域知识。领域知识往往很复杂，有时真要学好一门领域知识比驾驭一种编程语言要花更多精力。这就是为什么业务专家总是身价很高，掌握领域知识的门槛本来就不低。深刻理解领域知识有利于设计并实现程序。这个道理很简单 —— 我们通过java抽象领域对象，如果没有对领域的深刻理解，怎么能分得清应该有哪些domain object，它们的behaviour应该是什么？写程序时尽量做简单又灵活的设计。“简单”和“灵活”本来就有一定程度的矛盾，不理解领域知识就没法预见潜在的扩展点，容易设计不足； 处处盲目预留各种各样的扩展点实际上就是过度设计。所以好的程序设计不光需要懂得分层, ooad，pattern, strategy, bo,vo,dto…还必然要基于对业务知识的深刻理解。Domain Driven Design的思想也非常强调程序员对领域知识的学习。一个不可回避的问题是，新学一门领域知识，很难一下把握清楚，1月份对某个概念有了一定理解，5月份时发现当初自以为理解清楚了，其实有偏差，那么这四个月里写的程序可能根本就基于错误的assumption, 很多设计和实现又要推倒重做。所以比较理想的情况是，程序员就专门深入研究某一个领域，从此就混迹这一个领域。表面上这样限制了程序员混饭吃的门路，实际上只有这样才有利于在技术上有更深层的修为。当然一些技术天才走的是另一条路，Rod Johnson，Gavin King他们能做出来影响深远的framework，万人景仰，那靠的是纯粹的对技术的深刻理解，还要耐得住性子strive for the goal把想法实现出来。有这种天赋的人去搞物理，生物，化学也能很成功，还能得诺贝尔奖呢。</p> <p>&nbsp;&nbsp;&nbsp; 那么接下来要要解决的问题是，怎么选择一个好的方向去学习领域知识。gartner之类的时常搞一些这方面的调研，比如十大有前景IT技术之类的。他们预测的未必准，但是读一读这方面的资料你自己也能感受到什么方向至少能长期混口饭吃。我直到最近才开始投入学习领域知识，商业智能是个很合适的方向。</p> <p>&nbsp;&nbsp;&nbsp; 商业智能就是Business Intelligence, 简称BI，只是这个缩写容易被当作关键词给过滤掉，所以这篇文字的标题仍然写全称。</p> <p>&nbsp;&nbsp;&nbsp; 信息爆炸会越来越严重，以后必然是数据的社会，BI可以从海量数据中获取价值，这会是一个相对常青的行业。更现实的是，我正好在做BI的公司工作，可以很方便地接触到相关软件，身边也有这方面的高手可以提供指导。看到人家如何分析问题，建立模型解决问题，就有种强烈的感觉：这才是能赚钱的本领。</p> <p>&nbsp;&nbsp;&nbsp; BI的基础是统计和数学分析，公司里不少人是学统计出身的，连CEO也是。咱程序员多数在学校里学的是计算机，这方面比不上统计专业的人， 算是先天不足。但是我简单地算了一下帐，发现这种不足不难后天补齐。如果初级目标是赶上统计专业的本科生，据推断，统计专业的人第一年不可能学上统计学，因为高等数学是统计学的基础，统计学中讲分布函数和分布密度需要用到微积分，极大似然函数也要用到微积分，所以计算机专业的和统计专业的第一年没啥差距。而我们在学校也学过统计课，那么我们和统计专业的差距主要集中在大二下学期之后的时间，大四通常没啥重要的课可以讲，咱们跟统计专业的也就差一年多的学习课程，这里还包括很大一部分马克思主义哲学之类无关的课，所以如果咱们勤奋一点，追齐统计专业的本科生只需要大约一年的时间，也许还可以更短。</p> <p>&nbsp;&nbsp;&nbsp; 大学学的微积分，线性代数和统计学早就还给老师了，首先要复习一下这方面的东西。前段时间刚复习完微积分，统计学和一半儿线性代数。分享一下资源：</p> <blockquote> <p>微积分之倚天剑 屠龙刀： <a title="http://ishare.iask.sina.com.cn/f/6933932.html" href="http://ishare.iask.sina.com.cn/f/6933932.html">http://ishare.iask.sina.com.cn/f/6933932.html</a></p> <p>线性代数和概率统计： <a title="http://202.113.29.3/~gdsxjxb/wlkj/windows/artsmath/main/index2.htm" href="http://202.113.29.3/~gdsxjxb/wlkj/windows/artsmath/main/index2.htm">http://202.113.29.3/~gdsxjxb/wlkj/windows/artsmath/main/index2.htm</a></p> <p>统计： <a title="http://ishare.iask.sina.com.cn/f/5773491.html" href="http://ishare.iask.sina.com.cn/f/5773491.html">http://ishare.iask.sina.com.cn/f/5773491.html</a></p></blockquote> <p>&nbsp;&nbsp;&nbsp; 接下来还要掌握data mining的过程和方法，这个可以沿着SAS的semma理论学习，sample, explore, modify, model, assess。每个方面都大有学问。还需要学会使用相关的工具，比如enterprise miner. 正在学习SAS编程。最后要跟定某个金钱无数的行业继续深入学习，比如银行业。</p> <p>&nbsp;&nbsp;&nbsp; 学这些不是为了转行抢业务专家的饭碗，那太难了，毕竟没有合适的环境。已经在Java上投入很多精力和时间，好不容易积累一些技术实力，Java仍然是闯荡江湖的一项资本，目标是做BI方面产品的架构师，遇到合适的位置，就无可替代。与各位同行共勉！</p><img src ="http://www.blogjava.net/vcycyv/aggbug/354073.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-07-11 08:46 <a href="http://www.blogjava.net/vcycyv/archive/2011/07/11/354073.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>信用卡与数据挖掘（转）</title><link>http://www.blogjava.net/vcycyv/archive/2011/06/07/351840.html</link><dc:creator>人在江湖</dc:creator><author>人在江湖</author><pubDate>Tue, 07 Jun 2011 01:25:00 GMT</pubDate><guid>http://www.blogjava.net/vcycyv/archive/2011/06/07/351840.html</guid><wfw:comment>http://www.blogjava.net/vcycyv/comments/351840.html</wfw:comment><comments>http://www.blogjava.net/vcycyv/archive/2011/06/07/351840.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/vcycyv/comments/commentRss/351840.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/vcycyv/services/trackbacks/351840.html</trackback:ping><description><![CDATA[<p>转载自<a title="http://www.bihuman.com/bbs/viewthread.php?tid=2584" href="http://www.bihuman.com/bbs/viewthread.php?tid=2584">http://www.bihuman.com/bbs/viewthread.php?tid=2584</a></p> <p>信用卡是指客户可以进行先透支消费，后还款的金融工具。目前国内许多使用信用卡的客户往往将储蓄卡和信用卡的含义相互混淆了，因此在信用卡公司的后台数据记录上往往会出现许多余额为负的客户（余额为正说明是有欠款），而这种情况在国外几乎是不可能的。 　　信用卡公司一般来说是通过循环透支产生的利息和特约商户的折扣来获得收益。这也就是说，一个消费金额多但是每月都按时还款的客户对信用卡公司来说往往不一定是一个“好”的客户，真正“好”客户是那些持续使用循环透支并产生利息收益的客户。由于信用卡公司的“先消费，后还款”特点，卡公司一般都是风险厌恶型的企业，客户每欠款1块钱，则卡公司就会产生1块钱的风险暴露。因此，信用卡公司的目的往往是希望在保持一个可接受的整体资产损失的前提下，寻找更多的优质客户，创造更多的实际收益。每个信用卡公司的风险管控策略往往是不一样的，像招商银行在信审方面比较宽松，授信额度也较高，但是它在催收方面的力度较大；而类似广发银行在信审方面比较严格，而在催收方面则显出较好的耐心，表现出比较稳健的作风。 <br>　　在了解信用卡公司的经营状况之后，接下来谈谈信用卡公司涉及的数据挖掘模型。一个新客户与信用卡公司建立起客户关系的流程大约是这样的： <br>　　申请-〉审核-〉发卡-〉交易-〉出账-〉还款-〉催收-〉核销-〉被动（主动）流失 <br>　　相对应的，在申请到发卡这个阶段可以建立起“申请评分”模型，这也是最为常见的信用卡模型。在构造申请评分模型过程中，往往会遇到“拒绝推断”的问题，解决问题的方法是多样的，与信用卡公司的风险策略往往是紧密联系在一起的。 <br>　　在客户交易阶段，可以建立“客户分群模型”对客户进行细分；建立“关联分析”模型来分析客户在产品消费方面的关联规则；建立“客户消费模型”来对客户在将来的一个时间内的消费金额进行预测，从而设计相关的额度调整、利率调整策略。 <br>　　在出账到催收阶段，可以建立起“拖欠模型”来预测客户在将来的拖欠概率；建立“催收模型”预测客户的还款概率；建立“收益分析模型”对公司的整体收益情况进行评估。 <br>　　在最后的部分，也就是说客户关系走向衰亡的阶段，可以建立“客户流失模型”预测客户流失的概率；建立“欺诈模型”找出客户欺诈的行为模式；建立“违约的风险暴露”分析模型，分析在由于风险暴露对卡公司造成的损失。</p><img src ="http://www.blogjava.net/vcycyv/aggbug/351840.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/vcycyv/" target="_blank">人在江湖</a> 2011-06-07 09:25 <a href="http://www.blogjava.net/vcycyv/archive/2011/06/07/351840.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>