Showing posts with label Stata. Show all posts
Showing posts with label Stata. Show all posts

Tuesday, November 10, 2015

Coefficient logit regression meaning

This page shows an example of logistic regression regression analysis with footnotes explaining the output.  These data were collected on 200 high schools students and are scores on various tests, including science, math, reading and social studies (socst).  The variable female is a dichotomous variable coded 1 if the student was female and 0 if male.
Because we do not have a suitable dichotomous variable to use as our dependent variable, we will create one (which we will call honcomp, for honors composition) based on the continuous variable write.  We do not advocate making dichotomous variables out of continuous variables; rather, we do this here only for purposes of this illustration.
use http://www.ats.ucla.edu/stat/data/hsb2, clear

generate honcomp = (write >=60)
logit honcomp female read science
Iteration 0:   log likelihood = -115.64441
Iteration 1:   log likelihood = -84.558481
Iteration 2:   log likelihood = -80.491449
Iteration 3:   log likelihood = -80.123052
Iteration 4:   log likelihood = -80.118181
Iteration 5:   log likelihood =  -80.11818

Logit estimates                              Number of obs   =        200
                                             LR chi2(3)      =      71.05
                                             Prob > chi2     =     0.0000
Log likelihood =  -80.11818                  Pseudo R2       =     0.3072

-------------------------------------------------------------------------
   honcomp |      Coef.   Std. Err.      z   P>|z|   [95% Conf. Interval]
-----------+-------------------------------------------------------------
    female |   1.482498   .4473993     3.31  0.001   .6056111    2.359384
      read |   .1035361   .0257662     4.02  0.000   .0530354    .1540369
   science |   .0947902   .0304537     3.11  0.002    .035102    .1544784
     _cons |   -12.7772    1.97586    -6.47  0.000  -16.64982   -8.904589
-------------------------------------------------------------------------

Iteration Log

Iteration 0:   log likelihood = -115.64441
Iteration 1:   log likelihood = -84.558481
Iteration 2:   log likelihood = -80.491449
Iteration 3:   log likelihood = -80.123052
Iteration 4:   log likelihood = -80.118181
Iteration 5:a  log likelihood = -80.11818
a.  This is a listing of the log likelihoods at each iteration.  (Remember that logistic regression uses maximum likelihood, which is an iterative procedure.)  The first iteration (called iteration 0) is the log likelihood of the "null" or "empty" model; that is, a model with no predictors.  At the next iteration, the predictor(s) are included in the model.  At each iteration, the log likelihood increases because the goal is to maximize the log likelihood.  When the difference between successive iterations is very small,  the model is said to have "converged", the iterating is stopped and the results are displayed.  For more information on this process, see Regression Models for Categorical and Limited Dependent Variables by J. Scott Long.

Model Summary

Logit estimates                               Number of obsc   =        200
                                              LR chi2(3)d      =      71.05
                                              Prob > chi2e     =     0.0000
Log likelihood =  -80.11818b                  Pseudo R2f       =     0.3072
b.  Log likelihood - This is the log likelihood of the final model.  The value -80.11818 has no meaning in and of itself; rather, this number can be used to help compare nested models.
c.  Number of obs - This is the number of observations that were used in the analysis.  This number may be smaller than the total number of observations in your data set if you have missing values for any of the variables used in the logistic regression.  Stata uses a listwise deletion by default, which means that if there is a missing value for any variable in the logistic regression, the entire case will be excluded from the analysis.
d.  LR chi2(3) - This is the likelihood ratio (LR) chi-square test.  The likelihood chi-square test statistic can be calculated by hand as 2*(115.64441 - 80.11818) = 71.05.  This is minus two (i.e., -2) times the difference between the starting and ending log likelihood.  The number in the parenthesis indicates the number of degrees of freedom.  In this model, there are three predictors, so there are three degrees of freedom.
e.  Prob > chi2 - This is the probability of obtaining the chi-square statistic given that the null hypothesis is true.  In other words, this is the probability of obtaining this chi-square statistic (71.05) if there is in fact no effect of the independent variables, taken together, on the dependent variable.  This is, of course, the p-value, which is compared to a critical value, perhaps .05 or .01 to determine if the overall model is statistically significant.  In this case, the model is statistically significant because the p-value is less than .000.
f.  Pseudo R2 - This is the pseudo R-squared.  Logistic regression does not have an equivalent to the R-squared that is found in OLS regression; however, many people have tried to come up with one.  There are a wide variety of pseudo-R-square statistics.  Because this statistic does not mean what R-square means in OLS regression (the proportion of variance explained by the predictors), we suggest interpreting this statistic with great caution.

