1. ## Skew (w2k)

I could use some help with calculating a skew. I looked in help and it has the following:

SKEW(number1,number2...)
Number 1, Number 2,...are 1 to 30 numbers or references that contain number for which you want the skewness.

As easy as it sounds, I must not understand it because I could not get it to work. Can someone translate this for me? I may have taken this definition too literally.

Thanks.

2. ## Re: Skew (w2k)

Just like the Correlation Coefficient you asked about in November, SKEW is an Excel worksheet function. It is not part of Access.

You could use it in Access by creating an Excel application object, but that may be overkill. If you really need it, you could write a user-defined function in VBA, or someone may be willing to write it for you if you ask nicely ...

3. ## Re: Skew (w2k)

OK. Thank you for your response...

I am asking nicely. Can someone write a user-defined function in VBA for SKEW?

Thanks.

4. ## Re: Skew (w2k)

What does SKEW do?
Pat

5. ## Re: Skew (w2k)

Skew indicates the level of symmetry or lack there of.

6. ## Re: Skew (w2k)

Well, since you ask so nicely ... <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Here is a function that calculates the sample skewness of a field in a recordset (existing table or query) with an optional where-condition imposed. If the field name or recordset name includes spaces, enclose them in square brackets [ ]. Examples of usage:
=Skew("Price","tblCars")
=Skew("Price","tblCars","Brand='Ford'")
This function is the equivalent of the Excel worksheet function SKEW. If you want the population skewness, use DStDevP instead of DStdDev, and omit the line
Skew = Skew * (lngCount ^ 2) / ((lngCount - 1) * (lngCount - 2))

<img src=/w3timages/blueline.gif width=33% height=2>

Public Function Skew _
(sField As String, _
sRecordSet As String, _
Optional sCondition As String) As Double

Dim dblAvgOfField As Double
Dim dblAvgOfSquare As Double
Dim dblAvgOfThirdPower As Double
Dim dblStDev As Double
Dim lngCount As Long

On Error GoTo Err_Skew
lngCount = DCount(sField, sRecordSet, sCondition)
dblAvgOfField = DAvg(sField, sRecordSet, sCondition)
dblAvgOfSquare = DAvg(sField & "^2", sRecordSet, sCondition)
dblAvgOfThirdPower = DAvg(sField & "^3", sRecordSet, sCondition)
dblStDev = DStDev(sField, sRecordSet, sCondition)
Skew = (dblAvgOfThirdPower - 3 * dblAvgOfSquare * dblAvgOfField + 2 * dblAvgOfField ^ 3) / (dblStDev ^ 3)
Skew = Skew * (lngCount ^ 2) / ((lngCount - 1) * (lngCount - 2))
Exit Function

Err_Skew:
Skew = 0
End Function

<img src=/w3timages/blueline.gif width=33% height=2>

Notes:
<UL><LI>For large recordsets, this function will be slow, because the domain functions DAvg etc. are slow.
<LI>I have tested this function on small sample data sets, but I can't guarantee that it will return correct results under all circumstances. Make sure to test it before relying on it.
<LI>Access has some basic statistical functions built in, but it is not a statistics program. Excel has many more statistical functions; it wouldn't be sensible to try and emulate them all in Access. It's often easier to import the data into Excel and use the built-in features.
If you need to perform complex statistical analysis often, I would recommend using a dedicated statistics application such as SPSS, SAS or SPlus. You can import data from Access into, say, SPSS and do much more than is possible in Access or Excel.[/list]

7. ## Re: Skew (w2k)

Hans,

Thank you so much!!

I will also check into SPSS, SAS and SPlus and see if it will fit our needs.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•