This document contains the summaries of the regression analyses with smoking status as the outcome and all covariates included. We provide the code used to generate this table, which calls upon our analysis summary objects (also provided).

Main Effects

BASEII
EAS
ELSA
HRS
ILSE
LBLS
LBC
MAP
MAS
MIDUS
NAS
OATS
ROS
SLS
WLS
Term Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p
Intercept 0.77 0.05 2.15 14.04 < .001 0.73 0.08 2.08 9.01 < .001 2.89 0.05 17.92 58.05 < .001 2.88 0.03 17.73 85.28 < .001 0.01 0.09 1.01 0.12 .901 0.78 0.07 2.18 11.17 < .001 -0.27 0.07 0.76 -3.81 < .001 1.93 0.1 6.90 19.95 < .001 1.64 0.09 5.16 17.84 < .001 3.65 0.1 38.67 35.95 < .001 0.31 0.07 1.36 4.22 < .001 2.11 0.16 8.28 13.37 < .001 1.34 0.07 3.84 20.24 < .001 1.89 0.09 6.63 21.65 < .001 2.79 0.04 16.30 65.38 < .001
Neur -0.13 0.06 0.88 -2.36 .018 0.15 0.09 1.16 1.63 .103 0.00 0.05 1.00 -0.05 .959 -0.11 0.03 0.90 -3.45 .001 -0.33 0.10 0.72 -3.27 .001 -0.01 0.08 0.99 -0.12 .903 -0.18 0.07 0.83 -2.64 .008 0.02 0.1 1.02 0.21 .831 0.13 0.10 1.14 1.27 .202 0.09 0.1 1.09 0.86 .392 0.03 0.08 1.03 0.42 .675 0.20 0.18 1.23 1.14 .254 -0.03 0.07 0.97 -0.40 .691 -0.09 0.10 0.91 -0.97 .332 -0.24 0.04 0.79 -5.65 < .001
Con 0.06 0.05 1.06 1.11 .269 0.38 0.09 1.46 4.13 < .001 0.52 0.04 1.69 12.58 < .001 0.53 0.03 1.70 19.19 < .001 -0.19 0.10 0.83 -1.92 .055 0.10 0.08 1.10 1.26 .208 0.33 0.07 1.40 4.95 < .001 0.22 0.1 1.24 2.11 .035 0.19 0.10 1.20 1.88 .061 0.17 0.1 1.19 1.78 .076 0.07 0.08 1.07 0.90 .366 0.09 0.17 1.09 0.51 .608 0.15 0.07 1.16 2.21 .027 0.19 0.10 1.21 1.93 .053 0.21 0.04 1.23 5.05 < .001
N 1564.00 727.00 8832.00 19238.00 477.00 951.00 895.00 981.00 879.00 3989.00 756.00 422.00 1394.00 1176.00 10587.00

Interaction, no covariates