Parameter Estimates

-------------------------------------------------------------------------
   honcompg|     Coef.h  Std. Err.i     zj  P>|z|j   [95% Conf. Interval]k
-----------+-------------------------------------------------------------
    female |   1.482498   .4473993     3.31  0.001   .6056111    2.359384
      read |   .1035361   .0257662     4.02  0.000   .0530354    .1540369
   science |   .0947902   .0304537     3.11  0.002    .035102    .1544784
     _cons |   -12.7772    1.97586    -6.47  0.000   -16.64982   -8.90459
-------------------------------------------------------------------------
g.  honcomp - This is the dependent variable in our logistic regression.  The variables listed below it are the independent variables.
h.  Coef. - These are the values for the logistic regression equation for predicting the dependent variable from the independent variable.  They are in log-odds units.  Similar to OLS regression, the prediction equation is
log(p/1-p) = b0 + b1*female + b2*read + b3*science
where p is the probability of being in honors composition.  Expressed in terms of the variables used in this example, the logistic regression equation is
log(p/1-p) = -12.7772 + 1.482498*female + .1035361*read + 0947902*science
These estimates tell you about the relationship between the independent variables and the dependent variable, where the dependent variable is on the logit scale.  These estimates tell the amount of increase in the predicted log odds of honcomp = 1 that would be predicted by a 1 unit increase in the predictor, holding all other predictors constant.  Note: For the independent variables which are not significant, the coefficients are not significantly different from 0, which should be taken into account when interpreting the coefficients.  (See the columns with the z-values and p-values regarding testing whether the coefficients are statistically significant).  Because these coefficients are in log-odds units, they are often difficult to interpret, so they are often converted into odds ratios.  You can do this by hand by exponentiating the coefficient, or by using the or option with logit command, or by using the logistic command.
  female - The coefficient (or parameter estimate) for the variable female is 1.482498.  This means that for a one-unit increase in female (in other words, going from male to female), we expect a 1.482498 increase in the log-odds of the dependent variable honcomp, holding all other independent variables constant.
  read - For every one-unit increase in reading score (so, for every additional point on the reading test), we expect a .1035361 increase in the log-odds ofhoncomp, holding all other independent variables constant.
  science - For every one-unit increase in science score, we expect a .0947902 increase in the log-odds of honcomp, holding all other independent variables constant.
  constant - This is the expected value of the log-odds of honcomp when all of the predictor variables equal zero.  In most cases, this is not interesting.  Also, oftentimes zero is not a realistic value for a variable to take.
i.  Std. Err. - These are the standard errors associated with the coefficients.  The standard error is used for testing whether the parameter is significantly different from 0; by dividing the parameter estimate by the standard error you obtain a z-value (see the column with z-values and p-values).  The standard errors can also be used to form a confidence interval for the parameter, as shown in the last two columns of this table.
j.  z and P>|z| - These columns provide the z-value and 2-tailed p-value used in testing the null hypothesis that the coefficient (parameter) is 0.   If you use a 2-tailed test, then you would compare each p-value to your preselected value of alpha.  Coefficients having p-values less than alpha are statistically significant.  For example, if you chose alpha to be 0.05, coefficients having a p-value of 0.05 or less would be statistically significant (i.e., you can reject the null hypothesis and say that the coefficient is significantly different from 0).   If you use a 1-tailed test (i.e., you predict that the parameter will go in a particular direction), then you can divide the p-value by 2 before comparing it to your preselected alpha level.  With a 2-tailed test and alpha of 0.05, you may reject the null hypothesis that the coefficient for female is equal to 0.  The coefficient of 1.482498 is significantly greater than 0.
  The coefficient for read is .1035361 significantly different from 0 using alpha of 0.05 because its p-value is 0.000, which is smaller than 0.05.
  The coefficient for science is .0947902 significantly different from 0 using alpha of 0.05 because its p-value is 0.000, which is smaller than 0.05.
k. [95% Conf. Interval] - This shows a 95% confidence interval for the coefficient.  This is very useful as it helps you understand how high and how low the actual population value of the parameter might be.  The confidence intervals are related to the p-values such that the coefficient will not be statistically significant if the confidence interval includes 0. 

Odds Ratios

In this next example, we will illustrate the interpretation of odds ratios.  We will use the logistic command so that we see the odds ratios instead of the coefficients.  In this example, we will simplify our model so that we have only one predictor, the binary variable female.  Before we run the logistic regression, we will use the tab command to obtain a crosstab of the two variables.
tab female honcomp
           |        honcomp
    female |         0          1 |     Total
