*! version 0.31

Title

regmat -- generating matrix of regression estimates for
observational studies

Syntax

regmat [using],
outcomes(varlist)
exposures(varlist)
[adjustements(varlist strings)
noquietly
labels
base
keep(string)
drop(string)
Matprint options] , regression template

stregmat [using],
exposures(varlist)
[adjustements(varlist strings)
noquietly
labels
base
keep(string)
drop(string)
Matprint options] , regression template

Main options
outcomes(varlist) Not for stregmat.
A non-empty varlist of outcome variables.
An outcome is the dependent variable in a regression.

exposures(varlist) A non-empty varlist of outcome variables.
Exposures are variables of whiech estimates are to be reported.

adjustments(string) A set of varlist strings.

A varlist string is a possibly empty set of adjustment variables.

Each varlist string is surrounded in text quotes (").

An empty string ("") means no adjustment.

Adjustment variables are variables needed for the estimation of the exposures,
but it is not necessary to report their estimates.

noquietly If set, regression outputs are printed in the log.

labels Use variable and value labels.

base Include base values at factor variables.

keep To style output choose which calculations to keep.

Choices are: b(=estimate of exposure in regression), se(=Se(estimate)),
ci(=Confidence interval - level is set with set level),
and p (= P-value).

drop To style output choose which calculations to drop.

Choices are: b(=estimate of exposure in regression), se(=Se(estimate)),
ci(=Confidence interval - level is set with set level),
and p (= P-value).

eform Exponentialise table contents.

btext(string) Alternative text for b (estimate) in output table.

names(string) Alternative list of adjustment names in quotes
separated by commas.

Matprint options
style(string) Style for output. One of the values smcl (default),
csv (semicolon separated style),
latex or tex (latex style),
html (html style) and
md (markdown style, experimental)
.

decimals(string) Matrix of integers specifying numbers of
decimals at cell level. If the matrix is smaller than the data matrix the right
most column is copied to get the same number of columns.
And likewise for the bottom row.

title(string) Title/caption for the matrix output.

top(string) String containing text prior to table content.
Default is dependent of the value of the style option.

undertop(string) String containing text between header and table
content.
Default is dependent of the value of the style option.

bottom(string) String containing text after to table content.
Default is dependent of the value of the style option.

replace Delete an existing using file before adding table.

noeqstrip Do not remove duplicate successive roweq or coleq values

nozero Do not show zeros in output

version 13 and up
toxl(string) A string containing up to 5 values separated
by a comma. The values are:

* path and filename on the excel book to save in. Excel book suffix is set/reset to xls for Stata 13 and to xlsx for Stata 14 and above

* the sheet name to save output in

* (Optional) replace - replace/overwrite the content in the sheet

* (Optional) row, column numbers for the upper right corner of the table in the sheet

* (Optional) columnn widths in parentheses. If more columns than widths the last column width is used for the rest

todocx(string) A string containing one or two values separated
by a comma. The values are:

* path and filename on the excel book to save in.

* (Optional) replace - replace/overwrite the content in the sheet

Description

regmat and stregmat are prefix commands to a regression template.

A regression template is simply a regression command.

Each combination of one outcome variable (regmat only), one exposure
variable and one adjustment set is inserted just after the regression command.

Then all regression estimates of exposures are placed in a matrix ordered by
outcome (regmat only) and exposure variables rowwise and adjustment columnwise.

The resulting matrix is saved in the return list for further
usage.

The matprint options makes it easy to integrate the
result table into a log2markup output file.

Together with the basetable the command regmat
generates the two typical tables for reporting epidemiological research.

regmat example

Get example data:

`"sysuse nlsw88.dta, clear"'

To estimate the effect of being married and having a college grade on
wages and working hours, wage is primary outcome and
hours is secondary outcome. Both are assumed continuous.

The variables married and collgrad are the two exposures whos effect
are to be estimated.

We want crude estimates ("") and adjusted for age and race ("age i.race").

In the regression we use the option vce(robust).

`"regmat, outcome(wage hours) exposure(i.married i.collgrad) adjustment("" "age i.race") names("crude", "adjusted") btext(mean diff): regress, vce(robust)"'

The output from regmat can easily be exported to Excel using
option toxl.

Here the output is saved in sheet "tbl" at the Excel workbook "tbls.xls(x)"
in current directory:

`"regmat, outcome(wage hours) exposure(i.married i.collgrad) adjustment("" "age i.race") names("crude", "adjusted") btext(mean diff) toxl(tbls, tbl): regress, vce(robust)"'

To see current directory:

cd

To see the Excel workbook (stata 13):

shell tbls.xls

To see the Excel workbook (stata 14 and up):

shell tbls.xlsx

The output from regmat can easily be exported to Word using
option todocs.

Here the output is saved in sheet "tbl" in a new Word file "tbl1.docx"
in current directory (One can not add several tables to the same Word file):

`"regmat, outcome(wage hours) exposure(i.married i.collgrad) adjustment("" "age i.race") names("crude", "adjusted") btext(mean diff) todocx(tbl1, replace) title(comment text): regress, vce(robust)"'

To see the Word docx-file:

shell tbl1.docx

stregmat example

Get example data:

`"webuse hypoxia, clear"'

Declare data to be survival-time data and declare the failure event of
interest, that is, the event to be modeled

`"stset dftime, failure(failtype==1)"'

Estimate the crude and adjusted (age and hgb) effects of
hp5 and and ifp in a competing-risks model with failtype==2 as the
competing event

`"stregmat,exposures(hp5 ifp) adjustments("" "age hgb") eform btext(HzRR) names("crude", "adjusted"): stcrreg, compete(failtype==2)"'

A summary of mixed time-to-event analysis:

`"webuse catheter"'

`"stregmat, e(age female) noc: mestreg || patient:, distribution(weibull)"'

Stored results

regmat stores the following in r():

locals

r(Adjustment_#) Adjustment number #.

Matrix

r(regmat) The matrix containing regression estimates of the
exposures

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com