BASEII
EAS
ELSA
HRS
ILSE
LBLS
LBC
MAP
MAS
MIDUS
NAS
OATS
ROS
SLS
WLS
Term Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p
Intercept 0.77 0.06 2.16 14.04 < .001 0.74 0.09 2.09 8.55 < .001 2.89 0.05 18.06 57.81 < .001 2.88 0.03 17.79 85.04 < .001 0.01 0.10 1.01 0.08 .936 0.80 0.07 2.24 10.84 < .001 -0.29 0.07 0.75 -4.05 < .001 1.96 0.10 7.11 18.93 < .001 1.58 0.10 4.85 15.85 < .001 3.68 0.10 39.57 35.12 < .001 0.37 0.08 1.45 4.64 < .001 2.14 0.17 8.48 12.70 < .001 1.35 0.07 3.86 19.71 < .001 1.88 0.09 6.58 20.45 < .001 2.79 0.04 16.33 64.43 < .001
Neur -0.13 0.06 0.87 -2.43 .015 0.14 0.09 1.15 1.59 .112 0.03 0.05 1.03 0.49 .622 -0.09 0.03 0.91 -2.65 .008 -0.33 0.10 0.72 -3.24 .001 -0.01 0.08 0.99 -0.11 .916 -0.17 0.07 0.84 -2.45 .014 0.03 0.11 1.03 0.30 .761 0.15 0.10 1.16 1.47 .140 0.11 0.11 1.11 1.01 .313 -0.01 0.08 0.99 -0.12 .903 0.21 0.18 1.24 1.18 .238 -0.02 0.07 0.98 -0.35 .726 -0.10 0.10 0.91 -1.00 .315 -0.24 0.04 0.79 -5.57 < .001
Con 0.05 0.06 1.05 0.93 .352 0.37 0.09 1.45 4.00 < .001 0.51 0.04 1.67 12.04 < .001 0.52 0.03 1.69 18.36 < .001 -0.19 0.10 0.83 -1.91 .056 0.08 0.08 1.08 1.06 .291 0.31 0.07 1.36 4.48 < .001 0.21 0.10 1.23 2.02 .043 0.13 0.11 1.13 1.19 .234 0.16 0.10 1.17 1.59 .112 0.06 0.08 1.06 0.75 .456 0.08 0.17 1.09 0.50 .617 0.15 0.07 1.16 2.19 .029 0.19 0.10 1.21 1.95 .051 0.20 0.04 1.23 4.81 < .001
Neur x con 0.05 0.05 1.05 0.96 .336 -0.02 0.08 0.98 -0.24 .809 0.04 0.03 1.05 1.29 .197 0.03 0.02 1.03 1.07 .285 -0.01 0.09 0.99 -0.13 .893 0.06 0.06 1.06 0.98 .326 -0.09 0.05 0.91 -1.72 .086 0.07 0.09 1.08 0.86 .387 -0.18 0.12 0.84 -1.47 .143 0.09 0.08 1.10 1.14 .256 0.16 0.08 1.17 2.00 .046 0.06 0.12 1.06 0.45 .651 0.02 0.05 1.02 0.35 .729 -0.02 0.07 0.98 -0.28 .780 0.01 0.04 1.01 0.25 .805
N 1564.00 727.00 8832.00 19238.00 477.00 951.00 895.00 981.00 879.00 3989.00 756.00 422.00 1394.00 1176.00 10587.00

Interaction, demographics

