eh_test_subtype takes the name of the variable containing the pre-specified subtype labels, the number of subtypes, a list of risk factors, and the name of the dataframe and returns results related to the question of whether each risk factor differs across levels of the disease subtypes. Input is a dataframe that contains the risk factors of interest and a variable containing numeric class labels that is 0 for control subjects. Risk factors can be either binary or continuous. For categorical risk factors, a reference level should be selected and then indicator variables for each remaining level of the risk factor should be created. Categorical risk factors entered as is will be treated as ordinal. The multinomial logistic regression model is fit using mlogit.

eh_test_subtype(label, M, factors, data, digits = 2)

Arguments

label

the name of the subtype variable in the data. This should be a numeric variable with values 0 through M, where 0 indicates control subjects. Must be supplied in quotes, e.g. label = "subtype".

M

is the number of subtypes. For M>=2.

factors

a list of the names of the binary or continuous risk factors. For binary or categorical risk factors the lowest level will be used as the reference level. e.g. factors = list("age", "sex", "race").

data

the name of the dataframe that contains the relevant variables.

digits

the number of digits to round the odds ratios and associated confidence intervals, and the estimates and associated standard errors. Defaults to 2.

Value

Returns a list.

beta is a matrix containing the raw estimates from the polytomous logistic regression model fit with mlogit with a row for each risk factor and a column for each disease subtype.

beta_se is a matrix containing the raw standard errors from the polytomous logistic regression model fit with mlogit with a row for each risk factor and a column for each disease subtype.

eh_pval is a vector of unformatted p-values for testing whether each risk factor differs across the levels of the disease subtype.

or_ci_p is a dataframe with the odds ratio (95% CI) for each risk factor/subtype combination, as well as a column of formatted etiologic heterogeneity p-values.

beta_se_p is a dataframe with the estimates (SE) for each risk factor/subtype combination, as well as a column of formatted etiologic heterogeneity p-values.

var_covar contains the variance-covariance matrix associated with the model estimates contained in beta.

Examples

