@@ -2118,9 +2118,23 @@ Module stats
2118
2118
''' kurtosis_manual <- sum((data - mean_data)^4) / ((n - 1) * sd_data^4) - 3;
2119
2119
''' print(kurtosis_manual);
2120
2120
''' </example>
2121
+ ''' <remarks>
2122
+ ''' If x contains missings and these are not removed, the kurtosis is NA.
2123
+ '''
2124
+ ''' Otherwise, write xi for the non-missing elements of x, n for their number, μ for their mean, s for their standard deviation, and
2125
+ ''' mr = ∑i (xi −μ) ^ r /n for the sample moments of order r.
2126
+ '''
2127
+ ''' Joanes and Gill (1998) discuss three methods for estimating kurtosis:
2128
+ '''
2129
+ ''' Type 1: g2 = m4/m2 ^ 2 −3. This is the typical definition used in many older textbooks.
2130
+ ''' Type 2: G2 = ((n+1)*g2 +6)∗(n−1)/((n−2)(n−3)). Used in SAS and SPSS.
2131
+ ''' Type 3: b2 = m4 /s ^ 4 −3 = (g2 +3)(1−1/n) ^ 2 −3. Used in MINITAB and BMDP.
2132
+ '''
2133
+ ''' Only G2 (corresponding to type = 2) is unbiased under normality.
2134
+ ''' </remarks>
2121
2135
<ExportAPI( "kurtosis" )>
2122
- Public Function kurtosis(<RRawVectorArgument> x As Object ) As Object
2123
- Return CLRVector.asNumeric(x).Kurtosis
2136
+ Public Function kurtosis(<RRawVectorArgument> x As Object , Optional type As AlgorithmType = AlgorithmType.Classical ) As Object
2137
+ Return CLRVector.asNumeric(x).Kurtosis(type)
2124
2138
End Function
2125
2139
2126
2140
''' <summary>
@@ -2180,9 +2194,22 @@ Module stats
2180
2194
''' skewness_manual <- sum((data - mean_data)^3) / ((n - 1) * sd_data^3);
2181
2195
''' print(skewness_manual);
2182
2196
''' </example>
2197
+ ''' <remarks>
2198
+ ''' If x contains missings and these are not removed, the skewness is NA.
2199
+ ''' Otherwise, write xi for the non-missing elements of x, n for their number, μ for their mean, s for their standard deviation, and
2200
+ ''' mr =∑i (xi −μ) ^ r /n for the sample moments of order r.
2201
+ '''
2202
+ ''' Joanes and Gill (1998) discuss three methods for estimating skewness:
2203
+ '''
2204
+ ''' Type 1: g1 = m3 / m2 ^ (3/2). This is the typical definition used in many older textbooks.
2205
+ ''' Type 2: G1 = g1 * sqrt(n(n−1)) /(n−2). Used in SAS and SPSS.
2206
+ ''' Type 3: b1 = m3 /s^3 = g1 * ((n−1)/n) ^ (3/2) . Used in MINITAB and BMDP.
2207
+ '''
2208
+ ''' All three skewness measures are unbiased under normality.
2209
+ ''' </remarks>
2183
2210
<ExportAPI( "skewness" )>
2184
- Public Function skewness(<RRawVectorArgument> x As Object ) As Object
2185
- Return CLRVector.asNumeric(x).Skewness
2211
+ Public Function skewness(<RRawVectorArgument> x As Object , Optional type As AlgorithmType = AlgorithmType.Classical ) As Object
2212
+ Return CLRVector.asNumeric(x).Skewness(type)
2186
2213
End Function
2187
2214
2188
2215
''' <summary>
0 commit comments