BASEII
EAS
ELSA
HRS
ILSE
LBLS
LBC
MAP
MAS
MIDUS
NAS
OATS
ROS
SLS
WLS
Term Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p
Intercept 0.59 0.09 1.80 6.90 < .001 2.19 0.48 8.96 4.53 < .001 3.86 0.12 47.68 31.64 < .001 4.05 0.08 57.12 49.86 < .001 -2.79 1.25 0.06 -2.23 .026 0.92 1.65 2.51 0.56 .577 0.31 0.15 1.36 2.00 .045 2.39 0.49 10.86 4.87 < .001 3.43 0.60 30.95 5.76 < .001 4.48 0.21 88.39 21.22 < .001 0.51 0.17 1.67 3.04 .002 0.61 0.86 1.84 0.71 .478 2.06 0.27 7.81 7.67 < .001 2.17 0.18 8.72 12.04 < .001 2.97 0.07 19.56 39.79 < .001
Age -0.07 0.06 0.93 -1.20 .229 -0.19 0.08 0.83 -2.28 .022 -0.47 0.05 0.62 -10.29 < .001 -0.71 0.03 0.49 -21.87 < .001 0.23 0.10 1.26 2.44 .015 0.00 0.07 1.00 0.02 .984 -0.22 0.08 0.80 -2.89 .004 -0.01 0.10 0.99 -0.07 .944 -0.34 0.09 0.71 -3.59 < .001 -0.59 0.11 0.55 -5.38 < .001 -0.07 0.08 0.93 -0.94 .348 0.42 0.22 1.52 1.93 .053 -0.11 0.07 0.89 -1.68 .092 -0.04 0.09 0.96 -0.45 .651 -0.09 0.04 0.91 -2.32 .021
Gender 0.48 0.11 1.62 4.26 < .001 -0.65 0.17 0.52 -3.69 < .001 0.08 0.10 1.08 0.81 .420 0.22 0.06 1.25 3.48 .001 -0.47 0.20 0.63 -2.30 .022 -0.10 0.14 0.91 -0.69 .492 -0.57 0.14 0.57 -3.96 < .001 -0.41 0.26 0.67 -1.58 .113 0.59 0.20 1.81 3.01 .003 -0.17 0.21 0.84 -0.83 .409 0.23 0.34 1.26 0.67 .504 -0.40 0.16 0.67 -2.55 .011 -0.17 0.18 0.84 -0.94 .349 -0.06 0.08 0.94 -0.74 .460
Edu 0.05 0.06 1.05 0.85 .397 0.15 0.08 1.16 1.76 .078 0.39 0.05 1.47 7.72 < .001 0.23 0.03 1.26 8.29 < .001 0.23 0.10 1.26 2.30 .022 0.05 0.07 1.05 0.71 .478 0.10 0.08 1.10 1.27 .202 0.43 0.11 1.54 4.00 < .001 0.26 0.10 1.30 2.51 .012 0.65 0.12 1.92 5.48 < .001 0.03 0.08 1.03 0.39 .698 -0.52 0.16 0.59 -3.35 .001 0.15 0.07 1.17 2.30 .021 0.58 0.10 1.78 5.90 < .001 0.39 0.05 1.48 7.87 < .001
Neur -0.19 0.06 0.83 -3.28 .001 0.07 0.09 1.08 0.80 .423 -0.07 0.05 0.93 -1.30 .194 -0.19 0.03 0.83 -5.31 < .001 -0.34 0.11 0.71 -3.13 .002 0.01 0.08 1.01 0.12 .906 -0.17 0.07 0.84 -2.32 .020 0.15 0.11 1.16 1.33 .182 0.11 0.10 1.11 1.03 .303 0.06 0.11 1.06 0.54 .586 -0.02 0.08 0.98 -0.20 .838 0.06 0.18 1.07 0.34 .730 0.02 0.07 1.02 0.21 .833 -0.04 0.10 0.96 -0.35 .726 -0.18 0.04 0.83 -4.26 < .001
Con 0.03 0.06 1.03 0.52 .606 0.41 0.10 1.51 4.26 < .001 0.36 0.04 1.44 8.17 < .001 0.39 0.03 1.48 13.12 < .001 -0.15 0.10 0.86 -1.54 .124 0.09 0.08 1.10 1.19 .234 0.32 0.07 1.38 4.59 < .001 0.23 0.11 1.26 2.17 .030 0.08 0.11 1.08 0.70 .483 0.08 0.10 1.09 0.82 .411 0.05 0.08 1.05 0.58 .560 0.10 0.17 1.11 0.60 .550 0.18 0.07 1.20 2.49 .013 0.19 0.10 1.21 1.86 .062 0.22 0.04 1.24 5.10 < .001
Neur x con 0.05 0.05 1.06 1.04 .299 -0.05 0.08 0.95 -0.65 .514 0.06 0.04 1.07 1.81 .071 0.05 0.02 1.06 2.20 .028 0.00 0.09 1.00 -0.02 .984 0.06 0.06 1.06 1.00 .318 -0.08 0.05 0.92 -1.55 .122 0.08 0.09 1.09 0.95 .343 -0.14 0.12 0.87 -1.16 .247 0.10 0.08 1.11 1.22 .222 0.15 0.08 1.17 1.94 .053 0.03 0.13 1.03 0.25 .804 0.04 0.05 1.04 0.67 .503 0.01 0.07 1.01 0.08 .938 0.01 0.04 1.01 0.22 .825
N 1564.00 727.00 8832.00 19238.00 477.00 951.00 895.00 981.00 879.00 3989.00 756.00 422.00 1394.00 1176.00 10587.00

Interaction, all covariates

