New In
More new features in Stata 18
We introduced many highlights of the Stata 18 release here. But Stata 18 includes much more. We don’t want you to overlook the additional new features listed below. One of them might be your favorite.
General statistics
- Many of Stata’s estimation commands support the vce(robust) option for estimating robust standard errors and the vce(cluster clustvar) option for estimating cluster–robust standard errors. These options are now supported by two additional commands:
- The sureg command, which fits seemingly unrelated regression models
- The reg3 command, which fits systems of simultaneous equations via three-stage least squares
- Exact p-values are now available for Spearman’s rank correlation coefficients. The spearman command now supports the exact() option to compute the exact p-value using a Monte Carlo sampling of the permutation distribution or using a complete enumeration of the permutation distribution.
- Stata’s factor-variable notation allows users to specify categorical variables and interactions in variable lists in many commands. This notation is now supported by additional commands:
- The exlogistic command, which fits exact logistic regression models
- The expoisson command, which fits exact Poisson regression models
- After fitting simultaneous-quantile regression models with sqreg, you can use the new estat coefplot command to plot the coefficients and their confidence intervals across quantiles.
- The nlcom command, which computes nonlinear combinations of parameters, now supports the eform[()] option to report exponentiated nonlinear parameters.
- The table command now computes two additional statistics: the geometric mean and the geometric standard deviation, which are specified using statistic(geomean) and statistic(geosd), respectively. In addition, strL variables may now be used to define the rows, columns, and separate tables.
Causal inference
- After fitting a difference-in-differences model with didregress or xtdidregress to data comprising multiple cohorts that are treated at different times, you can use the new estat bdecomp command to decompose the average treatment effect on the treated (ATET) into components. The results are useful in determining whether the treatment effects are heterogeneous and, if so, how much the heterogeneity impacts the overall ATET reported by didregress or xtdidregress.
Meta-analysis
- After meta regress, you can now use predict with the reses() option, which is specified with the reffects option, to compute comparative standard errors for the random effects. Diagnostic standard errors can be obtained by adding the diagnostic suboption.
- After meta mvregress, you can now use predict with the reses() option to compute comparative standard errors for the random effects by default. Diagnostic standard errors can be obtained by adding the diagnostic suboption.
Survival analysis
- The stcurve command plots the survivor, failure, hazard, or cumulative hazard function after fitting many models for survival-time data. In Stata 18, stcurve has the following new features:
- After fitting a shared-frailty Cox model with stcox, you can now specify the expression _frailty = (numlist) in the at() option to adjust estimates of survivor and related functions for frailties set to the values in numlist.
- After fitting a Cox model for a multiple-record-per-subject interval-censored dataset using stintcox, you can specify the new atmeans option to evaluate the survivor or other function at time-specific means of the covariate.
- After fitting a Cox model for a multiple-record-per-subject interval-censored dataset using stintcox, you can specify the new atframe(frname) option to evaluate the survivor or other function at the values of the variables specified in the frname frame.
- After lasso cox or elasticnet cox, you can calculate predictions based on penalized coefficients by default, or you can calculate predictions based on postselection coefficients by specifying the postselection option.
- After fitting a shared-frailty Cox model with stcox, predict now allows the atfrailty and atfrailty(varname|#) options when you predict the baseline survivor function, baseline cumulative-hazard function, or baseline hazard contributions. If you specify atfrailty, frailties are set to their estimated values when computing predictions. If you specify atfrailty(varname|#), frailties are instead set to the values in varname or #.
- The stintcox command, which fits Cox proportional hazards models for interval-censored data, now supports the vce(robust) option for estimating robust standard errors and the vce(cluster clustvar) option for estimating cluster—robust standard errors.
Multivariate statistics
- Stata’s factor-variable notation allows users to specify categorical variables and interactions in variable lists in many commands. This notation is now supported by additional commands:
- The discrim knn command, which performs kth-nearest-neighbor discriminant analysis
- The discrim logistic command, which performs logistic discriminant analysis
Graphics
- When you create by-graphs, you can now specify the altleg bystyle to move the legend to the six o’clock position and use two columns for the legend. For instance, specifying the by(group, style(altleg)) option will create the graph for each value of group and will place the two-column legend at the bottom of these graphs.
- You can now specify a minimum length for the axis labels with the labelminlen(#) option. This can be particularly helpful if you are creating multiple graphs that you intend to combine by using graph combine. You can, for instance, specify ylabel(labelminlen(5)) with each graph to ensure that at least five characters are used for the y-axis labels; labels are padded with spaces on the left if needed. Adding this option to each graph specification will allow you to create graphs with labels of the same width so that axes will align nicely when combined.
Data management
- You can use the new export spss command to export a Stata dataset to an SPSS (.sav) file.
- The import delimited command has a new emptylines(skip|include) option to control how empty lines are processed as observations.
- The icd10 commands have been updated to include ICD-10 diagnosis codes from the sixth edition (2019).
- The contract command is now faster.
Functions
- Seven new datetime functions, mostly related to days of the week, are now available. Read the overview.
Programming
- The levelsof command is now faster.
- The Stata–Python API specification has new features and improvements:
- The ValueLabel class can now work with Stata’s extended missing values using the following methods:
- ValueLabel.getLabel(name, value) allows value to be .a, .b, …, .z in addition to an integer value so that it can return the labels associated with Stata’s missing values.
- ValueLabel.getValueLabels(name) returns Stata’s missing label as a key if the value label contains a missing value associated with a label. Previously, the key was returned as an integer missing value.
- ValueLabel.setLabelValue(name, value, label) allows value to be .a, .b, …, .z in addition to an integer value so that it can set labels for missing values.
- ValueLabel.getValues(name) returns Stata’s missing label in the result if the value label contains a missing value associated with a label. Previously, the value was returned as an integer missing value.
- ValueLabel.removeLabelValue(name, value) allows value to be .a, .b, …, .z in addition to an integer value so that it can remove labels for missing values.
- The Missing class has the following improvements:
- Missing.getValue(val=None) allows users to input None or ., .a, …, .z to access Stata’s missing values. Previously val could be None, or a, b, …, z.
- Missing.getMissing(value) gets the missing symbol associated with value that represents the corresponding missing value in Stata.
- The Data class has a new function, isAlias(var), that returns whether a variable in the current dataset is an alias for a variable in another frame.
- The Frame class has a new function, isAlias(var), that returns whether a variable in the current dataset is an alias for a variable in another frame.
- The Stata–Java API Specification has the following new features:
- The ValueLabel class can now work with Stata’s extended missing values using the following methods:
- ValueLabel.getLabel(java.lang.String, double) gets the label for a specified value-label value.
- ValueLabel.getValueLabels(String name, Map<LabelValue,String> map) gets the value and label pairings for a specified value-label name.
- ValueLabel.removeLabelValue(String name, Missing.Extended missingValue) removes a value-label value from the specified value-label name.
- ValueLabel.setLabelValue(String name, Missing.Extended missingValue, String label) sets a value and label for a value-label name.
- The LabelValue class was added to encapsulate a Stata value-label value.
- The Data class has a new function, isAlias(int var), that returns whether a variable in the current dataset is an alias for a variable in another frame.
- The Frame class has a new function, isAlias(int var), that returns whether a variable in the current dataset is an alias for a variable in another frame.
- The matlist command has two new options for customizing the display of matrices. The rightindent option indents data by one space relative to the end of row lines. The rowtitleleft option displays row titles flush left.
- Programmers working with alias variables in frames can take advantage of four new macro functions:
- isalias varname returns 1 for an alias variable and 0 otherwise.
- aliasframe varname returns the name of a frame that varname is linked to.
- aliaslinkname varname returns the name of the linking variable that was used to create varname.
- aliasvarname varname returns the name of the variable that varname is linked to.
Mata
- The Mata xl() class includes seven new member functions:
- put_string() writes a string scalar, vector, or matrix to a Microsoft Excel worksheet.
- set_header() adds a worksheet header to the active worksheet.
- set_footer() adds a worksheet footer to the active worksheet.
- insert_horizontal_page_break() inserts a page break at the specified row in the active worksheet.
- delete_horizontal_page_break() deletes a page break at the specified row in the active worksheet.
- insert_vertical_page_break() inserts a page break at the specified column in the active worksheet.
- delete_vertical_page_break() deletes a page break at the specified column in the active worksheet.
Interface
- jdbc load now has a dialog that allows you to
- add or remove data source names (DSNs),
- filter tables of a DSN or filter columns of a table, and
- select which columns of a table to load into Stata.
- When you run multiple instances of Stata in Windows, the Stata instance number will now appear on the following top-level windows: Do-File Editor, Data Editor, Variables Manager, SEM Builder, Graph windows, and Viewer windows.
- In Windows, the new set taskbargroups setting affects how Stata windows are grouped on the taskbar. If taskbar grouping is enabled, different instances of Stata will be grouped separately on the taskbar. This setting is enabled by default.
- Stata for Mac now prompts you for your preferred window layout when it is first launched. You can choose the Sidebar layout, which may be preferable for small laptop displays, or the Widescreen layout, which may be preferable for desktop monitors or large laptop displays.
Even more
- Here we’ve told you about many of the new features in Stata 18 that were not highlighted at stata.com/new-in-stata. Yet there is still more. See the What’s new for a complete list of updates.