-----------+----------------------+----------
      male |        73         18 |        91 
    female |        74         35 |       109 
-----------+----------------------+----------
     Total |       147         53 |       200 
If we divide the number of males who are in honors composition, 18, by the number of males who are not in honors composition, 73, we get the odds of being in honors composition for males, 18/73 = .24657534.  If we do the same thing for females, we get 35/74 = .47297297.  To get the odds ratio, which is the ratio of the two odds that we have just calculated, we get .47297297/.24657534 = 1.9181682.  As we can see in the output below, this is exactly the odds ratio we obtain from the logistic command.  The thing to remember here is that you want the group coded as 1 over the group coded as 0, so honcomp=1/honcomp=0 for both males and females, and then the odds for females/odds for males, because the females are coded as 1.
With regard to the 95% confidence interval, we do not want this to include the value of 1.  When we were considering the coefficients, we did not want the confidence interval to include 0.  If we exponentiate 0, we get 1 (exp(0) = 1).  Hence, this is two ways of saying the same thing.  As you can see, the 95% confidence interval includes 1; hence, the odds ratio is not statistically significant.  Because the lower bound of the 95% confidence interval is so close to 1, the p-value is very close to .05.
There are a few other things to note about the output below.  The first is that although we have only one predictor variable, the test for the odds ratio does not match with the overall test of the model.  This is because the z statistic is actually the result of a Wald chi-square test, while the test of the overall model is a likelihood ratio chi-square.  While these two types of chi-square tests are asymptotically equivalent, in small samples they can differ, as they do here.  Also, we have the unfortunate situation in which the results of the two tests give different conclusions.  This does not happen very often.  In a situation like this, it is difficult to know what to conclude.  One might consider the power, or one might decide if an odds ratio of this magnitude is important from a clinical or practical standpoint.
logistic honcomp female 
Logistic regression                        Number of obs   =        200
                                           LR chi2(1)      =       3.94
                                           Prob > chi2     =     0.0473
Log likelihood =  -113.6769                Pseudo R2       =     0.0170

-------------------------------------------------------------------------
   honcomp | Odds Ratio   Std. Err.      z    P>|z|  [95% Conf. Interval]
-----------+-------------------------------------------------------------
    female |   1.918168   .6400451     1.95   0.051  .9973827    3.689024
-------------------------------------------------------------------------

Source

Friday, May 22, 2015

Computing interaction effects and standard error in logit and probit models

link
Conclusion 
Interaction effects are complicated to compute and interpret in nonlinear models. Because of their widespread use, however, having a command to compute them is important for applied reseachers. The new command inteff allows users to compute the magnitude, sign, statistical significance of interaction effects in logit and probit models.

The results of two examples are typical of patterns we have found after computing interaction effects for a wide range of problems. The interaction effects has a wave shape when plotted against predicted values. Some interaction effects are positive, som nagative, no matter what the sign of coefficient on the interaction term. For predicted value equals to 0.5 the interaction effects is B12O'(u) for probit case. There is wide variation in the statistical significance of the interaction effect.

There are two limitations to the inteff command. One is that the code will only work for logit and probit models, even though the issue applies to all nonlinear models, such as tobit and count models. In addtion, the command will only work for the interaction between two variable that do not also have higer order terms. For example, the command would yield the wrong answer if, in the first example, age squared was also included as an independent variables. For other nonlinear models, interactions between more than two variables or interactions of variables with higher - order terms use the Stata command predictnl with great care

Sunday, June 16, 2013

How can you get 3-way, 4-way, 5-way or more cross tabulation in Stata?

The tabulate command is great for 2-way cross tabulations. But how do you do 3-way, 4-way, 5-way of more cross tabulations? The answer is to use the table command with the contents(freq) option. Here is the general form of the table command.
table row_variabble column_variable super_column_variable, by(super_row_var_list) contents(frq)
Before we begin let's load the dataset and create an additional categorical variable, read_level.
* create new categorical variable
gen read_level=read>=55
label define read_level 0 "low" 1 "high"
label values read_level read_level* create new categorical variable

gen read_level=read>=55

label define read_level 0 "low" 1 "high"

label values read_level read_level
We begin by looking at all of the 1-way tables for our categorical variables.
tab1

-> tabulation of prog  

    type of |
    program |      Freq.     Percent        Cum.
