# What is -regmat-

regmat is prefix command to a regression template. A regression template is simply a regression command. Each combination of one outcome variable, 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 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. The resulting tables are easy to integrate into the final text using eg. log2markup output file or -putexcel-.

-regmat- is a part of the package matrixtools.

## Syntax

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

## Options

• outcomes(varlist): 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).

To see -matprint- options

## Stored results

-regmat- stores the following in r():

local

Matrix

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

## Versions

-regmat- is tested in version 12.1 ic, 13.1 ic, 14.2 ic, and 15.1 ic.

## Installation

To install use the command: ssc install matrixtools

# A demonstration of -regmat-

## Background

The data is from Hosmer and Lemeshow, Applied logistic regression, 1989 and the description from Rachel MacKay Altman's old homepage

Low birth weight is an outcome that has been of concern to physicians for years.

This is due to the fact that infant mortality rates and birth defect rates are very high for low birth weight babies.

A woman's behaviour during pregnancy (including diet, smoking habits, and receiving prenatal care) can greatly alter the chances of carrying the baby to term and, consequently, of delivering a baby of normal birth weight.

The goal of this study was to identify risk factors associated with giving birth to a low birth weight baby (weighing less than 2500 grams).

Data were collected on 189 women, 59 of whom had low birth weight babies and 130 of whom had normal birth weight babies.

The observed predictor variables have been shown to be associated with low birth weight in the obstetrical literature.

The goal of the current study was to ascertain if these variables were important in the population being served by the medical centre where the data were collected.

## The dataset

webuse lbw, clear

rename low bwlt2500
generate bwlt1500 = bwt < 1500 if !missing(bwt)
label variable bwlt1500 "birthweight < 1500g"
label define no_yes 0 "No" 1 "Yes"
label values bwlt* no_yes


## The Analysis

Crude estimates as well as estimates adjusted for ftv and ptl of the effect of smoke and age on the two outcomes bwlt2500 and bwlt1500 is presented below.

Note that the same type of regression (template: logit, vce(robust) or) is used.

regmat, outcome(bwlt2500 bwlt1500) exposure(i.smoke age) ///
adjustments("" "ftv i.ptl"): logit, vce(robust) or


--------------------------------------------------------------------------------------------------------------------------------------
b  se(b)  Lower 95% CI  Upper 95% CI  P value             b  se(b)  Lower 95% CI  Upper 95% CI  P value
--------------------------------------------------------------------------------------------------------------------------------------
bwlt2500  smoke(1)          2.02   1.38          1.08          3.79     0.03          1.76   1.41          0.90          3.43     0.10
age               0.95   1.03          0.90          1.01     0.08          0.93   1.04          0.87          1.00     0.05
bwlt1500  smoke(1)          1.04   2.53          0.17          6.39     0.97          0.68   2.77          0.09          5.04     0.71
age               1.16   1.05          1.05          1.27     0.00          1.19   1.06          1.05          1.35     0.00
--------------------------------------------------------------------------------------------------------------------------------------


The return list contains the adjustments and the estimates in a matrix.

return list


macros:

matrices:
r(regmat) :  4 x 10


The estimates in the matrix looks like:

matprint r(regmat), decimals(3)


--------------------------------------------------------------------------------------------------------------------------------------
b  se(b)  Lower 95% CI  Upper 95% CI  P value             b  se(b)  Lower 95% CI  Upper 95% CI  P value
--------------------------------------------------------------------------------------------------------------------------------------
bwlt2500  smoke(1)         2.022  1.378         1.079         3.789    0.028         1.761  1.405         0.904         3.430    0.096
age              0.950  1.030         0.897         1.006    0.079         0.932  1.036         0.869         0.998    0.045
bwlt1500  smoke(1)         1.037  2.529         0.168         6.390    0.969         0.682  2.775         0.092         5.041    0.708
age              1.157  1.049         1.054         1.270    0.002         1.191  1.064         1.055         1.346    0.005
--------------------------------------------------------------------------------------------------------------------------------------


