Baseline characteristics tables: add "HH:MM" variable
Source:R/AutoScript.basetable.R
AS.basetable.HHMM.RdSee Details.
Usage
AS.basetable.HHMM(
name,
outcome,
basetable,
subset.mask = NULL,
p.values = TRUE,
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. Alternatively, the string
"auto"restricts the analysis to the non-missing observations.- p.values
Logical value indicating whether to display p-values in the added row.
- digits.sig
Number of significant figures for p-values. Default =
2.- sig.thresh
Threshold below which p-values are displayed as
"< threshold"and values larger than1 - thresholdare displayed as"> 1 - 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 criterion1.AS.basetable.HHMM: adds a row for a time-of-day variable in "HH:MM" string format with circular mean ± SD. P-values are obtained from circular-linear regression2. Likelihood-ratio tests are performed using the Cordeiro–Paula–Botter method3.AS.basetable.linear: adds a row for a continuous variable with mean ± SD. P-values are obtained from linear regression.AS.basetable.log1plinear: adds a row for a log(x + 1)-transformed continuous variable with back-transformed mean ± SD. P-values are obtained from linear regression on the transformed outcome.AS.basetable.loglinear: adds a row for a log-transformed continuous variable with geometric mean ± SD. P-values are obtained from linear regression on the transformed outcome.AS.basetable.TTE: adds a row for a time-to-event variable, with Kaplan–Meier median and 95% confidence interval using the Brookmeyer–Crowley4 method with Greenwood's variance5 and a complementary log–log transformation6. 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 and 2, 1 versus 0 and 2, 2 versus 0 and 1.
A global likelihood-ratio test.
With 4 groups, only the likelihood-ratio test is provided.
References
Akaike, H., 1974. A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19(6), pp. 716–723.
Fisher, N.I. and Lee, A.J., 1992. Regression models for an angular response. Biometrics, pp. 665–677.
Cordeiro, G.M., Paula, G.A. and Botter, D.A., 1994. Improved likelihood ratio tests for dispersion models. International Statistical Review, pp. 257–274.
Brookmeyer, R. and Crowley, J., 1982. A confidence interval for the median survival time. Biometrics, pp. 29–41.
Greenwood, M., 1926. A report on the natural duration of cancer. In: Reports on Public Health and Medical Subjects, 33, pp. 1–26. London: Her Majesty’s Stationery Office, Ministry of Health.
Klein, J.P., Logan, B., Harhoff, M. and Andersen, P.K., 2007. Analyzing survival curves at a fixed point in time. Statistics in Medicine, 26(24), pp. 4505–4519.
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.7" "59.1 ± 10.2" "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%)" ""