eh_test_subtype( label = "subtype", M = 4, factors = list("x1", "x2", "x3"), data = subtype_data, digits = 2 )
#> $beta #> 1 2 3 4 #> x1 1.5555082 0.8232515 0.2410591 0.1086845 #> x2 0.3031594 0.4335048 0.3518870 0.3714092 #> x3 0.8000998 1.9909315 3.0115985 1.5594139 #> #> $beta_se #> 1 2 3 4 #> x1 0.08753299 0.07493534 0.07586862 0.06932731 #> x2 0.07838983 0.07322825 0.07596005 0.06978524 #> x3 0.22460699 0.18331057 0.17831011 0.18231380 #> #> $eh_pval #> p_het #> x1 0.0000000 #> x2 0.4778092 #> x3 0.0000000 #> #> $or_ci_p #> 1 2 3 4 #> x1 4.74 (3.99-5.62) 2.28 (1.97-2.64) 1.27 (1.1-1.48) 1.11 (0.97-1.28) #> x2 1.35 (1.16-1.58) 1.54 (1.34-1.78) 1.42 (1.23-1.65) 1.45 (1.26-1.66) #> x3 2.23 (1.43-3.46) 7.32 (5.11-10.49) 20.32 (14.33-28.82) 4.76 (3.33-6.8) #> p_het #> x1 <.001 #> x2 0.478 #> x3 <.001 #> #> $beta_se_p #> 1 2 3 4 p_het #> x1 1.56 (0.09) 0.82 (0.07) 0.24 (0.08) 0.11 (0.07) <.001 #> x2 0.3 (0.08) 0.43 (0.07) 0.35 (0.08) 0.37 (0.07) 0.478 #> x3 0.8 (0.22) 1.99 (0.18) 3.01 (0.18) 1.56 (0.18) <.001 #> #> $var_covar #> 1:(intercept) 2:(intercept) 3:(intercept) 4:(intercept) #> 1:(intercept) 1.583424e-02 0.0020749366 1.538390e-03 1.411022e-03 #> 2:(intercept) 2.074937e-03 0.0098303418 1.611641e-03 1.446205e-03 #> 3:(intercept) 1.538390e-03 0.0016116406 1.125289e-02 1.453280e-03 #> 4:(intercept) 1.411022e-03 0.0014462049 1.453280e-03 6.506720e-03 #> 1:x1 -7.560778e-03 -0.0005440598 -3.413115e-05 3.971430e-05 #> 2:x1 -1.176115e-03 -0.0030930534 -9.883087e-05 2.882341e-05 #> 3:x1 -6.557242e-04 -0.0005967342 -8.074165e-04 9.933156e-06 #> 4:x1 -2.559735e-04 -0.0002209032 -5.969347e-05 -1.497000e-04 #> 1:x2 -1.103647e-03 -0.0002595891 -9.069383e-05 -2.827972e-05 #> 2:x2 -1.745275e-04 -0.0015141079 -2.220558e-04 -9.743127e-05 #> 3:x2 -1.308655e-04 -0.0003206160 -1.403289e-03 -1.854608e-04 #> 4:x2 -3.481221e-05 -0.0001126917 -1.367579e-04 -1.168994e-03 #> 1:x3 -6.968243e-03 -0.0031109990 -2.166244e-03 -1.577317e-03 #> 2:x3 -2.140470e-03 -0.0079890602 -2.028591e-03 -1.582729e-03 #> 3:x3 -1.657044e-03 -0.0017990200 -1.107647e-02 -1.526814e-03 #> 4:x3 -1.542640e-03 -0.0016665523 -1.690220e-03 -6.315218e-03 #> 1:x1 2:x1 3:x1 4:x1 #> 1:(intercept) -7.560778e-03 -1.176115e-03 -6.557242e-04 -2.559735e-04 #> 2:(intercept) -5.440598e-04 -3.093053e-03 -5.967342e-04 -2.209032e-04 #> 3:(intercept) -3.413115e-05 -9.883087e-05 -8.074165e-04 -5.969347e-05 #> 4:(intercept) 3.971430e-05 2.882341e-05 9.933156e-06 -1.497000e-04 #> 1:x1 7.662025e-03 2.723054e-03 1.877348e-03 1.567851e-03 #> 2:x1 2.723054e-03 5.615306e-03 2.092352e-03 1.648672e-03 #> 3:x1 1.877348e-03 2.092352e-03 5.756048e-03 1.819256e-03 #> 4:x1 1.567851e-03 1.648672e-03 1.819256e-03 4.806276e-03 #> 1:x2 2.729980e-04 4.241437e-04 3.340472e-04 3.400662e-04 #> 2:x2 2.034282e-04 2.574290e-04 2.456496e-04 2.415033e-04 #> 3:x2 1.460669e-04 1.657421e-04 2.101845e-04 1.509003e-04 #> 4:x2 1.067297e-04 1.141753e-04 1.108608e-04 2.235015e-04 #> 1:x3 3.114125e-04 1.458225e-03 2.548043e-03 9.697007e-04 #> 2:x3 2.675947e-04 8.709618e-04 1.607566e-03 6.477681e-04 #> 3:x3 1.646081e-04 2.887457e-04 5.082306e-04 2.447116e-04 #> 4:x3 1.055721e-04 1.566098e-04 2.634006e-04 1.271303e-04 #> 1:x2 2:x2 3:x2 4:x2 #> 1:(intercept) -1.103647e-03 -1.745275e-04 -0.0001308655 -3.481221e-05 #> 2:(intercept) -2.595891e-04 -1.514108e-03 -0.0003206160 -1.126917e-04 #> 3:(intercept) -9.069383e-05 -2.220558e-04 -0.0014032886 -1.367579e-04 #> 4:(intercept) -2.827972e-05 -9.743127e-05 -0.0001854608 -1.168994e-03 #> 1:x1 2.729980e-04 2.034282e-04 0.0001460669 1.067297e-04 #> 2:x1 4.241437e-04 2.574290e-04 0.0001657421 1.141753e-04 #> 3:x1 3.340472e-04 2.456496e-04 0.0002101845 1.108608e-04 #> 4:x1 3.400662e-04 2.415033e-04 0.0001509003 2.235015e-04 #> 1:x2 6.144965e-03 2.103034e-03 0.0017349791 1.525559e-03 #> 2:x2 2.103034e-03 5.362377e-03 0.0020981689 1.683358e-03 #> 3:x2 1.734979e-03 2.098169e-03 0.0057699288 1.840361e-03 #> 4:x2 1.525559e-03 1.683358e-03 0.0018403607 4.869979e-03 #> 1:x3 4.128127e-04 5.231606e-04 0.0008403805 4.126313e-04 #> 2:x3 3.145503e-04 8.072030e-04 0.0010315586 4.832200e-04 #> 3:x3 3.052938e-04 5.513506e-04 0.0011363433 4.372081e-04 #> 4:x3 2.998371e-04 5.419764e-04 0.0009008454 6.795656e-04 #> 1:x3 2:x3 3:x3 4:x3 #> 1:(intercept) -0.0069682426 -0.0021404698 -0.0016570436 -0.0015426399 #> 2:(intercept) -0.0031109990 -0.0079890602 -0.0017990200 -0.0016665523 #> 3:(intercept) -0.0021662437 -0.0020285912 -0.0110764743 -0.0016902196 #> 4:(intercept) -0.0015773173 -0.0015827294 -0.0015268144 -0.0063152182 #> 1:x1 0.0003114125 0.0002675947 0.0001646081 0.0001055721 #> 2:x1 0.0014582255 0.0008709618 0.0002887457 0.0001566098 #> 3:x1 0.0025480430 0.0016075659 0.0005082306 0.0002634006 #> 4:x1 0.0009697007 0.0006477681 0.0002447116 0.0001271303 #> 1:x2 0.0004128127 0.0003145503 0.0003052938 0.0002998371 #> 2:x2 0.0005231606 0.0008072030 0.0005513506 0.0005419764 #> 3:x2 0.0008403805 0.0010315586 0.0011363433 0.0009008454 #> 4:x2 0.0004126313 0.0004832200 0.0004372081 0.0006795656 #> 1:x3 0.0504483009 0.0212043678 0.0180839052 0.0174825086 #> 2:x3 0.0212043678 0.0336027637 0.0178328883 0.0174539362 #> 3:x3 0.0180839052 0.0178328883 0.0317944968 0.0171920852 #> 4:x3 0.0174825086 0.0174539362 0.0171920852 0.0332383219 #>