Skip to content

Commit 13c7ab1

Browse files
committed
implements of the different algorithm type
1 parent 3224442 commit 13c7ab1

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

Library/Rlapack/stats.vb

+31-4
Original file line numberDiff line numberDiff line change
@@ -2118,9 +2118,23 @@ Module stats
21182118
''' kurtosis_manual <- sum((data - mean_data)^4) / ((n - 1) * sd_data^4) - 3;
21192119
''' print(kurtosis_manual);
21202120
''' </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>
21212135
<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)
21242138
End Function
21252139

21262140
''' <summary>
@@ -2180,9 +2194,22 @@ Module stats
21802194
''' skewness_manual &lt;- sum((data - mean_data)^3) / ((n - 1) * sd_data^3);
21812195
''' print(skewness_manual);
21822196
''' </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>
21832210
<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)
21862213
End Function
21872214

21882215
''' <summary>

0 commit comments

Comments
 (0)