BASEII
EAS
ELSA
HRS
ILSE
LBLS
LBC
MAP
MAS
MIDUS
NAS
OATS
ROS
SLS
WLS
Term Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p Est SE OR t value p
Intercept 0.60 0.09 1.82 6.94 < .001 2.13 0.49 8.43 4.34 < .001 3.93 0.12 51.00 31.74 < .001 4.08 0.08 59.39 49.48 < .001 -2.71 1.27 0.07 -2.14 .033 1.62 1.70 5.03 0.95 .342 0.29 0.16 1.34 1.87 .062 2.12 0.57 8.32 3.73 < .001 3.35 0.60 28.55 5.60 < .001 4.45 0.21 85.93 20.76 < .001 0.47 0.17 1.60 2.79 .005 1.04 0.89 2.84 1.17 .243 2.00 0.27 7.41 7.44 < .001 2.26 0.19 9.54 11.82 < .001 3.05 0.08 21.16 39.50 < .001
Age -0.06 0.06 0.94 -1.14 .254 -0.18 0.08 0.84 -2.13 .033 -0.46 0.05 0.63 -10.07 < .001 -0.71 0.03 0.49 -21.83 < .001 0.23 0.10 1.25 2.31 .021 -0.01 0.07 0.99 -0.21 .836 -0.20 0.08 0.82 -2.57 .010 0.00 0.12 1.00 -0.03 .977 -0.32 0.09 0.73 -3.38 .001 -0.58 0.11 0.56 -5.23 < .001 -0.05 0.08 0.95 -0.68 .495 0.34 0.22 1.40 1.54 .125 -0.08 0.07 0.93 -1.13 .259 0.01 0.09 1.01 0.14 .888 -0.09 0.04 0.92 -2.20 .028
Gender 0.47 0.12 1.59 4.00 < .001 -0.64 0.18 0.53 -3.58 < .001 0.02 0.10 1.02 0.24 .812 0.23 0.07 1.26 3.51 < .001 -0.39 0.21 0.68 -1.81 .071 -0.28 0.16 0.76 -1.72 .086 -0.51 0.15 0.60 -3.50 < .001 -0.23 0.28 0.80 -0.79 .428 0.63 0.20 1.87 3.16 .002 -0.09 0.22 0.92 -0.39 .694 0.13 0.37 1.14 0.34 .731 -0.48 0.16 0.62 -2.96 .003 -0.34 0.19 0.71 -1.75 .079 -0.14 0.09 0.87 -1.62 .104
Edu 0.05 0.06 1.06 0.96 .338 0.15 0.10 1.16 1.53 .127 0.42 0.05 1.52 8.05 < .001 0.27 0.03 1.31 9.32 < .001 0.13 0.11 1.14 1.20 .228 0.05 0.08 1.05 0.66 .512 0.10 0.08 1.10 1.25 .213 0.47 0.13 1.59 3.65 < .001 0.20 0.11 1.23 1.89 .059 0.62 0.12 1.85 5.01 < .001 0.03 0.08 1.03 0.43 .666 -0.57 0.17 0.57 -3.33 .001 0.10 0.07 1.10 1.39 .165 0.49 0.10 1.64 4.77 < .001 0.37 0.05 1.44 6.92 < .001
Agree -0.02 0.06 0.98 -0.36 .717 -0.06 0.10 0.94 -0.61 .545 -0.11 0.06 0.90 -1.88 .060 -0.15 0.04 0.86 -3.97 < .001 0.04 0.11 1.04 0.35 .728 0.00 0.08 1.00 0.04 .966 0.15 0.09 1.16 1.69 .092 -0.13 0.14 0.87 -0.96 .335 -0.22 0.11 0.80 -1.99 .047 0.10 0.19 1.10 0.51 .611 -0.06 0.08 0.94 -0.78 .435 0.12 0.10 1.12 1.20 .230 0.07 0.05 1.07 1.43 .154
Extra 0.11 0.06 1.11 1.75 .079 0.10 0.09 1.10 1.06 .289 0.48 0.06 1.62 7.69 < .001 0.44 0.04 1.55 10.69 < .001 -0.25 0.11 0.78 -2.17 .030 0.42 0.08 1.53 5.07 < .001 0.00 0.08 1.00 0.01 .991 0.30 0.12 1.35 2.52 .012 -0.19 0.14 0.83 -1.38 .168 0.09 0.10 1.09 0.93 .354 -0.54 0.22 0.58 -2.48 .013 0.14 0.07 1.15 1.96 .049 0.24 0.11 1.28 2.29 .022 0.26 0.05 1.29 5.65 < .001
Open -0.03 0.06 0.97 -0.45 .652 0.01 0.10 1.01 0.09 .928 -0.25 0.06 0.78 -4.03 < .001 -0.17 0.04 0.84 -4.25 < .001 0.36 0.11 1.44 3.40 .001 0.18 0.08 1.20 2.38 .017 -0.09 0.08 0.91 -1.07 .285 -0.27 0.12 0.76 -2.30 .022 0.12 0.13 1.13 0.98 .328 0.14 0.10 1.15 1.37 .172 0.12 0.18 1.13 0.69 .493 0.18 0.07 1.20 2.45 .014 0.23 0.11 1.26 2.13 .033 0.10 0.05 1.10 2.07 .038
Neur -0.17 0.06 0.84 -2.98 .003 0.07 0.10 1.08 0.72 .469 -0.02 0.05 0.98 -0.37 .710 -0.14 0.04 0.87 -3.89 < .001 -0.40 0.12 0.67 -3.37 .001 0.18 0.09 1.20 2.03 .042 -0.25 0.09 0.78 -2.95 .003 0.19 0.13 1.21 1.49 .136 0.18 0.11 1.20 1.67 .095 0.03 0.11 1.03 0.29 .775 -0.05 0.09 0.95 -0.56 .576 -0.08 0.21 0.93 -0.37 .714 0.06 0.08 1.07 0.82 .413 0.08 0.11 1.09 0.73 .466 -0.10 0.05 0.90 -2.17 .030
Con 0.02 0.06 1.02 0.33 .739 0.39 0.10 1.48 3.91 < .001 0.30 0.05 1.35 5.41 < .001 0.36 0.04 1.43 9.99 < .001 -0.16 0.11 0.85 -1.51 .131 0.02 0.08 1.02 0.26 .797 0.35 0.08 1.42 4.54 < .001 0.20 0.13 1.22 1.54 .125 -0.01 0.12 0.99 -0.06 .954 0.14 0.11 1.15 1.25 .211 0.08 0.11 1.09 0.75 .450 0.19 0.18 1.21 1.05 .294 0.18 0.07 1.19 2.35 .019 0.18 0.11 1.19 1.65 .099 0.15 0.05 1.17 3.39 .001
Neur x con 0.05 0.05 1.06 1.03 .304 -0.05 0.08 0.95 -0.66 .508 0.07 0.04 1.07 1.97 .048 0.05 0.02 1.06 2.17 .030 0.01 0.09 1.01 0.07 .946 0.09 0.06 1.10 1.49 .136 -0.10 0.05 0.91 -1.79 .074 0.06 0.10 1.06 0.57 .568 -0.07 0.13 0.93 -0.58 .560 0.10 0.08 1.10 1.16 .248 0.16 0.08 1.17 1.95 .051 0.05 0.13 1.05 0.36 .722 0.04 0.05 1.04 0.73 .465 0.02 0.08 1.02 0.31 .755 0.01 0.04 1.01 0.38 .707
N 1564.00 727.00 8817.00 19207.00 477.00 951.00 895.00 653.00 879.00 3987.00 756.00 422.00 1394.00 1176.00 10562.00