If options labels and base are added:

regmat, outcome(bwlt2500 bwlt1500) exposure(i.smoke age) ///
adjustments("" "ftv i.ptl") labels base: logit, vce(robust) or


--------------------------------------------------------------------------------------------------------------------------------------------------------------------
b  se(b)  Lower 95% CI  Upper 95% CI  P value             b  se(b)  Lower 95% CI  Upper 95% CI  P value
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
birthweight<2500g    smoked during pregnancy (0)          1.00   1.00          1.00          1.00                   1.00   1.00          1.00          1.00
smoked during pregnancy (1)          2.02   1.38          1.08          3.79     0.03          1.76   1.41          0.90          3.43     0.10
age of mother                        0.95   1.03          0.90          1.01     0.08          0.93   1.04          0.87          1.00     0.05
birthweight < 1500g  smoked during pregnancy (0)          1.00   1.00          1.00          1.00                   1.00   1.00          1.00          1.00
smoked during pregnancy (1)          1.04   2.53          0.17          6.39     0.97          0.68   2.77          0.09          5.04     0.71
age of mother                        1.16   1.05          1.05          1.27     0.00          1.19   1.06          1.05          1.35     0.00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------


The variable smoke has no value label:

metadata


--------------------------------------------------------------------------------------------------------------------------------------------------
Name      Index  Label                                               Value Label Name  Format  Value Label Values               n  unique  missing
--------------------------------------------------------------------------------------------------------------------------------------------------
id            1  identification code                                                   %8.0g                                  189     189        0
bwlt2500      2  birthweight<2500g                                   no_yes            %8.0g   0 "No" 1 "Yes"                 189       2        0
age           3  age of mother                                                         %8.0g                                  189      24        0
lwt           4  weight at last menstrual period                                       %8.0g                                  189      76        0
race          5  race                                                race              %8.0g   1 "white" 2 "black" 3 "other"  189       3        0
smoke         6  smoked during pregnancy                                               %8.0g                                  189       2        0
ptl           7  premature labor history (count)                                       %8.0g                                  189       4        0
ht            8  has history of hypertension                                           %8.0g                                  189       2        0
ui            9  presence, uterine irritability                                        %8.0g                                  189       2        0
ftv          10  number of visits to physician during 1st trimester                    %8.0g                                  189       6        0
bwt          11  birthweight (grams)                                                   %8.0g                                  189     133        0
bwlt1500     12  birthweight < 1500g                                 no_yes            %10.0g  0 "No" 1 "Yes"                 189       2        0
--------------------------------------------------------------------------------------------------------------------------------------------------


By adding value labels to smoke and roping se and pvalue the returned matrix becomes nicer to look at:

label values smoke no_yes
regmat, outcome(bwlt2500 bwlt1500) exposure(i.smoke age) ///
adjustments("" "ftv i.ptl") labels base drop(se p): logit, vce(robust) or


--------------------------------------------------------------------------------------------------------------------------------------
b  Lower 95% CI  Upper 95% CI             b  Lower 95% CI  Upper 95% CI
--------------------------------------------------------------------------------------------------------------------------------------
birthweight<2500g    smoked during pregnancy (No)           1.00          1.00          1.00          1.00          1.00          1.00
smoked during pregnancy (Yes)          2.02          1.08          3.79          1.76          0.90          3.43
age of mother                          0.95          0.90          1.01          0.93          0.87          1.00
birthweight < 1500g  smoked during pregnancy (No)           1.00          1.00          1.00          1.00          1.00          1.00
smoked during pregnancy (Yes)          1.04          0.17          6.39          0.68          0.09          5.04
age of mother                          1.16          1.05          1.27          1.19          1.05          1.35
--------------------------------------------------------------------------------------------------------------------------------------


The do file for this document

Last update: 2018-10-11, Stata version 15.1