Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: A quick question


From   "Albert Newton" <[email protected]>
To   [email protected]
Subject   Re: st: A quick question
Date   Thu, 11 May 2006 19:06:14 -0700

Thanks for looking at my problem.  I just found that I made a stupid
algebric mistake.  Nonthing is wrong with the program.

On 5/11/06, Phil Schumm <[email protected]> wrote:
On May 11, 2006, at 5:34 PM, Albert Newton wrote:
> I have two varibles: weight and height of respondents in 1989.
>
> weight1998      float  %9.0g
> height1998      float  %9.0g
>
> I want to create a new variable:
>
> gen BMI = weight1998/(height1998^2)
>
> My little problem is that:  BMI takes strange values if weight1998
> is missing.  Could anyone tell me why?  Thanks a lot!
>
> height1998    weight1998      BMI1989
> 1.5748                  290                        53.04115
> 1.4732                  256                        53.50351
> 1.5494                  285                        53.84973
> 1.5494                  306                        57.8176
> 1.6764                  375                        60.52597
> 1.905                   .                          124.4902
> 1.778                   .                          142.9097
> 1.778                   .                          142.9097
> 1.6764                  .                          160.757
> 1.6764                  .                          160.757
> 1.6764                  .                          160.757


It is clear that the variable you are listing (BMI1989) was not
calculated using the expression above.  For example, if we take the
first observation:


. di 290/(1.5748^2)
116.93572


which is not equal to 53.04115.  We can help you a lot better if you
include part of the actual log.  For example:


. des

Contains data
  obs:            11
vars:             2
size:           110 (99.9% of memory free)
------------------------------------------------------------------------
-------
              storage  display     value
variable name   type   format      label      variable label
------------------------------------------------------------------------
-------
weight1998      int    %8.0g
height1998      float  %9.0g
------------------------------------------------------------------------
-------
Sorted by:
     Note:  dataset has changed since last saved

. gen BMI = weight1998/(height1998^2)
(6 missing values generated)

. li

     +--------------------------------+
     | wei~1998   hei~1998        BMI |
     |--------------------------------|
  1. |      290     1.5748   116.9357 |
  2. |      256     1.4732   117.9551 |
  3. |      285     1.5494   118.7183 |
  4. |      306     1.5494    127.466 |
  5. |      375     1.6764   133.4369 |
     |--------------------------------|
  6. |        .      1.905          . |
  7. |        .      1.778          . |
  8. |        .      1.778          . |
  9. |        .     1.6764          . |
 10. |        .     1.6764          . |
     |--------------------------------|
 11. |        .     1.6764          . |
     +--------------------------------+


BTW, BMI is typically calculated as:

BMI = weight (kg) / height (m^2)

Your heights look about right (for meters), but your weights are off
by about a factor of 4.


-- Phil

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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