[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

# Re: st: RE: RE: rowskew?

 From jeheyman To statalist@hsphsun2.harvard.edu Subject Re: st: RE: RE: rowskew? Date Wed, 15 Oct 2008 07:31:56 -0500

```Thanks for both ideas.

```
My flubbing the first way is what led to my first posting as I was trying to calculate skew and kurtosis without losing the 12 other calculations in the model.
```
```
I had thought of the moments approach but convinced myself that there must be a way to do it directly using Stata commands. As such, I turned a 20 minute project into a 6 hour head-banger.
```
Thanks much.

jh.

On Oct 14, 2008, at 2:11 AM, Martin Weiss wrote:

```
```Would it also be possible to -xpose,clear- and then to calculate the
```
skewness and kurtosis for the former rows, now columns with - summarize-?
```Admittedly a little quick and dirty...

HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
```
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Matt Spittal
```Sent: Tuesday, October 14, 2008 5:22 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: rowskew?

jeheyman,

```
You can use the moments about the mean to calculate skew and kurtosis for a
```row of variables.  Imagine that you want to do this for the variables
weight, length and price from the auto dataset.

sysuse auto, clear

// get mean and N
egen rowmean = rowmean(weight length price)
egen rowN = rownonmiss(weight length price)

// calculate 2, 3, and 4th moments about the mean
gen m2 = 1/rowN * ((weight - rowmean)^2 + (length - rowmean)^2 +
(price - rowmean)^2)
gen m3 = 1/rowN * ((weight - rowmean)^3 + (length - rowmean)^3 +
(price - rowmean)^3)
gen m4 = 1/rowN * ((weight - rowmean)^4 + (length - rowmean)^4 +
(price - rowmean)^4)

// calculate skew and kurtosis
gen rowskew = m3*m2^(-3/2)
gen rowkurt = m4*m2^(-2)

list weight length price rowskew rowkurt in 1/10

-- Matt
matt.spittal@cancervic.org.au

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of jeheyman
Sent: Tuesday, 14 October 2008 12:31 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: rowskew?

Is it possible to calculate essentially a rowskew and rowkurtosis in
the same way that egen calculates rowmean?

For each observation I have 18 variables and I need, obviously, the
three distribution measures.  Mean is trivial but the other two are
proving elusive. I feel like I'm overlooking something obvious and
posting seemed to be better than continuing to bang my head against
the wall.

Thanks.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```
```
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```

 © Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index