Code

Preparation

The following packages were used to generate this table:

library(papaja)
library(tidyverse)
library(tools)
library(psych)
library(knitr)
library(kableExtra)
library(here)

The files needed for this table are available at osf.io/mzfu9 in the Individual Study Output folder.

First we load the individual study analysis objects.

study.names = c("BASEII", "EAS","ELSA", "HRS", "ILSE", "LBC",
                "LBLS", "MAP", "MAS","MIDUS","NAS", "OATS", 
                "ROS","SLS","WLS")

lapply(here(paste0("behavior/", study.names, "_behavior.Rdata")), load, .GlobalEnv)

Then we identify which studies have physical activity as an outcome.

#identify which studies have active outcome
active.names = lapply(paste0(study.names,"_behavior"), 
                      FUN = function(x) rownames(get(x)$descriptives))
active.names = sapply(active.names, FUN = function(x) "active" %in% x)
active.names = study.names[active.names]
columns = unite(
  expand.grid(stat = c("estimate", "std.error", "OR", "statistic", "p.value"),
              study = active.names),
  columns, study, stat, sep="_")$columns
header = c(" " = 1, "BASEII" = 5, "EAS" = 5, "ELSA" = 5, "HRS" = 5, "ILSE" = 5, 
           "LBLS" = 5, "LBC" = 5, "MAP" = 5, "MAS" = 5, "MIDUS" = 5, "NAS" = 5, "OATS" = 5,  
           "ROS" = 5, "SLS" = 5, "WLS" = 5)