------------+-----------------------------------
    general |         45       22.50       22.50
   academic |        105       52.50       75.00
   vocation |         50       25.00      100.00
------------+-----------------------------------
      Total |        200      100.00

-> tabulation of ses  

        ses |      Freq.     Percent        Cum.
------------+-----------------------------------
        low |         47       23.50       23.50
     middle |         95       47.50       71.00
       high |         58       29.00      100.00
------------+-----------------------------------
      Total |        200      100.00

-> tabulation of female  

     female |      Freq.     Percent        Cum.
------------+-----------------------------------
       male |         91       45.50       45.50
     female |        109       54.50      100.00
------------+-----------------------------------
      Total |        200      100.00

-> tabulation of honors  

      honors |
     english |      Freq.     Percent        Cum.
-------------+-----------------------------------
not enrolled |        147       73.50       73.50
    enrolled |         53       26.50      100.00
-------------+-----------------------------------
       Total |        200      100.00

-> tabulation of read_level  

 read_level |      Freq.     Percent        Cum.
------------+-----------------------------------
        low |        117       58.50       58.50
       high |         83       41.50      100.00
------------+-----------------------------------
      Total |        200      100.00
Next the 2-way table.
tab prog ses

   type of |               ses
   program |       low     middle       high |     Total
-----------+---------------------------------+----------
   general |        16         20          9 |        45 
  academic |        19         44         42 |       105 
  vocation |        12         31          7 |        50 
-----------+---------------------------------+----------
     Total |        47         95         58 |       200 
Now the 3-way table.
table prog ses female, contents(freq)

------------------------------------------------------------
          |                  female and ses                 
type of   | -------- male --------    ------- female -------
program   |    low  middle    high       low  middle    high
----------+-------------------------------------------------
  general |      7      10       4         9      10       5
 academic |      4      22      21        15      22      21
 vocation |      4      15       4         8      16       3
------------------------------------------------------------
Followed by a 4-way table.
table prog ses female, by(honors) contents(freq)

---------------------------------------------------------------
honors       |
english and  |                  female and ses                 
type of      | -------- male --------    ------- female -------
program      |    low  middle    high       low  middle    high
-------------+-------------------------------------------------
not enrolled |
     general |      7      10       2         7       8       4
    academic |      3      17      12         9      16       8
    vocation |      4      14       4         6      14       2
-------------+-------------------------------------------------
enrolled     |
     general |                      2         2       2       1
    academic |      1       5       9         6       6      13
    vocation |              1                 2       2       1
---------------------------------------------------------------
Finally a 5-way table.
table prog ses female, by(honors read_level) contents(freq)

---------------------------------------------------------------
honors       |
english,     |
read_level   |                  female and ses                 
and type of  | -------- male --------    ------- female -------
program      |    low  middle    high       low  middle    high
-------------+-------------------------------------------------
not enrolled |
low          |
     general |      4       5       1         6       6       4
    academic |      2       8       7         8      12       3
    vocation |      4      11       3         6      12       2
-------------+-------------------------------------------------
not enrolled |
high         |
     general |      3       5       1         1       2        
    academic |      1       9       5         1       4       5
    vocation |              3       1                 2        
-------------+-------------------------------------------------
enrolled     |
low          |
     general |                                2               1
    academic |              2       2         1       1       1
    vocation |                                1       1       1
-------------+-------------------------------------------------
enrolled     |
high         |
     general |                      2                 2        
    academic |      1       3       7         5       5      12
    vocation |              1                 1       1        
--------------------------------------------------------------- 

Monday, May 6, 2013

Convert stata to spss


Abstract

This package provides a batch process to exchange data of current directory between different spreadsheet and statistics programs. Stat/Transfer is required.

Download Info

If you experience problems downloading a file, check if you have the proper application to view it first. In case of further problems read the IDEAS help page. Note that these files are not on the IDEAS site. Please be patient as the files may be large.
File URL: http://fmwww.bc.edu/repec/bocode/f/ftrans.ado
File Function: program code
Download Restriction: no

File URL: http://fmwww.bc.edu/repec/bocode/f/ftrans.sthlp
File Function: help file
Download Restriction: no


Source

Curve fit on stata

CURVEFIT: Stata module to produces curve estimation regression statistics and related plots between two variables for alternative curve estimation regression models

Abstract

