Posts

Showing posts from March, 2018

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?

How to perform test of Normality Data with STATA

In   Stata, you can test normality by either graphical or numerical methods. The former include drawing a stem-and-leaf plot, scatterplot, box-plot, histogram, probability-probability (P-P) plot, and quantile-quantile (Q-Q) plot. The latter involve computing the Shapiro-Wilk, Shapiro-Francia, and Skewness/Kurtosis tests. The examples below are for the variable   score : Graphical methods   Command Plot drawn . stem score stem-and-leaf . dotplot score scatterplot . graph box score box-plot . histogram score histogram . pnorm score P-P plot . qnorm score Q-Q plot   Numerical methods   Command Test conducted . swilk score Shapiro-Wilk . sfrancia score Shapiro-Francia   . sktest score Skewness/Kurtosis Be aware that in these tests, the null hypothesis states that the variable is normally distributed. That means the data is considered normal if > 0.05 good luck

How to Perform Chi Square Test in STATA

In   Stata, both the   .tabulate   and   .tab commands conduct the Pearson's Chi-square test. The   .tabulate   (may be abbreviated as   .tab ) command produces one- or two-way frequency tables given one or two variables. The commands also can run a Chi-square test using the   chi2   option: . tab grade gender, chi2 The above command will produce a cross-table of   grade   and   gender   and its Chi-square statistic. When you do not have individual data, but only aggregate frequencies, use the   .tabi   command. You must list the frequencies of each cell with a backward slash ( \ ) to separate a row of a table. Consider the following examples: . tabi 22 44 \ 34 56, chi2 . tabi 34 45 \ 34 53 \ 34 34, chi2 . tabi 34 45 36 \ 34 64 96, chi2 The first command conducts a Chi-square test for a 2x2 table, while the second and third commands run the test for 3x2 and 2x3 tables, respectively.

How to Cronchbach Alpha with STATA

For my personal record only. This is how to perform croncbach alpha with stata Cronbach's alpha examines reliability by determining the internal consistency of a test or the average correlation of items (variables) within the test. In   Stata, the alpha   command conducts the reliability test. For example, suppose you wish to test the internal reliability of ten variables, q1   through q10 . You could run the following: alpha q1-q10, item In the above example, the   item   option displays the effects of removing an item from the scale.