Main Effects

#sample size
active.n = data.frame(study = active.names, 
                      term = "N", estimate = 
                        sapply(X = active.names, FUN = function(x)
                          get(paste0(x,"_behavior"))$regression$main$active$n)) %>%
  mutate(study = paste0(study, "_estimate")) %>%
  spread(key = "study", value = "estimate")

lapply(X = active.names, FUN = function(x) get(paste0(x,"_behavior"))$regression$main$active$coef) %>%
  map2_df(., active.names, ~ mutate(.x, study = .y)) %>%
  mutate(OR = exp(estimate)) %>%
  gather(key = "key", value = "value", -study, -term) %>%
  unite(study_stat, study, key, sep="_") %>%
  filter(!is.infinite(value)) %>%
  spread(key = "study_stat", value = "value") %>%
  gather(key = "key", value = "value", which(grepl("p", names(.)))) %>%
  mutate(sig = value, 
    value = printp(value),
    value = cell_spec(value, "html", 
                      color = ifelse(sig >= .05 | is.na(sig), 
                                     "black", "red"))) %>%
    filter(!grepl("NA", value))%>%
    dplyr::select(-sig) %>%
    spread(key = "key", value = "value") %>%
    full_join(active.n) %>%
    mutate(term = gsub("\\(", "", term), 
           term = gsub("\\)", "", term),
           term = toTitleCase(term),
           term = gsub("\\:", " x ", term), 
          term = factor(term, 
                         levels = c("Intercept", "Age", "Gender", "Edu", "Agree", "Extra", "Open", 
                                    "Neur", "Con", "Neur x con", "N"))) %>%
    arrange(term) %>%
    dplyr::select(term, columns) %>%
    kable(.,  booktabs = T, escape = F, digits = 2, format = "html", 
          align=c(rep('c',times=ncol(.))),
          col.names = c("Term", rep(c("Est","SE","OR", "t value", "p"), length(active.names)))) %>%
    kable_styling("bordered", full_width = TRUE) %>%
  add_header_above(header = header) 

Interaction, no covariates

#sample size
active.n = data.frame(study = active.names, 
                      term = "N", estimate = 
                        sapply(X = active.names, FUN = function(x)
                          get(paste0(x,"_behavior"))$regression$intr$active$n)) %>%
  mutate(study = paste0(study, "_estimate")) %>%
  spread(key = "study", value = "estimate")

lapply(X = active.names, FUN = function(x) get(paste0(x,"_behavior"))$regression$intr$active$coef) %>%
  map2_df(., active.names, ~ mutate(.x, study = .y)) %>%
  mutate(OR = exp(estimate)) %>%
  gather(key = "key", value = "value", -study, -term) %>%
  unite(study_stat, study, key, sep="_") %>%
  filter(!is.infinite(value)) %>%
  spread(key = "study_stat", value = "value") %>%
  gather(key = "key", value = "value", which(grepl("p", names(.)))) %>%
  mutate(sig = value, 
    value = printp(value),
    value = cell_spec(value, "html", 
                      color = ifelse(sig >= .05 | is.na(sig), 
                                     "black", "red"))) %>%
    filter(!grepl("NA", value))%>%
    dplyr::select(-sig) %>%
    spread(key = "key", value = "value") %>%
    full_join(active.n) %>%
    mutate(term = gsub("\\(", "", term), 
           term = gsub("\\)", "", term),
           term = toTitleCase(term),
           term = gsub("\\:", " x ", term), 
           term = factor(term, 
                       levels = c("Intercept", "Age", "Gender", "Edu", "Agree", "Extra", "Open", 
                                  "Neur", "Con", "Neur x con", "N"))) %>%
  arrange(term) %>%
  dplyr::select(term, columns) %>%
  kable(.,  booktabs = T, escape = F, digits = 2, format = "html", 
        align=c(rep('c',times=ncol(.))),
        col.names = c("Term", rep(c("Est","SE","OR", "t value", "p"), length(active.names)))) %>%
  kable_styling("bordered", full_width = TRUE) %>%
