Gerhard Riener has a nice page replicated below. LaTex and Stata @Gerhard’s Hompage @ Department of Economics @ Essex Stata Integration to Latex Producing Tables and Graphs and including them into publications and articles is often a very tedious task, especially when LaTex tables are involved. I collected some hopefully useful programs and links to instruction how to least paifully get your output to the masses General Articles A good website for people who (have to) work with data: DataNinja maintained by an Econ PhD student Rosa Gini and Jacopo Pasquini Automatic generation of documents Florent Bresson Outils Stata pour LaTeX Ben Jann Making regression tables from stored estimates Roger B. Newson Confidence intervals and p-values for delivery to the end user Stata Modules The most comprehensive stata module is OUTTEX . Provides a lot of features for exporting into html, \LaTex and text. CORRTEX Stata module to generate correlation tables formatted in LaTeX OUTREG2 Stata module to arrange regression outputs into an illustrative table TABOUT Stata module to export publication quality cross-tabulations, EST2TEX Stata module to create LaTeX tables from estimation results ESTOUT Stata module to make regression tables SUTEX Stata module to LaTeX code for summary statistics tables MAKETEX : Stata module to generate LaTeX code from a text file OUTTABLE : Stata module to write matrix to LaTeX table 原文: http://iman.edublogs.org/2009/07/02/set-of-tools-to-put-stata-output-in-latex/
Panel Data Econometrics: STATA Command *************************** * Panel的设置 和描述性统计 . tsset // Declare a dataset to be panel data panel variable: firmid (unbalanced) time variable: yeara, 1990 to 2006, but with gaps . xtdes firmid: 1 , 2 , ..., 3218 n = 3219 yeara: 1989 , 1990 , ..., 2006 T = 18 Delta(yeara) = 1 ; (2006-1989)+1 = 18 (firmid*yeara uniquely identifies each observation) . xtsum // Summarize xt data . xttab // Tabulate xt data *************************** * Hausman test http://fmwww.bc.edu/ec-c/s2009/327/ec327.s2009.php use traffic, clear summarize fatal beertax spircons unrate perincK * Fixed-effects (within) regression xtreg fatal beertax spircons unrate perincK, fe * Fixed-effects (within) regression,adding year dummies first qui tabulate year, generate(yr) local j 0 forvalues i=82/87 { local ++j rename yrj yri qui replace yri = yri - yr7 } drop yr7 xtreg fatal beertax spircons unrate perincK yr*, fe test yr82 yr83 yr84 yr85 yr86 yr87 * Between regression (regression on group means) xtreg fatal beertax spircons unrate perincK, be * Random-effects GLS regression xtreg fatal beertax spircons unrate perincK, re * Hausman test qui xtreg fatal beertax spircons unrate perincK, fe estimates store fix qui xtreg fatal beertax spircons unrate perincK, re hausman fix . *************************** * Dynamic panel: xtabond2 http://fmwww.bc.edu/ec-c/s2009/327/xtabond2.pdf use http://www.stata-press.com/data/r7/abdata.dta,clear * Dynamic panel- data estimation, one-step difference GMM xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984) /// noleveleq small * Dynamic panel-data estimation, two-step system GMM xtabond2 n l.n l(0/1).(w k) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984, mz) /// robust twostep small h(2) xtabond2 n l(1/2).n l(0/1).w l(0/2).(k ys) yr1980-yr1984, gmm(l.n w k) iv(yr1980-yr1984) /// robust twostep small xtabond2 n l(1/2).n l(0/1).w l(0/2).(k ys), gmm(w k, lag(1 .)) gmm(ys, lag(2 .)) iv(yr198*, eq(lev)) /// robust twostep *************************** * Dynamic panel: xtabond2 http://fmwww.bc.edu/ec-c/s2009/327/ec327.s2009.php http://fmwww.bc.edu/ec-c/s2009/327/xtabond2.pdf * Dynamic panel-data estimation, two-step difference GMM xtabond2 fatal L.fatal spircons year, /// gmmstyle(beertax spircons unrate perincK) /// ivstyle(year) twostep robust noleveleq * Dynamic panel-data estimation, two-step system GMM xtabond2 fatal L.fatal spircons year, /// gmmstyle(beertax spircons unrate perincK) /// ivstyle(year) twostep robust ----------------------- Using Arellano Bond Dynamic Panel GMM Estimators in Stata(Elitza Mileva) tsset ctry_dum year ssc install xtabond2,replace * Dynamic panel-data estimation, one-step difference GMM // * gmm( ) lists the endogenous var // * lag (2 2) instruct to use only the second lag of the endogenous variables as instruments // * iv ( ) lists all strictly exogenous variables (l.growth, uncert, tot, dev_m2) as well as the additional instrumental variables (fin_integr, trans_index, flows_eeca), which are not part of equation (1) and, therefore, are not listed before the comma in the Stata command . // * nolevel (or noleveleq) tells Stata to apply the difference GMM estimator. By default xtabond2 will apply the system GMM, if you dont specify nolevel. // * small tells Stata to use the small-sample adjustment and report t - instead of z-statistics and the Wald chi-squared test instead of the F test. // * twostep specifies that the two-step estimator is calculated instead of the default one-step. In two-step estimation, the standard covariance matrix is robust to panel-specific autocorrelation and heteroskedasticity, but the standard errors are downward biased. Use twostep robust to get the finite-sample corrected two-step covariance matrix. // * robust specifies that the resulting standard errors are consistent with panel-specific autocorrelation and heteroskedasticity in one-step estimation. xtabond2 inv l.inv fdi loans portfolio l.growth uncert tot dev_m2, gmm (inv fdi loans portfolio, lag (2 2)) iv(fin_integr trans_index flows_eeca l.growth uncert tot dev_m2) nolevel small * Dynamic panel-data estimation, one-step system GMM // * equation () sub-option, which specifies which equation should use the instruments: first-difference only ( equation (diff) ) or levels only ( equation (level) ). The default is both equations. xtabond2 inv l.inv fdi loans portfolio l.growth uncert tot dev_m2, gmm (inv fdi loans portfolio, lag (3 3)) iv(fin_integr trans_index flows_eeca l.growth uncert tot dev_m2) small noconst
Stata: Unbalanced to Balanced 将非平行面板转换为平行面板的命令 :xtbalance http://blog.cnfol.com/arlion/article/1183850.html 使用范例: xtbalance , range(1998 2005) 下载解压后存放到 personal 文件夹下即可。也可以放到其他的文件夹中,但需要采用 adopath + 命令指定文件夹的路径。 帮助文件: --------------------------------------------------------------------------------------------------------------- help for xtbalance version1.0 --------------------------------------------------------------------------------------------------------------- Trans the dataset into balance Panel Data xtbalance, range(numlist) You must tsset your data before using xtbalance; see help tsset. Description: xtbalance Trans the dataset into balance Panel Data with sample range specified by option range . Options : range(numlist) specifies sample range to be transfored.numlist must be two integers and specified in ascending order. Examples: . help xtbalance . xtbalance, range(1998 2005) For problems and suggestions login my blog http://blog.cnfol.com/arlion Author: Yu-Jun Lian, Jinhe Center, Xi'an Jiaotong University, China. ================== FAQ: 应对安装中可能出现的问题,方法如下: 不知怎么回事,照您的方法做还是不能在 STATA9.0 添加 xtbalance 。真是苦恼! 以下为 blog 主人的回复: 执行如下命令再运行 xtbalance , try 一下 adopath + D:\stata9\ado\personal 以下为 blog 主人的回复: 不知道你的 STATA 中是否设定了 profile.do 文件,如果没有,可以设一个。它的作用是把一些基本的设定定义好,在每次运行 STATA 时自动执行。 设定方法:把下面的代码粘贴到 do 文件编辑器中,保存到 D:\stata9 中,名称为 profile.do 。当然,你也可以根据自己的需要添加或删除命令。 adopath + D:\stata9\ado\personal adopath + D:\stata9\ado\personal\invt adopath + D:\stata9\ado\personal\update2 //adopath + D:\statawd\chung //adopath + D:\statawd\mine local fn = subinstr(`c(current_time)',:,,2) log using d:\stata9\ado\do\s`fn'.log, text replace cmdlog using d:\stata9\ado\do\c`fn'.log, replace sysdir set PLUS D:\stata9\ado\plus sysdir set OLDPLACE D:\ado sysdir set PERSONAL D:\stata9\ado\personal set matsize 2000 set more off,perma cd d:\stata9\ado\personal 下面的命令可保持时间跨度不变,将 unbalance 转化为 balance : tsset firm year,yearly xtdes by firm: gen obs=_N drop if obsr(max) xtbalance_ado
Guide to creating maps with Stata The graphs and maps on this site are created with the Stata statistical package. This article describes how to make maps like those showing Millennium Development Goal regions and UNICEF regions in Stata from a shapefile. Shapefiles store geographic features and related information and were developed by ESRI for its ArcGIS line of software. The shapefile format is used by many other programs and maps in this format can be downloaded from various sites on the Internet. Another common map format is the MapInfo Interchange Format for use with the MapInfo software. Shapefile data is usually stored in a set of three files (.shp, .shx, .dbf), while MapInfo data is stored in two files (.mif, .mid). Some sources for shapefiles and other data are listed on the website of the U.S. Centers for Disease Control and Prevention (CDC) under Resources for Creating Public Health Maps . The CDC itself provides shapefiles for all countries with administrative boundaries down to the state level. Please note that these shapefiles are not in the public domain and are intended for use with the CDC's Epi Info software only. Other sources of shapefiles can be found with a Google search. This guide is divided into two parts. Read part 1 if you have Stata 9 or 10 and part 2 if you have Stata 8. The creation of maps is not supported in older versions of Stata. Part 1: Creating maps with Stata 9 or 10 To create a map with Stata 9 or 10 you need the following software. Stata version 9.2 or newer. spmap: Stata module for drawing thematic maps, by Maurizio Pisati. Install in Stata with the command ssc install spmap . shp2dta: Stata module for converting shapefiles to Stata format, by Kevin Crow. Install in Stata with the command ssc install shp2dta . Shapefile: For the example in this guide, download world_adm0.zip (646 KB), a shapefile that contains the boundaries of all countries of the world. Step 1: Convert shapefile to Stata format Unzip world_adm0.zip to a folder that is visible to Stata. The archive contains three files called world_adm0.dbf, world_adm0.shp, and world_adm0.shx. Start Stata and run this command: shp2dta using world_adm0, data(world-d) coor(world-c) genid(id) Two new files will be created: world-d.dta (with the country names and other information) and world-c.dta (with the coordinates of the country boundaries). If you plan to superimpose labels on a map, for example country names, you should run the following command instead, which will add centroid coordinates to the file world-d.dta: shp2dta using world_adm0, data(world-d) coor(world-c) genid(id) genc(c) Please refer to the spmap documentation to learn more about labels because they are not covered in this guide. The DBF, SHP, and SHX files can be deleted. Some shapefiles are not compatible with the shp2dta command and Stata will abort the conversion with an error message. If this is the case, you can use a combination of two other programs, shp2mif and mif2dta. These programs are explained in the instructions for Stata 8 (see Step 1 and Step 2 in part 2 of this guide). Step 2: Draw map in Stata Open world-d.dta in Stata. The file contains no country-specific data that could be used for this example so we will create a variable with the length of each country's name. The Stata command for this is: generate length = length(NAME) Draw a map that indicates the length of all country names with this command: spmap length using world-c.dta, id(id) Be patient because spmap is slow if a map contains many features. The default map is monochrome, it shows Antarctica, the legend is too small and the legend values are arranged from high to low. We can draw a second map without Antarctica, with a blue palette, and with a bigger legend with values arranged from low to high: spmap length using world-c.dta if NAME!=Antarctica, id(id) fcolor(Blues) legend(symy(*2) symx(*2) size(*2)) legorder(lohi) You now have the map below. Darker colors indicate longer names, ranging from 4 letters (for example Cuba and Iraq) to 33 letters (Falkland Islands (Islas Malvinas)). To customize the map further, please read the Stata help file for spmap. Map created with spmap in Stata: length of country names The instructions above can be used to convert any shapefile to Stata format. If you have maps in MapInfo format you have to use another program called mif2dta that is described in part 2 of this guide. Part 2: Creating maps with Stata 8 To create a map with Stata 8 you need the following software. Stata version 8.2. tmap: Stata module for thematic mapping by Maurizio Pisati. Install in Stata with the command ssc install tmap . mif2dta: Stata module for converting files from MapInfo to Stata format, also by Maurizio Pisati. Install in Stata with the command ssc install mif2dta . SHP2MIF: DOS program for converting shapefiles to MapInfo format. Go to the the website of RouteWare and click on SHP2MIF (135 Kb) under the heading Converters to get ishp2mif.zip. Shapefile: For the example in this guide, download world_adm0.zip (646 KB), a shapefile that contains the boundaries of all countries of the world. Step 1: Convert shapefile to MapInfo format Unzip ishp2mif.zip. The archive contains three files, among them SHP2MIF.EXE. Unzip world_adm0.zip to the same folder as SHP2MIF.EXE. The archive contains three files called world_adm0.dbf, world_adm0.shp, and world_adm0.shx. Open a DOS command window: Windows Start menu - Run - command - OK. Change the path in the command window to the folder that contains SHP2MIF.EXE and the three map files. Use the DOS command cd to change the path. SHP2MIF works best with short file names in the 8.3 format (name up to 8 characters, extension up to 3 characters). Rename the map files with this DOS command: rename world_adm0.* world.* The map files are now called world.dbf, world.shp, and world.shx. Convert the maps to MapInfo format by typing shp2mif world in the DOS command window. This produces two new files: WORLD.MID and WORLD.MIF. Close the DOS command window. The DBF, SHP and SHX files can be deleted. Step 2: Convert MapInfo files to Stata format Move the MIF and MID files to a folder that is visible to Stata. Start Stata and run this command: mif2dta world, genid(id) Two new files will be created: world-Coordinates.dta (with the country boundaries) and world-Database.dta (with the country names and other information). If you plan to superimpose labels on a map, for example country names, you should run the following command instead, which will add centroid coordinates to the file world-Database.dta: mif2dta world, genid(id) genc(c) Please refer to the tmap documentation to learn more about labels because they are not covered in this guide. The MIF and MID files can be deleted. Step 3: Draw map in Stata Open world-Database.dta in Stata. The file contains no country-specific data that could be used for this example so we will create a variable with the length of each country's name. The Stata command for this is: generate length = length(name) Draw a map that indicates the length of all country names with this command: tmap choropleth length, map(world-Coordinates.dta) id(id) Be patient because tmap is slow if a map contains many features. The default map is monochrome, it shows Antarctica and the legend is too small. We can draw a second map without Antarctica, with a blue palette, and with a bigger legend: tmap choropleth length if name!=Antarctica, map(world-Coordinates.dta) id(id) palette(Blues) legsize(2) To reduce the margins, display the graph again and set the margins to zero: graph display, margins(zero) You now have the map below. Darker colors indicate longer names, ranging from 4 letters (for example Cuba and Iraq) to 33 letters (Falkland Islands (Islas Malvinas)). To customize the map further, please read the Stata help file for tmap and the tmap user's guide by Maurizio Pisati. The user's guide and additional tmap files can be downloaded in Stata with the commands ssc describe tmap and net get tmap . Map created with tmap in Stata: length of country names The instructions above can be used to convert any shapefile to Stata format. If you have maps in MapInfo format you can skip step 1 of the instructions and start with step 2. Related articles Guide to integrating Stata and external text editors Guide to creating PNG images with Stata Guide to reading Statalist with Gmail External links Stata FAQ: How do I graph data onto a map? Wikipedia article on shapefiles Wikipedia article on MapInfo Interchange Format Resources for Creating Public Health Maps from the Centers for Disease Control and Prevention (CDC) Friedrich Huebler, 6 November 2005 (edited 30 June 2009), Creative Commons License Permanent URL: http://huebler.blogspot.com/2005/11/creating-maps-with-stata.html http://huebler.blogspot.com/2005/11/creating-maps-with-stata.html
haif calculates homoskedastic adjustment inflation factors (HAIFs) for core variables in the corevarlist, caused by adjustment by the additional variables specified by addvars(). HAIFs are calculated for the variances and standard errors of estimated linear regression parameters corresponding to the core variables. For each variance (or standard error), the HAIF is defined as the ratio between that variance (or standard error) of that parameter, in a model containing both the core variables and the additional variables, to the corresponding variance (or standard error) of the same parameter, in a model containing only the core variables, calculated assuming that the second model is true, and also assuming that the outcome variable is homoskedastic (meaning that it has equal variances in all subpopulations defined by the predictor variables). haifcomp calculates the ratios between the HAIFs for the same core variables caused by adjustment for two alternative lists of additional variables, namely a numerator list and a denominator list. haif and haifcomp are intended for use in model selection, allowing the user to choose a model based on the joint distribution of the exposures and confounders, before estimating the parameters of the model from the data on the outcome variable.
http://ideas.repec.org/c/boc/bocode/s457003.html sortobs allows the user to sort observations by either (1) a variable's specific values or (2) observation numbers. Observations that are not specified in the command retain their original, respective sort orders.
http://ideas.repec.org/c/boc/bocode/s457002.html grep emulates the unix/linux command by the same name and will of course run on all operating systems. You can use it to parse any list of dta files and find ones with variables whose variable name or variable labels contain strings that interest you. It display the results in smcl format and they are clickable to you can directly describe the results. Furthermore it returns everything including datasets and variables found so you can program on top of it.
SEQCOMP, a sequence analysis Stata plug-in http://laurent.lesnard.free.fr/article.php3?id_article=8 Version 1.0 Available for Stata (v9 and higher) Mac (intel and PPC) and Windows Wednesday 28 May 2008 This Stata plug-in implements a sequence analysis method which has been presented in a working paper and previously in an article published in the Electronic International Journal of Time Use Research , Vol. 1 No. 1, pp. 67-91. Social sciences lack solutions to perform sequence analysis. This paper presents the Stata plug-in which was developed to implement a sequence analysis method I thought up to build a taxonomy of work schedules. Warning ! prior to version 0.7, the plugin was not the exact implementation of the formula proposed Differences are likely to be minor but users are advised to check on (...)" class="spip_note" name="nh1" href="http://laurent.lesnard.free.fr/article.php3?id_article=8#nb1">1 ] here . Many thanks to Renzo Carriero who pointed out that to me. First version: 7 december 2006 A sequence comparison method based on the sole substitution operations Although this method can be seen as a particular case of Optimal Matching , it is only a distant relative since only substitution operations are used. As a consequence, this method is only suitable for sequences of identical length. In a way, this method is closer to the Hamming distance which is usually considered as the ancestor of the Levenshtein distance (OM). Hence, a possible name for this method could be dynamic hamming dissimilarity measure. Indeed, subsitution costs are not equal to one unit as in the Hamming distance but are derived from the series of transition matrices which describe, between two episodes, the fluctuations between the states considered in the analysis. More precisely, sizable transitions between two states between t and t+1 means that they are close in probabilistic terms: the chances that switching between the two states are high. On the contrary, few transitions are observed between two states mean that these two states are distant. Work schedules can be sumarized by a two-state (work and no work) process. At 9 AM, transitions from work to no work are presumably higher than at 9 PM and consequently, workers and non workers will be considered as close at 9 AM and very distant at 9 PM. As a sequence comparison method, the end result is a matrix composed of the dissimilarity for every pair of sequences. A data reduction technique, such as cluster analysis or multidimensional scaling (MDS) is needed if these dissimilarities are to be exploited. Content of the zip file A Stata plug-in is actually composed of two distinct files: the plug-in strictly speaking, which extension is simply plugin This extension is hiding a dll." class="spip_note" name="nh2" href="http://laurent.lesnard.free.fr/article.php3?id_article=8#nb2">2 ]. an ado file, named here seqcomp.ado , an interface to distseq.plugin These two files must be unzipped into your local personal ado folder, installed somwhere on your computer . Once these two files installed, the plugin can be used through basic Stata syntax: seqcomp varlist In varlist, the first argument, should be put the list of variables the sequences to be analyzed are made of. The analysis can be restricted to certain sequences through the if option and weights can also be used The keyword iw is used since the version 0.4 in place of aw: iw is used (...)" class="spip_note" name="nh3" href="http://laurent.lesnard.free.fr/article.php3?id_article=8#nb3">3 ]. Typical use is: seqcomp episode1-episode100 The dissimilarities computed by the plugin are available as a Stata dissimilarity matrix named dhamdist . Note that the size of this matrix does not depend on matsize hence can be way over 800 for Stata Intercooled users and way over 11,000 for Stata SE ones. Getting the dissimilarities as a Stata matrix slows down a little things so it is possible to disable this feature using the nodistmat option. In this case the export option to save the result in a dissimilarity list becomes compulsory (results have to be stored somewhere!). The using command is also compulsory when export is chosen as it indicates where the results are to be stored. Remark that the file path must imperatively include at the end the appropriate folder separator . For example seqcomp episode1-episode100 using C:\temp\, export nodistmat will analyse all the sequences in the files from episode1 to episode100 and will put the results in C:\temp\. id() is optional but useful when export is chosen as it helps to match the internal id used to compute dissimilarities with any their original id, if any. Weights are taken into account for the calculations of the transition matrices but not for matching, which is by definition a one to one comparison. When weights are turned on, it is the users responsibility to use them again properly in the data reduction stage. Finally, it is possible to tell seqcomp which variable identifies observations: a file including a mapping of this variable to the internal id used will be produced. Results are made of three files if the export option is chosen: substitution.dat , which contains the series of the substitution cost matrices distancelist.dat , which presents the dissimilarity matrix as a dissimilarity list file with three columns: dissimilarities are located in the third column whereas the id of the couples of sequences can be found in the two first columns. 2 1 x 3 1 x 3 2 x 4 2 x 1 3 x ... idmapping.dat , made of two columns: the first one lists the internal ids of observations and the second gives their true id. This is the most efficient way of storing a dissimilarity matrix and is quite easy to use with standard statistical packages, in particular with the cluster package ClustanGraphics which reads without problem proximity lists . Stata itself reads proximity lists but is restricted to small matrices Matrix maximum size is 800 for Stata intercooled and 11,000 for Stata (...)" class="spip_note" name="nh4" href="http://laurent.lesnard.free.fr/article.php3?id_article=8#nb4">4 ]. However, Stata is not good when it comes to do cluster analysis: few (old) algorithms are available. SAS and ClustanGraphics are better in this field but neither features the latest methods. Why writing a plug-in and not a classical Stata ado file with Mata statements? The principle of sequence analysis is quite simple but require a lot of computer memory. Stata is not good when it comes to manage memory with such procedures and the only solution is to program these elements in C. Differences are likely to be minor but users are advised to check on their data. This extension is hiding a dll. The keyword iw is used since the version 0.4 in place of aw : iw is used to reflect the relative importance of observations (post-stratification etc.) whereas aw is inversely proportional to some variance measure (and as a consequence has nothing to do with sampling considerations). Matrix maximum size is 800 for Stata intercooled and 11,000 for Stata Special Edition (SE).
STATA http://dss.princeton.edu/online_help/stats_packages/stata/stata.htm Stata is an interactive data analysis program which runs on a variety of platforms. Stata is installed on the Windows machines and Macs in OIT's public clusters and on the Windows machines in the DSS Data Lab, as well as on the Tombstone Unix server. DSS Resources Introduction to Stata Introduction Issuing Commands Stata's Online Help Operating System Interface Dealing With Memory Requirements - what to do if there's no room Keeping Track of Your Work Stata's Built-in Calculator: display Data, Datasets and Variables Data Files - what they are and how to get them in Stata Converting to and from Excel and spreadsheet files Reading other kinds of text data Saving Data Missing Values Stata Variable Types Stata Variable Names Exploring your Data Examining your Data Summary Statistics Simple Regression Predicted Values Creating and Modifying Variables Variable creation commands The if qualifier Combining tests: and and or Subscripting Running Stata on Unix Running Unix Stata in text mode Stata for Unix with an XWindows interface Running large jobs in the background