Posts

Sum up and create new variable with STATA

Following are examples of how to create new variables in Stata using the gen (short for generate) and egen commands: To create a new variable (e.g., newvar ) and set its value to 0 , use: gen newvar = 0 To create a new variable (e.g., total ) from the transformation of existing variables (e.g., the sum of v1 , v2 , v3 , and v4 ), use: gen total = v1 + v2 + v3 + v4 Alternatively, use egen with the built-in rowtotal option: egen total = rowtotal(v1 v2 v3 v4) Note: The egen command treats missing values as 0 . To create a variable (e.g., avg ) that stores the average of four variables (e.g., v1 , v2 , v3 , and v4 ), use: gen avg = (v1 + v2 + v3 + v4) / 4 Note: Use the / (slash) to denote division and an * (asterisk) for multiplication. Alternatively, use egen with the built-in rowmean option: egen avg = rowmean(v1 v2 v3 v4) Stata also lets you take advantage of built-in functions for variable transformations. For example, to take the natura

Reporting Odds RAtio

  When Odds ratio is above 2 , then it is simply put as XX times higher likelihood (XX=odds ratio). If odds ratio is 2.5, then there is a 2.5 times higher likelihood of having the outcome compared to the comparison group. From the above example, one might say “The odds of having a postoperative infection is 3.5 times higher if the patient experienced a complication during the surgery as opposed to not experiencing the complication”. Here the odds ratio would be 3.5. When the odds ratio is lower than 1 , the likelihood of having the outcome is XX% lower (XX% = 1-Odds ratio). For e.g. if odds ratio is 0.70, then there is a 30% lower likelihood of having the outcome. In the above example related to surgical infection, you might say “The odds of having a postoperative infection is 20% lower if the patient was given prophylactic antibiotics during the surgery as opposed to not getting the antibiotic”. Here the odds ratio would be 0.80. The odds ratio also shows the strength of

Compute BMI with SPSS & STATA

  If you mean that the height is 168 cm which would be plausible   for 68kg  This is the formula compute bmi = weight / ((height/100)**2) . sedangkan untuk Stata, rumusnya adalah  gen BMI =  weight/(( heigth/100)^2) udah, gitu aja

Simple and Multiple Regression with STATA

Image
Chapter Outline   1.0 Introduction 1.1 A First Regression Analysis 1.2 Examining Data 1.3 Simple linear regression 1.4 Multiple regression 1.5 Transforming variables 1.6 Summary 1.7 Self assessment 1.8 For more information 1.0 Introduction This book is composed of four chapters covering a variety of topics about using Stata for regression. We should emphasize that this book is about “data analysis” and that it demonstrates how Stata can be used for regression analysis, as opposed to a book that covers the statistical basis of multiple regression.  We assume that you have had at least one statistics course covering regression analysis and that you have a regression book that you can use as a reference (see the Regression With Stata page and our Statistics Books for Loan page for recommended regression analysis books). This book is designed to apply your knowledge of regression, combine it with instruction on Stata, to perform, understand and interpret regression analy

How to recode into new variable in STATA

To recode variables in   Stata, use the   recode   command. To use   recode , you must provide a list of variables to be recoded and the rules associated with that change. For a variable (e.g.,   q1 ) that contains integers ranging from   1   to   7 , to collapse the values into three categories, use: recode q1 1=1 2=1 3/5=2 6=3 7=3 In the example above: The values of   1   and   2   are recoded as   1 .   The values of   3 ,   4 ,   5   are recoded as   2 . Note: The forward slash ( / ) denotes a range of values (e.g., from   3   to   5 ), including the beginning and end of the range.   The values of   6   and   7   are recoded as   3 .   After using   recode , you cannot recover the original values. To recode and store changes into a new variable (e.g.,   new_q1 ), combine   recode   with the   gen()   option: recode q1 1/2=1 3/5=2 6/7=3, gen(new_q1) Gampang kan?