add_header_above(header = header) 

Interaction, demographics

#sample size
active.n = data.frame(study = active.names, 
                      term = "N", estimate = 
                        sapply(X = active.names, FUN = function(x)
                          get(paste0(x,"_behavior"))$regression$cov1$active$n)) %>%
  mutate(study = paste0(study, "_estimate")) %>%
  spread(key = "study", value = "estimate")

lapply(X = active.names, FUN = function(x) get(paste0(x,"_behavior"))$regression$cov1$active$coef) %>%
  map2_df(., active.names, ~ mutate(.x, study = .y)) %>%
  mutate(OR = exp(estimate)) %>%
  gather(key = "key", value = "value", -study, -term) %>%
  unite(study_stat, study, key, sep="_") %>%
  filter(!is.infinite(value)) %>%
  spread(key = "study_stat", value = "value") %>%
  gather(key = "key", value = "value", which(grepl("p", names(.)))) %>%
  filter(!is.na(value)) %>%
  mutate(sig = value, 
    value = printp(value),
    value = cell_spec(value, "html", 
                      color = ifelse(sig >= .05 | is.na(sig), 
                                     "black", "red"))) %>%
    filter(!grepl("NA", value))%>%
    dplyr::select(-sig) %>%
    spread(key = "key", value = "value") %>%
    full_join(active.n) %>%
    mutate(term = gsub("\\(", "", term), 
           term = gsub("\\)", "", term),
           term = toTitleCase(term),
           term = gsub("\\:", " x ", term), 
           term = factor(term, 
                         levels = c("Intercept", "Age", "Gender", "Edu", "Agree", "Extra", "Open", 
                                    "Neur", "Con", "Neur x con", "N"))) %>%
    arrange(term) %>%
    dplyr::select(term, columns) %>%
    kable(.,  booktabs = T, escape = F, digits = 2, format = "html", 
          align=c(rep('c',times=ncol(.))),
          col.names = c("Term", rep(c("Est","SE","OR", "t value", "p"), length(active.names)))) %>%
    kable_styling("bordered", full_width = TRUE) %>%
  add_header_above(header = header)  

Interaction, all covariates

#sample size
active.n = data.frame(study = active.names, 
                      term = "N", estimate = 
                        sapply(X = active.names, FUN = function(x)
                          get(paste0(x,"_behavior"))$regression$cov2$active$n)) %>%
  mutate(study = paste0(study, "_estimate")) %>%
  spread(key = "study", value = "estimate")

lapply(X = active.names, FUN = function(x) get(paste0(x,"_behavior"))$regression$cov2$active$coef) %>%
  map2_df(., active.names, ~ mutate(.x, study = .y)) %>%
  mutate(OR = exp(estimate)) %>%
  gather(key = "key", value = "value", -study, -term) %>%
  unite(study_stat, study, key, sep="_") %>%
  filter(!is.infinite(value)) %>%
  spread(key = "study_stat", value = "value") %>%
  gather(key = "key", value = "value", which(grepl("p", names(.)))) %>%
  filter(!is.na(value)) %>%
  mutate(sig = value, 
    value = printp(value),
    value = cell_spec(value, "html", 
                      color = ifelse(sig >= .05 | is.na(sig), 
                                     "black", "red"))) %>%
  filter(!grepl("NA", value)) %>%
  dplyr::select(-sig) %>%
  spread(key = "key", value = "value") %>%
  full_join(active.n) %>%
  mutate(term = gsub("\\(", "", term), 
         term = gsub("\\)", "", term),
         term = toTitleCase(term),
         term = gsub("\\:", " x ", term), 
         term = factor(term, 
                       levels = c("Intercept", "Age", "Gender", "Edu", "Agree", "Extra", "Open", 
                                  "Neur", "Con", "Neur x con", "N"))) %>%
  arrange(term) %>%
  dplyr::select(term, columns) %>%
  kable(.,  booktabs = T, escape = F, digits = 2, format = "html", 
        align=c(rep('c',times=ncol(.))),
        col.names = c("Term", rep(c("Est","SE","OR", "t value", "p"), length(active.names)))) %>%
  kable_styling("bordered", full_width = TRUE) %>%
add_header_above(header = header)