Skip to contents

See Details.

Usage

AS.basetable.linear(
  name,
  outcome,
  basetable,
  subset.mask = NULL,
  p.values = TRUE,
  digits.fixed = 2,
  digits.sig = 2,
  sig.thresh = 0.001
)

Arguments

name

A string giving the variable name to display in the first column.

outcome

Numeric vector of continuous outcome values.

basetable

A list created by AS.basetable.create, containing the group assignments and current table structure.

subset.mask

Optional logical vector used to restrict the analysis to a subset of observations.

p.values

Logical value indicating whether to display p-values in the added row.

digits.fixed

Number of decimal places for summaries. Default = 2.

digits.sig

Number of significant figures for p-values. Default = 2.

sig.thresh

Threshold below which p-values are displayed as "< threshold". Default = 0.001.

Value

An updated baseline table list with a new row summarizing the added variable. The table itself can be accessed with $table.

Details

  • AS.basetable.create: creates a template table structure with headers, group sample sizes, and p-value columns for 1, 2, 3, or 4 groups.

  • AS.basetable.binary: adds a row for a binary variable with counts and percentages. P-values are obtained from logistic regression.

  • AS.basetable.blank: adds a blank row with a label, for separating sections.

  • AS.basetable.count: adds a row for a count variable. P-values are obtained from Poisson regression or negative binomial regression, whichever model yields the lower Akaike information criterion¹.

  • AS.basetable.HHMM: adds a row for a time-of-day variable in "HH:MM" string format with circular mean ± circular SD. P-values are obtained from circular-linear regression². Likelihood-ratio tests are performed using the Cordeiro–Paula–Botter method³.

  • AS.basetable.linear: adds a row for a continuous variable with mean ± SD. P-values are obtained from linear regression.

  • AS.basetable.loglinear: adds a row for a log-transformed continuous variable with geometric mean ± geometric SD. P-values are obtained from linear regression on the log-transformed outcome.

  • AS.basetable.TTE: adds a row for a time-to-event variable, with Kaplan–Meier median and 95% confidence interval. P-values are obtained from Cox regression.

The resulting table includes total and group-specific summaries. P-values are provided but are not always appropriate to report. With 3 groups, seven possible comparisons are provided:

  • Each pairwise comparison: group 0 versus 1, 0 versus 2, and 1 versus 2.

  • Each group against the combination of the other two: group 0 versus 1 & 2, 1 versus 0 & 2, 2 versus 0 & 1

  • A global likelihood-ratio test.

With 4 groups, only the likelihood-ratio test is provided.

References

  1. Akaike, H., 1974. A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19(6), pp. 716–723.

  2. Fisher, N.I. and Lee, A.J., 1992. Regression models for an angular response. Biometrics, pp. 665–677.

  3. Cordeiro, G.M., Paula, G.A. and Botter, D.A., 1994. Improved likelihood ratio tests for dispersion models. International Statistical Review, pp. 257–274.

Examples

# See GitHub README for further examples:
# https://github.com/hongconsulting/AutoScript
library(AutoScript)
library(survival)
data <- survival::veteran
table1 <- AS.basetable.create(group = data$trt - 1, name = c("Control", "Experimental"))
table1 <- AS.basetable.linear("Age (years), mean \u00b1 SD", data$age, table1, digits.fixed = 1)
table1 <- AS.basetable.loglinear("Time from diagnosis", data$diagtime, table1, digits.fixed = 1)
table1 <- AS.basetable.blank("(months), mean \u00b1 SD", table1)
table1 <- AS.basetable.blank("Histology:", table1)
table1 <- AS.basetable.binary("- Non-small cell, n (%)", data$celltype != "smallcell", table1)
table1 <- AS.basetable.binary("  - Adenocarcinoma, n (%)", data$celltype == "adeno", table1,
                              subset.mask = data$celltype != "smallcell")
table1 <- AS.basetable.binary("  - Squamous, n (%)", data$celltype == "squamous", table1,
                              subset.mask = data$celltype != "smallcell")
table1 <- AS.basetable.binary("  - Large cell, n (%)", data$celltype == "large", table1,
                              subset.mask = data$celltype != "smallcell")
table1 <- AS.basetable.binary("- Small cell, n (%)", data$celltype == "smallcell", table1,
                              p.values = FALSE)
options(width = 100)
print(table1$table)
#>       [,1]                        [,2]          [,3]          [,4]           [,5]   
#>  [1,] "Name"                      "Total"       "Control"     "Experimental" "p"    
#>  [2,] ""                          "n = 137"     "n = 69"      "n = 68"       ""     
#>  [3,] "Age (years), mean ± SD"    "58.3 ± 10.5" "57.5 ± 10.8" "59.1 ± 10.3"  "0.37" 
#>  [4,] "Time from diagnosis"       "5.8 ± 2.4"   "6.1 ± 2.3"   "5.5 ± 2.5"    "0.50" 
#>  [5,] "(months), mean ± SD"       ""            ""            ""             ""     
#>  [6,] "Histology:"                ""            ""            ""             ""     
#>  [7,] "- Non-small cell, n (%)"   "89 (65%)"    "39 (57%)"    "50 (74%)"     "0.038"
#>  [8,] "  - Adenocarcinoma, n (%)" "27 (30%)"    "9 (23%)"     "18 (36%)"     "0.19" 
#>  [9,] "  - Squamous, n (%)"       "35 (39%)"    "15 (38%)"    "20 (40%)"     "0.88" 
#> [10,] "  - Large cell, n (%)"     "27 (30%)"    "15 (38%)"    "12 (24%)"     "0.14" 
#> [11,] "- Small cell, n (%)"       "48 (35%)"    "30 (43%)"    "18 (26%)"     ""