The Curve Estimation procedure produces curve estimation regression statistics and related plots between two variables for 35 different curve estimation regression models (Linear, Logarithmic, Inverse, Quadratic, Cubic, Power, Compound, S-curve, Logistic, Growth, Exponential, Vapor Pressure, Reciprocal Logarithm, Modified Power, Shifted Power, Geometric, Modified Geometric, Root, Hoerl, Modified Hoerl, Reciprocal, Reciprocal Quadratic, Bleasdale, Harris, Exponential Association, Three-Parameter Exponential Association, Saturation-Growth Rate, Gompertz Relation, Richards, MMF, Weibull, Sinusoidal, Gaussian, Heat Capacity, Rational).

Download Info

If you experience problems downloading a file, check if you have the proper application to view it first. In case of further problems read the IDEAS help page. Note that these files are not on the IDEAS site. Please be patient as the files may be large.
File URL: http://fmwww.bc.edu/repec/bocode/c/curvefit.ado
File Function: program code
Download Restriction: no

File URL: http://fmwww.bc.edu/repec/bocode/c/curvefit.sthlp
File Function: help file
Download Restriction: no

File URL: http://fmwww.bc.edu/repec/bocode/t/temptime.dta
File Function: sample dataset
Download Restriction: no


Source

Friday, October 26, 2012

Change font in notepad ++


Setting / style configurator/
- in language choose Global style
- in font style
Choose font you need
tick "enable global font"

Thursday, September 29, 2011

How do i do this SPSS command in Stata

http://www.ats.ucla.edu/stat/stata/faq/spss_command_to_stata.htm

Say that you use SPSS but wish to know how to do a particular command in Stata. For example, you want to make a new variable and know you can use the compute command to create a new variable in SPSS, but what is the equivalent (or similar) command in Stata?  (By the way, there are actually three similar Stata commands, generate, replace and egen). The table below shows you five columns of information.
  • SPSS commands, listed in alphabetical order
  • The equivalent (or similar) Stata command(s)
  • Links to UCLA web pages that illustrate the use of the Stata command
  • Cross references to the Stata manual for learning more about the command (which is also hot linked to the online help for the command)
  • Cross references to books that illustrate more about the command.
This table is by no means complete, and it not intended to be a complete and exhaustive reference. Instead, it is intended to be a short, simple, sweet and handy reference for SPSS users who are making the transition to Stata. We also highly recommend A Sample Stata Session (via the Stata web site) which gives you a quick overview of using Stata as well as seeing the [GS] Getting Started manual that accompanied your purchase of Stata.
SPSS CommandStata Command(s)UCLA Web PagesStata ManualBooks
ADD FILESappendCombining data  [D] appendishr - 9.5
AGGREGATEcollapseCollapsing data across observations[D] collapseishr - 9.6
ANOVAanova.[R] anova 
AUTORECODEdestring
encode
How can I quickly convert many string variables to numeric  [D] destring
[D] encode
 
CASESTOVARSreshape wideReshaping data from long to wide[D] reshape 
COMMENT*
/* */
//
.[P] commentsishr 4.8
COMPUTEgenerate
replace
egen
Creating and Recoding Variables[D] generate
[D] replace
[D] egen
ishr 8.1
CORRELATIONScorrelate
pwcorr
- Overview of statistical tests in Stata
- Annotated output for the correlation command
[R] correlate 
CROSSTABStabulate
tab2
Overview of statistical tests in Stata[R] tabuluate twowayishr 10.3
DATA LISTinfile
infix
insheet
Inputting raw data files into Stata[D] infile (free format)
[D] insheet
[D] infix (fixed format)
ishr 6.3
DELETE VARIABLESkeep
drop
Subsetting variables and observations[D] drop 
DESCRIPTIVESsummarize- Descriptive information and statistics
- Annotated output for the summarize command
 
[R] summarizeishr 10.1
DISPLAYdescribe.[D] describe 
DOCUMENTnotes.[D] notes 
DO IFxyzcommand ifStata Learning Module: Using "if" for subsetting with Stata Commands[U] 11.1.3 if exp 
DO REPEATforeachWorking across variables using foreach[P] foreachishr - 17.4
ECHOdisplay.[P] display 
ERASEerase.[D] erase 
EXAMINEtabulate x, summarize(y)Overview of statistical tests in Stata[R] tabulate, summarize() 
EXECUTEno equivalentcomment: transformation commands always immediately executednone 
EXPORTno equivalentcomment: all Stata files can be used on all platformsnone 
FACTORfactorAnnotated output for the factor command[MV] factor 
FILE LABELlabel dataLabeling data, variables and values[D] label 
FILTERxyzcommand if (___)Using "if" for subsetting with Stata Commands[U] 11.1.3 if exp 
FLIPxpose.[D] xpose 
FORMATSformat.[D] formatishr - 5.2
FREQUENCIEStabulateOverview of statistical tests in Stata[R] tabulate onewayishr - 10.3
GET FILEuseUsing and saving Stata data files[D] useishr - 6.1
GET SASfdause- SAS to Stata
- SAS w/formats to Stata
[D] fdause 
GRAPHgraphIntroduction to graphics[G] graph 
IFgenerate __ if __Using "if" for subsetting with Stata Commands[U] 11.1.3 if expishr - 8.1
IGRAPHgraphIntroduction to graphics[G] graph 
INCLUDE FILEdo ___.[R] do 
LISTlist.[D] list 
LOGISTIC REGRESSIONlogisticData Analysis Example: Logistic Regression[R] logistic 
LOOPforvalues [P] forvalues 
MATCH FILESmergeCombining Stata data files[D] mergeishr - 9.5
MEANStabulate __, summarize(__)Overview of statistical tests in Stata[R] tabulate, summarize()ishr - 10.4
MISSING VALUESnone.[U] 12.2.1 Missing Values 
MIXEDxtmixed.[XT] xtmixed 
NOMREGmlogitData Analysis Example: Multinomial Logistic Regression[R] mlogit 
PLUMologitData Analysis Example: Ordinal Logistic Regression[R] ologit 
PROBITprobitData Analysis Example: Probit Regression[R] probit 
RECODErecodeCreating and Recoding Variables[D] recodeishr - 8.4
RECORD TYPEno equivalenthttp://www.stata.com/support/faqs/data/hier.html  
REGRESSIONregress- Regression with Stata
- Annotated output for the regress command
[R] regress 
RELIABILITYalpha.[R] alpha 
RENAME VARIABLESrename.[D] rename 
SAMPLEsample.[D] sampleishr - 9.2
SAVEsaveUsing and saving Stata data files[D] saveishr - 6.1
SELECT IFkeep if
drop if
Subsetting variables and observations[D] dropishr - 9.2
SORT CASESsort.[D] sortishr - 9.4
SPLIT FILEby.[D] by
[U] 11 Language syntax
ishr - 4.7
SUMMARIZEtabulate ___, summarize(___)Overview of statistical tests in Stata[R] tabulate, summarize() 
TEMPORARY.
SELECT IF (___).
xyzcommand if (___)Using "if" for subsetting with Stata Commands[U] 11.1.3 if expishr - 4.4
T-TESTttestOverview of statistical tests in Stata ishr - 10.4
VALUE LABELSlabel valuesLabeling data, variables and values
[D] label
ishr - 7.1
VARIABLE LABELSlabel variableLabeling data, variables and values[D] labelishr - 7.1
VARSTOCASESreshape longReshaping data from wide to long[D] reshape 
WEIGHTaw pw fw iwWhat types of weights do SAS, Stata and SPSS support?[U] l11.1.6 weightishr - 4.5
Legend
  • xyzcommand stands for any arbitrary Stata command
  • UCLA Web Pages
    • "." - no specific page exists. Try visiting the site and using the "search" command to pages that might tangentially refer to the command.
  • Stata Manual Names
    • [D] Data
    • [R] Reference manual
    • [U] Users Guide
    • [MV] Multivariate Statistics
    • [XT] Cross sectional time series
  • Book References
    • ishr - Introduction to Stata for Health Researchers by Svend Juul

Thursday, August 5, 2010

Convert VHLSS Stata- SPSS


Do SPSS đọc được rất nhiều loại đuôi kể cả đuôi .dta của stata, nhưng nhiều khi để đuôi .dta của stata dùng trong SPSS lại không tiện, như khi bạn muốn merge các file dữ liệu trong SPSS đuôi file dữ liệu phải là .sav
Việc dùng Stat/tranfer chỉ chuyển được 1 cách thủ công các file, mất thời gian, khi dùng SPSS lại phải mất công.
Trong SPSS có cửa sổ Syntax rất tiện lợi để viết các code làm nhanh gọn
Mình làm 1 số file syntax trên SPSS19 để convert các file VHLSS
VHLSS2004
VHLSS2006
VHLSS2008

Với các file này nếu muốn sử dụng trên máy tính khác chỉ việc vào cửa số Syntax SPSS
chon Edit/ Replace (Ctrl+H)
Ví dụ


Công việc trở lên đơn giản, với nhiều loại dữ liệu khác cũng có thể làm tương tự như vậy