Title: | Create Tables from Different Types of Regression |
---|---|
Description: | Create regression tables from generalized linear model(GLM), generalized estimating equation(GEE), generalized linear mixed-effects model(GLMM), Cox proportional hazards model, survey-weighted generalized linear model(svyglm) and survey-weighted Cox model results for publication. |
Authors: | Jinseob Kim [aut, cre] |
Maintainer: | Jinseob Kim <[email protected]> |
License: | Apache License 2.0 |
Version: | 1.3.10 |
Built: | 2025-03-05 08:31:35 UTC |
Source: | https://github.com/jinseob2kim/jstable |
Make coefficient table with NA
coefNA(model)
coefNA(model)
model |
glm object (gaussian or binomial) |
DETAILS
coefficient table with NA
coefNA(glm(mpg ~ wt + qsec, data = mtcars))
coefNA(glm(mpg ~ wt + qsec, data = mtcars))
Function to count event, subgroup number
count_event_by( formula, data, count_by_var = NULL, var_subgroup = NULL, decimal.percent = 1 )
count_event_by( formula, data, count_by_var = NULL, var_subgroup = NULL, decimal.percent = 1 )
formula |
formula with survival analysis |
data |
same data as in formula |
count_by_var |
variables to count subgroup for |
var_subgroup |
1 sub-group variable for analysis, |
decimal.percent |
decimals to show percent of, Default: 1 |
This function is used inside TableSubgroupCox, TableSubgroupMultiCox for calculation
Table with event, subgroup number
group_by
, summarise
, mutate
, bind_rows
, arrange
## Not run: if (interactive()) { } ## End(Not run)
## Not run: if (interactive()) { } ## End(Not run)
Table for coxph.object with model option: TRUE - allow "frailty" or "cluster" model
cox2.display(cox.obj.withmodel, dec = 2, msm = NULL)
cox2.display(cox.obj.withmodel, dec = 2, msm = NULL)
cox.obj.withmodel |
coxph.object with model option: TRUE |
dec |
Decimal point, Default: 2 |
msm |
Multi state model, Default: NULL |
GEE like - cluster, Mixed effect model like - frailty
Table, cluster/frailty info, metrics, caption
library(survival) data(lung) fit1 <- coxph(Surv(time, status) ~ ph.ecog + age + cluster(inst), data = lung, model = TRUE) fit2 <- coxph(Surv(time, status) ~ ph.ecog + age + frailty(inst), data = lung, model = TRUE) cox2.display(fit1) cox2.display(fit2)
library(survival) data(lung) fit1 <- coxph(Surv(time, status) ~ ph.ecog + age + cluster(inst), data = lung, model = TRUE) fit2 <- coxph(Surv(time, status) ~ ph.ecog + age + frailty(inst), data = lung, model = TRUE) cox2.display(fit1) cox2.display(fit2)
Transform the unit of coefficients to "HR"
coxExp(cox.coef, dec)
coxExp(cox.coef, dec)
cox.coef |
cox model coefficients |
dec |
Decimal point |
DETAILS
The transforemed coefficients(95
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) jstable:::coxExp(jstable:::coxmeTable(fit))
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) jstable:::coxExp(jstable:::coxmeTable(fit))
Make mixed effect model results from coxme.object (coxme package)
coxme.display(coxme.obj, dec = 2)
coxme.display(coxme.obj, dec = 2)
coxme.obj |
coxme.object |
dec |
Decimal point, Default: 2 |
DETAILS
Fixed effect table, random effect, metrics, caption
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) coxme.display(fit)
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) coxme.display(fit)
Extract fixed effect table in coxme.object
coxmeTable(mod)
coxmeTable(mod)
mod |
coxme.object |
DETAILS
beta, se, z, p of fixed effects
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) jstable:::coxmeTable(fit)
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) jstable:::coxmeTable(fit)
Combine CreateTableOne & print function in tableone package
CreateTableOne2( data, strata, vars, factorVars, includeNA = F, test = T, testApprox = chisq.test, argsApprox = list(correct = TRUE), testExact = fisher.test, argsExact = list(workspace = 2 * 10^5), testNormal = oneway.test, argsNormal = list(var.equal = F), testNonNormal = kruskal.test, argsNonNormal = list(NULL), showAllLevels = T, printToggle = F, quote = F, smd = F, Labels = F, exact = NULL, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, labeldata = NULL, minMax = F, showpm = T, addOverall = F, pairwise = F, pairwise.showtest = F )
CreateTableOne2( data, strata, vars, factorVars, includeNA = F, test = T, testApprox = chisq.test, argsApprox = list(correct = TRUE), testExact = fisher.test, argsExact = list(workspace = 2 * 10^5), testNormal = oneway.test, argsNormal = list(var.equal = F), testNonNormal = kruskal.test, argsNonNormal = list(NULL), showAllLevels = T, printToggle = F, quote = F, smd = F, Labels = F, exact = NULL, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, labeldata = NULL, minMax = F, showpm = T, addOverall = F, pairwise = F, pairwise.showtest = F )
data |
A data frame in which these variables exist. All variables (both vars and strata) must be in this data frame. |
strata |
Stratifying (grouping) variable name(s) given as a character vector. If omitted, the overall results are returned. |
vars |
Variables to be summarized given as a character vector. Factors are handled as categorical variables, whereas numeric variables are handled as continuous variables. If empty, all variables in the data frame specified in the data argument are used. |
factorVars |
Numerically coded variables that should be handled as categorical variables given as a character vector. Do not include factors, unless you need to relevel them by removing empty levels. If omitted, only factors are considered categorical variables. The variables specified here must also be specified in the vars argument. |
includeNA |
If TRUE, NA is handled as a regular factor level rather than missing. NA is shown as the last factor level in the table. Only effective for categorical variables., Default: F |
test |
If TRUE, as in the default and there are more than two groups, groupwise comparisons are performed, Default: T |
testApprox |
A function used to perform the large sample approximation based tests. The default is chisq.test. This is not recommended when some of the cell have small counts like fewer than 5, Default: chisq.test |
argsApprox |
A named list of arguments passed to the function specified in testApprox. The default is list(correct = TRUE), which turns on the continuity correction for chisq.test, Default: list(correct = TRUE) |
testExact |
A function used to perform the exact tests. The default is fisher.test. If the cells have large numbers, it will fail because of memory limitation. In this situation, the large sample approximation based should suffice., Default: fisher.test |
argsExact |
A named list of arguments passed to the function specified in testExact. The default is list(workspace = 2 * 10^5), which specifies the memory space allocated for fisher.test, Default: list(workspace = 2 * 10^5) |
testNormal |
A function used to perform the normal assumption based tests. The default is oneway.test. This is equivalent of the t-test when there are only two groups, Default: oneway.test |
argsNormal |
A named list of arguments passed to the function specified in testNormal. The default is list(var.equal = TRUE), which makes it the ordinary ANOVA that assumes equal variance across groups., Default: list(var.equal = F) |
testNonNormal |
A function used to perform the nonparametric tests. The default is kruskal.test (Kruskal-Wallis Rank Sum Test). This is equivalent of the wilcox.test (Man-Whitney U test) when there are only two groups, Default: kruskal.test |
argsNonNormal |
A named list of arguments passed to the function specified in testNonNormal. The default is list(NULL), which is just a placeholder., Default: list(NULL) |
showAllLevels |
Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information., Default: T |
printToggle |
Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned., Default: F |
quote |
Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily, Default: F |
smd |
If TRUE, as in the default and there are more than two groups, standardized mean differences for all pairwise comparisons are calculated, Default: F |
Labels |
Use Label, Default: F |
exact |
A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test)., Default: NULL |
nonnormal |
A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test)., Default: NULL |
catDigits |
Number of digits to print for proportions., Default: 1 |
contDigits |
Number of digits to print for continuous variables. Default 2. |
pDigits |
Number of digits to print for p-values (also used for standardized mean differences), Default: 3 |
labeldata |
labeldata to use, Default: NULL |
minMax |
Whether to use [min,max] instead of [p25,p75] for nonnormal variables. The default is FALSE. |
showpm |
Logical, show normal distributed continuous variables as Mean ± SD. Default: T |
addOverall |
(optional, only used if strata are supplied) Adds an overall column to the table. Smd and p-value calculations are performed using only the stratifed clolumns. Default: F |
pairwise |
(optional, only used if strata are supplied) When there are three or more strata, it displays the p-values for pairwise comparisons. Default: F |
pairwise.showtest |
(optional, only used if strata are supplied) When using pairwise comparison, it displays the test used to calculate p-values for pairwise comparisons. Default: F |
DETAILS
A matrix object containing what you see is also invisibly returned. This can be assinged a name and exported via write.csv.
library(survival) CreateTableOne2(vars = names(lung), strata = "sex", data = lung)
library(survival) CreateTableOne2(vars = names(lung), strata = "sex", data = lung)
Combine CreateTableOne & print function in tableone package
CreateTableOneJS( vars, strata = NULL, strata2 = NULL, data, factorVars = NULL, includeNA = F, test = T, testApprox = chisq.test, argsApprox = list(correct = TRUE), testExact = fisher.test, argsExact = list(workspace = 2 * 10^5), testNormal = oneway.test, argsNormal = list(var.equal = F), testNonNormal = kruskal.test, argsNonNormal = list(NULL), showAllLevels = T, printToggle = F, quote = F, smd = F, Labels = F, exact = NULL, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, labeldata = NULL, psub = T, minMax = F, showpm = T, addOverall = F, normalityTest = F, pairwise = F, pairwise.showtest = F )
CreateTableOneJS( vars, strata = NULL, strata2 = NULL, data, factorVars = NULL, includeNA = F, test = T, testApprox = chisq.test, argsApprox = list(correct = TRUE), testExact = fisher.test, argsExact = list(workspace = 2 * 10^5), testNormal = oneway.test, argsNormal = list(var.equal = F), testNonNormal = kruskal.test, argsNonNormal = list(NULL), showAllLevels = T, printToggle = F, quote = F, smd = F, Labels = F, exact = NULL, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, labeldata = NULL, psub = T, minMax = F, showpm = T, addOverall = F, normalityTest = F, pairwise = F, pairwise.showtest = F )
vars |
Variables to be summarized given as a character vector. Factors are handled as categorical variables, whereas numeric variables are handled as continuous variables. If empty, all variables in the data frame specified in the data argument are used. |
strata |
Stratifying grouping variable name(s) given as a character vector. If omitted, the overall results are returned. |
strata2 |
Stratifying 2nd grouping variable name(s) given as a character vector. If omitted, the 1 group results are returned. |
data |
A data frame in which these variables exist. All variables (both vars and strata) must be in this data frame. |
factorVars |
Numerically coded variables that should be handled as categorical variables given as a character vector. Do not include factors, unless you need to relevel them by removing empty levels. If omitted, only factors are considered categorical variables. The variables specified here must also be specified in the vars argument. |
includeNA |
If TRUE, NA is handled as a regular factor level rather than missing. NA is shown as the last factor level in the table. Only effective for categorical variables., Default: F |
test |
If TRUE, as in the default and there are more than two groups, groupwise comparisons are performed, Default: T |
testApprox |
A function used to perform the large sample approximation based tests. The default is chisq.test. This is not recommended when some of the cell have small counts like fewer than 5, Default: chisq.test |
argsApprox |
A named list of arguments passed to the function specified in testApprox. The default is list(correct = TRUE), which turns on the continuity correction for chisq.test, Default: list(correct = TRUE) |
testExact |
A function used to perform the exact tests. The default is fisher.test. If the cells have large numbers, it will fail because of memory limitation. In this situation, the large sample approximation based should suffice., Default: fisher.test |
argsExact |
A named list of arguments passed to the function specified in testExact. The default is list(workspace = 2 * 10^5), which specifies the memory space allocated for fisher.test, Default: list(workspace = 2 * 10^5) |
testNormal |
A function used to perform the normal assumption based tests. The default is oneway.test. This is equivalent of the t-test when there are only two groups, Default: oneway.test |
argsNormal |
A named list of arguments passed to the function specified in testNormal. The default is list(var.equal = TRUE), which makes it the ordinary ANOVA that assumes equal variance across groups., Default: list(var.equal = F) |
testNonNormal |
A function used to perform the nonparametric tests. The default is kruskal.test (Kruskal-Wallis Rank Sum Test). This is equivalent of the wilcox.test (Man-Whitney U test) when there are only two groups, Default: kruskal.test |
argsNonNormal |
A named list of arguments passed to the function specified in testNonNormal. The default is list(NULL), which is just a placeholder., Default: list(NULL) |
showAllLevels |
Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information., Default: T |
printToggle |
Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned., Default: F |
quote |
Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily, Default: F |
smd |
If TRUE, as in the default and there are more than two groups, standardized mean differences for all pairwise comparisons are calculated, Default: F |
Labels |
Use Label, Default: F |
exact |
A character vector to specify the variables for which the p-values should be those of exact tests. By default all p-values are from large sample approximation tests (chisq.test)., Default: NULL |
nonnormal |
A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test)., Default: NULL |
catDigits |
Number of digits to print for proportions. Default: 1 |
contDigits |
Number of digits to print for continuous variables. Default 2. |
pDigits |
Number of digits to print for p-values (also used for standardized mean differences), Default: 3 |
labeldata |
labeldata to use, Default: NULL |
psub |
show sub-group p-values, Default: F |
minMax |
Whether to use [min,max] instead of [p25,p75] for nonnormal variables. The default is FALSE. |
showpm |
Logical, show normal distributed continuous variables as Mean ± SD. Default: T |
addOverall |
(optional, only used if strata are supplied) Adds an overall column to the table. Smd and p-value calculations are performed using only the stratifed clolumns. Default: F |
normalityTest |
Logical, perform the Shapiro test for all variables. Default: F |
pairwise |
(optional, only used if strata are supplied) When there are three or more strata, it displays the p-values for pairwise comparisons. Default: F#' @return A matrix object containing what you see is also invisibly returned. This can be assinged a name and exported via write.csv. |
pairwise.showtest |
(optional, only used if strata are supplied) When using pairwise comparison, it displays the test used to calculate p-values for pairwise comparisons. Default: F |
DETAILS
library(survival) CreateTableOneJS(vars = names(lung), strata = "sex", data = lung)
library(survival) CreateTableOneJS(vars = names(lung), strata = "sex", data = lung)
Extract AIC from coxme.object
## S3 method for class 'coxme' extractAIC(fit, scale = NULL, k = 2, ...)
## S3 method for class 'coxme' extractAIC(fit, scale = NULL, k = 2, ...)
fit |
coxme.object |
scale |
NULL |
k |
numeric specifying the 'weight' of the equivalent degrees of freedom (=: edf) part in the AIC formula. |
... |
further arguments (currently unused in base R). |
DETAILS
AIC(Integreted, Penalized)
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) extractAIC(fit)
library(coxme) fit <- coxme(Surv(time, status) ~ ph.ecog + age + (1 | inst), lung) extractAIC(fit)
Transform the unit of coefficients to "Coeff", "OR" or "RR"
geeExp(gee.coef, family = "binomial", dec)
geeExp(gee.coef, family = "binomial", dec)
gee.coef |
geeUni object. |
family |
Family: "gaussian", "binomial", "poisson", "quasipoisson", etc..., Default: 'binomial' |
dec |
Decimal point |
DETAILS
The transforemed coefficients(95
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee.uni <- geeUni("Weight", c("Time", "Cu"), data = dietox, id.vec = dietox$Pig, family = "gaussian", cor.type = "exchangeable" ) gee.exp <- geeExp(gee.uni, "binomial", 2)
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee.uni <- geeUni("Weight", c("Time", "Cu"), data = dietox, id.vec = dietox$Pig, family = "gaussian", cor.type = "exchangeable" ) gee.exp <- geeExp(gee.uni, "binomial", 2)
Make gee results from "geeglm" object
geeglm.display(geeglm.obj, decimal = 2)
geeglm.display(geeglm.obj, decimal = 2)
geeglm.obj |
"geeglm" object |
decimal |
Decimal, Default: 2 |
DETAILS
List: caption, main table, metrics table
data.table-package
complete.cases
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee01 <- geeglm(Weight ~ Time + Cu, id = Pig, data = dietox, family = gaussian, corstr = "ex" ) geeglm.display(gee01)
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee01 <- geeglm(Weight ~ Time + Cu, id = Pig, data = dietox, family = gaussian, corstr = "ex" ) geeglm.display(gee01)
Extract the coefficients of univariate gee using geeglm function (geepack package).
geeUni(y, x, data, id.vec, family, cor.type = "exchangeable")
geeUni(y, x, data, id.vec, family, cor.type = "exchangeable")
y |
Dependant variable |
x |
Independent variable |
data |
Data |
id.vec |
Vector of id (should be ordered) |
family |
Family: "gaussian", "binomial", "poisson", "quasipoisson", etc... |
cor.type |
Correlation structure, Default: 'exchangeable' |
DETAILS
coefficient, standard error, p-value
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee.uni <- geeUni("Weight", "Time", data = dietox, id.vec = dietox$Pig, family = "gaussian", cor.type = "exchangeable" )
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee.uni <- geeUni("Weight", "Time", data = dietox, id.vec = dietox$Pig, family = "gaussian", cor.type = "exchangeable" )
Show summary table of glm object(regression, logistic).
glmshow.display(glm.object, decimal = 2)
glmshow.display(glm.object, decimal = 2)
glm.object |
glm.object |
decimal |
digits, Default: 2 |
DETAILS
table
glmshow.display(glm(mpg ~ wt + qsec, data = mtcars))
glmshow.display(glm(mpg ~ wt + qsec, data = mtcars))
Apply label information to epiDisplay.object using label data
LabelepiDisplay(epiDisplay.obj, label = F, ref)
LabelepiDisplay(epiDisplay.obj, label = F, ref)
epiDisplay.obj |
epiDisplay.object or glmshow.object |
label |
Apply label information, Default: F |
ref |
Label data made by mk.lev function |
DETAILS
epiDisplay.object with label information
fit <- glm(Sepal.Length ~ Sepal.Width + Species, data = iris) fit.table <- glmshow.display(fit) iris.label <- mk.lev(iris) LabelepiDisplay(fit.table, label = TRUE, ref = iris.label)
fit <- glm(Sepal.Length ~ Sepal.Width + Species, data = iris) fit.table <- glmshow.display(fit) iris.label <- mk.lev(iris) LabelepiDisplay(fit.table, label = TRUE, ref = iris.label)
Apply label information to cox2.display object using label data
LabeljsCox(obj, ref)
LabeljsCox(obj, ref)
obj |
cox2.display object |
ref |
Label data made by mk.lev function |
DETAILS
cox2.display object with label information
library(survival) fit <- coxph(Surv(time, status) ~ sex + ph.ecog + ph.karno + cluster(inst), data = lung, model = TRUE ) fit.table <- cox2.display(fit) lung.label <- mk.lev(lung) LabeljsCox(fit.table, ref = lung.label)
library(survival) fit <- coxph(Surv(time, status) ~ sex + ph.ecog + ph.karno + cluster(inst), data = lung, model = TRUE ) fit.table <- cox2.display(fit) lung.label <- mk.lev(lung) LabeljsCox(fit.table, ref = lung.label)
Apply label information to geeglm.display object using label data
LabeljsGeeglm(obj, ref)
LabeljsGeeglm(obj, ref)
obj |
geeglm.display object |
ref |
Label data made by mk.lev function |
DETAILS
geeglm.display object with label information
library(geepack) library(jstable) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee01 <- geeglm(Weight ~ Time + Cu, id = Pig, data = dietox, family = gaussian, corstr = "ex" ) g1 <- geeglm.display(gee01) LabeljsGeeglm(g1, ref = mk.lev(dietox))
library(geepack) library(jstable) data(dietox) dietox$Cu <- as.factor(dietox$Cu) gee01 <- geeglm(Weight ~ Time + Cu, id = Pig, data = dietox, family = gaussian, corstr = "ex" ) g1 <- geeglm.display(gee01) LabeljsGeeglm(g1, ref = mk.lev(dietox))
Apply label information to metric object of jstable using label data
LabeljsMetric(obj.metric, ref)
LabeljsMetric(obj.metric, ref)
obj.metric |
metric of lmer.display, coxme.display |
ref |
Label data made by mk.lev function |
DETAILS
metric of lmer.display, coxme.display with label information
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsTable(fit.table$table, ref = lung.label) LabeljsRanef(fit.table$ranef, ref = lung.label) LabeljsMetric(fit.table$metric, ref = lung.label)
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsTable(fit.table$table, ref = lung.label) LabeljsRanef(fit.table$ranef, ref = lung.label) LabeljsMetric(fit.table$metric, ref = lung.label)
Apply label information to object of jstable using label data
LabeljsMixed(obj, ref)
LabeljsMixed(obj, ref)
obj |
lmer.display, coxme.display |
ref |
Label data made by mk.lev function |
DETAILS
lmer.display, coxme.display with label information
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsMixed(fit.table, ref = lung.label)
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsMixed(fit.table, ref = lung.label)
Apply label information to ranef object of jstable using label data
LabeljsRanef(obj.ranef, ref)
LabeljsRanef(obj.ranef, ref)
obj.ranef |
ranef of lmer.display, coxme.display, cox2.display |
ref |
Label data made by mk.lev function |
DETAILS
ranef of lmer.display, coxme.display, cox2.display with label information
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsTable(fit.table$table, ref = lung.label) LabeljsRanef(fit.table$ranef, ref = lung.label)
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsTable(fit.table$table, ref = lung.label) LabeljsRanef(fit.table$ranef, ref = lung.label)
Apply label information to table of geeglm.display, lmer.display, coxme.display using label data
LabeljsTable(obj.table, ref)
LabeljsTable(obj.table, ref)
obj.table |
table of geeglm.display, lmer.display, coxme.display |
ref |
Label data made by mk.lev function |
DETAILS
table of geeglm.display, lmer.display, coxme.display with label information
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsTable(fit.table$table, ref = lung.label)
library(coxme) fit <- coxme(Surv(time, status) ~ sex + ph.ecog + ph.karno + (1 | inst) + (1 | sex), lung) fit.table <- coxme.display(fit) lung.label <- mk.lev(lung) LabeljsTable(fit.table$table, ref = lung.label)
Make mixed effect model results from "lmerMod" or "glmerMod" object (lme4 package)
lmer.display(lmerMod.obj, dec = 2, ci.ranef = F)
lmer.display(lmerMod.obj, dec = 2, ci.ranef = F)
lmerMod.obj |
"lmerMod" or "glmerMod" object |
dec |
Decimal, Default: 2 |
ci.ranef |
Show confidence interval of random effects?, Default: F |
DETAILS
Table: fixed & random effect
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) l1 <- lme4::lmer(Weight ~ Time + Cu + (1 | Pig) + (1 | Evit), data = dietox) lmer.display(l1)
library(geepack) data(dietox) dietox$Cu <- as.factor(dietox$Cu) l1 <- lme4::lmer(Weight ~ Time + Cu + (1 | Pig) + (1 | Evit), data = dietox) lmer.display(l1)
Transform the unit of coefficients to "Coeff", "OR" or "RR"
lmerExp(lmer.coef, family = "binomial", dec)
lmerExp(lmer.coef, family = "binomial", dec)
lmer.coef |
lmer coefficients. |
family |
Family: "gaussian", "binomial", "poisson", "quasipoisson", etc..., Default: 'binomial' |
dec |
Decimal point |
DETAILS
The transforemed coefficients(95
# EXAMPLE1
# EXAMPLE1
Export label and level: multiple variable
mk.lev(data)
mk.lev(data)
data |
data |
DETAILS
default label and level data
mk.lev(iris)
mk.lev(iris)
Export label and level: one variable
mk.lev.var(data, vname)
mk.lev.var(data, vname)
data |
data |
vname |
variable to export label and level |
DETAILS
if continuous variable - (label, NA), categorical variable - (label, level)
lapply(names(iris), function(x) { jstable::mk.lev.var(iris, x) })
lapply(names(iris), function(x) { jstable::mk.lev.var(iris, x) })
DATASET_DESCRIPTION
mort
mort
A data frame with 17562 rows and 24 variables:
ccode
integer COLUMN_DESCRIPTION
cname
character COLUMN_DESCRIPTION
yy
integer COLUMN_DESCRIPTION
mm
integer COLUMN_DESCRIPTION
dd
integer COLUMN_DESCRIPTION
date
character COLUMN_DESCRIPTION
nonacc
integer COLUMN_DESCRIPTION
cardio
integer COLUMN_DESCRIPTION
respir
integer COLUMN_DESCRIPTION
influenza
integer COLUMN_DESCRIPTION
meanpm10
double COLUMN_DESCRIPTION
meanso2
double COLUMN_DESCRIPTION
meanno2
double COLUMN_DESCRIPTION
meanco
double COLUMN_DESCRIPTION
maxco
double COLUMN_DESCRIPTION
maxo3
double COLUMN_DESCRIPTION
meantemp
double COLUMN_DESCRIPTION
maxtemp
double COLUMN_DESCRIPTION
mintemp
double COLUMN_DESCRIPTION
meanhumi
double COLUMN_DESCRIPTION
meanpress
double COLUMN_DESCRIPTION
season
integer COLUMN_DESCRIPTION
dow
integer COLUMN_DESCRIPTION
sn
integer COLUMN_DESCRIPTION
DETAILS
DT::datatable option for data
opt.data(fname)
opt.data(fname)
fname |
File name to download |
DETAILS
datatable option object
opt.data("mtcars")
opt.data("mtcars")
DT::datatable option for ROC result
opt.roc(fname)
opt.roc(fname)
fname |
File name to download |
DETAILS
datatable option object
options <- opt.roc("mtcars")
options <- opt.roc("mtcars")
Simple download DT::datatable option - No filter, No page
opt.simpledown(fname)
opt.simpledown(fname)
fname |
File name to download |
DETAILS
datatable option object
options <- opt.simpledown("mtcars")
options <- opt.simpledown("mtcars")
DT::datatable option for table 1
opt.tb1(fname)
opt.tb1(fname)
fname |
File name to download |
DETAILS
datatable option object
options <- opt.tb1("mtcars")
options <- opt.tb1("mtcars")
DT::datatable option for glm, gee(geepack package), lmer/glmer(lme4 package)
opt.tbreg(fname)
opt.tbreg(fname)
fname |
File name to download |
DETAILS
datatable option object
options <- opt.tbreg("mtcars")
options <- opt.tbreg("mtcars")
Table for complex design cox model.
svycox.display(svycoxph.obj, decimal = 2)
svycox.display(svycoxph.obj, decimal = 2)
svycoxph.obj |
svycoxph.object |
decimal |
digit, Default: 2 |
DETAILS
List including table, metric, caption
library(survival) data(pbc) pbc$sex <- factor(pbc$sex) pbc$stage <- factor(pbc$stage) pbc$randomized <- with(pbc, !is.na(trt) & trt > 0) biasmodel <- glm(randomized ~ age * edema, data = pbc, family = binomial) pbc$randprob <- fitted(biasmodel) if (is.null(pbc$albumin)) pbc$albumin <- pbc$alb ## pre2.9.0 dpbc <- survey::svydesign( id = ~1, prob = ~randprob, strata = ~edema, data = subset(pbc, randomized) ) model <- survey::svycoxph(Surv(time, status > 0) ~ sex + protime + albumin + stage, design = dpbc ) svycox.display(model)
library(survival) data(pbc) pbc$sex <- factor(pbc$sex) pbc$stage <- factor(pbc$stage) pbc$randomized <- with(pbc, !is.na(trt) & trt > 0) biasmodel <- glm(randomized ~ age * edema, data = pbc, family = binomial) pbc$randprob <- fitted(biasmodel) if (is.null(pbc$albumin)) pbc$albumin <- pbc$alb ## pre2.9.0 dpbc <- survey::svydesign( id = ~1, prob = ~randprob, strata = ~edema, data = subset(pbc, randomized) ) model <- survey::svycoxph(Surv(time, status > 0) ~ sex + protime + albumin + stage, design = dpbc ) svycox.display(model)
Combine svyCreateTableOne & print function in tableone package
svyCreateTableOne2( data, strata, vars, factorVars, includeNA = F, test = T, showAllLevels = T, printToggle = F, quote = F, smd = F, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, Labels = F, labeldata = NULL, minMax = F, showpm = T, addOverall = F, pairwise = F, pairwise.showtest = F )
svyCreateTableOne2( data, strata, vars, factorVars, includeNA = F, test = T, showAllLevels = T, printToggle = F, quote = F, smd = F, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, Labels = F, labeldata = NULL, minMax = F, showpm = T, addOverall = F, pairwise = F, pairwise.showtest = F )
data |
A data frame in which these variables exist. All variables (both vars and strata) must be in this data frame. |
strata |
Stratifying (grouping) variable name(s) given as a character vector. If omitted, the overall results are returned. |
vars |
Variables to be summarized given as a character vector. Factors are handled as categorical variables, whereas numeric variables are handled as continuous variables. If empty, all variables in the data frame specified in the data argument are used. |
factorVars |
Numerically coded variables that should be handled as categorical variables given as a character vector. Do not include factors, unless you need to relevel them by removing empty levels. If omitted, only factors are considered categorical variables. The variables specified here must also be specified in the vars argument. |
includeNA |
If TRUE, NA is handled as a regular factor level rather than missing. NA is shown as the last factor level in the table. Only effective for categorical variables., Default: F |
test |
If TRUE, as in the default and there are more than two groups, groupwise comparisons are performed, Default: T |
showAllLevels |
Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information., Default: T |
printToggle |
Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned., Default: F |
quote |
Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily, Default: F |
smd |
If TRUE, as in the default and there are more than two groups, standardized mean differences for all pairwise comparisons are calculated, Default: F |
nonnormal |
A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test)., Default: NULL |
catDigits |
Number of digits to print for proportions., Default: 1 |
contDigits |
Number of digits to print for continuous variables. Default 2. |
pDigits |
Number of digits to print for p-values (also used for standardized mean differences), Default: 3 |
Labels |
Use Label, Default: F |
labeldata |
labeldata to use, Default: NULL |
minMax |
Whether to use [min,max] instead of [p25,p75] for nonnormal variables. The default is FALSE. |
showpm |
Logical, show normal distributed continuous variables as Mean ± SD. Default: T |
addOverall |
(optional, only used if strata are supplied) Adds an overall column to the table. Smd and p-value calculations are performed using only the stratifed clolumns. Default: F |
pairwise |
(optional, only used if strata are supplied) When there are three or more strata, it displays the p-values for pairwise comparisons. Default: F |
pairwise.showtest |
(optional, only used if strata are supplied) When using pairwise comparison, it displays the test used to calculate p-values for pairwise comparisons. Default: F |
DETAILS
A matrix object containing what you see is also invisibly returned. This can be assinged a name and exported via write.csv.
library(survey) data(nhanes) nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) nhanesSvy <- svydesign( ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR, nest = TRUE, data = nhanes ) svyCreateTableOne2( vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"), strata = "RIAGENDR", data = nhanesSvy, factorVars = c("HI_CHOL", "race", "RIAGENDR") )
library(survey) data(nhanes) nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) nhanesSvy <- svydesign( ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR, nest = TRUE, data = nhanes ) svyCreateTableOne2( vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"), strata = "RIAGENDR", data = nhanesSvy, factorVars = c("HI_CHOL", "race", "RIAGENDR") )
Combine svyCreateTableOne & print function in tableone package
svyCreateTableOneJS( vars, strata = NULL, strata2 = NULL, data, factorVars = NULL, includeNA = F, test = T, showAllLevels = T, printToggle = F, quote = F, smd = F, Labels = F, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, labeldata = NULL, psub = T, minMax = F, showpm = T, addOverall = F, pairwise = F, pairwise.showtest = F )
svyCreateTableOneJS( vars, strata = NULL, strata2 = NULL, data, factorVars = NULL, includeNA = F, test = T, showAllLevels = T, printToggle = F, quote = F, smd = F, Labels = F, nonnormal = NULL, catDigits = 1, contDigits = 2, pDigits = 3, labeldata = NULL, psub = T, minMax = F, showpm = T, addOverall = F, pairwise = F, pairwise.showtest = F )
vars |
Variables to be summarized given as a character vector. Factors are handled as categorical variables, whereas numeric variables are handled as continuous variables. If empty, all variables in the data frame specified in the data argument are used. |
strata |
Stratifying grouping variable name(s) given as a character vector. If omitted, the overall results are returned. |
strata2 |
Stratifying 2nd grouping variable name(s) given as a character vector. If omitted, the 1 group results are returned. |
data |
A data frame in which these variables exist. All variables (both vars and strata) must be in this data frame. |
factorVars |
Numerically coded variables that should be handled as categorical variables given as a character vector. Do not include factors, unless you need to relevel them by removing empty levels. If omitted, only factors are considered categorical variables. The variables specified here must also be specified in the vars argument. |
includeNA |
If TRUE, NA is handled as a regular factor level rather than missing. NA is shown as the last factor level in the table. Only effective for categorical variables., Default: F |
test |
If TRUE, as in the default and there are more than two groups, groupwise comparisons are performed, Default: T |
showAllLevels |
Whether to show all levels. FALSE by default, i.e., for 2-level categorical variables, only the higher level is shown to avoid redundant information., Default: T |
printToggle |
Whether to print the output. If FALSE, no output is created, and a matrix is invisibly returned., Default: F |
quote |
Whether to show everything in quotes. The default is FALSE. If TRUE, everything including the row and column names are quoted so that you can copy it to Excel easily, Default: F |
smd |
If TRUE, as in the default and there are more than two groups, standardized mean differences for all pairwise comparisons are calculated, Default: F |
Labels |
Use Label, Default: F |
nonnormal |
A character vector to specify the variables for which the p-values should be those of nonparametric tests. By default all p-values are from normal assumption-based tests (oneway.test)., Default: NULL |
catDigits |
Number of digits to print for proportions., Default: 1 |
contDigits |
Number of digits to print for continuous variables. Default 2. |
pDigits |
Number of digits to print for p-values (also used for standardized mean differences), Default: 3 |
labeldata |
labeldata to use, Default: NULL |
psub |
show sub-group p-values, Default: F |
minMax |
Whether to use [min,max] instead of [p25,p75] for nonnormal variables. The default is FALSE. |
showpm |
Logical, show normal distributed continuous variables as Mean ± SD. Default: T |
addOverall |
(optional, only used if strata are supplied) Adds an overall column to the table. Smd and p-value calculations are performed using only the stratifed clolumns. Default: F |
pairwise |
(optional, only used if strata are supplied) When there are three or more strata, it displays the p-values for pairwise comparisons. Default: F |
pairwise.showtest |
(optional, only used if strata are supplied) When using pairwise comparison, it displays the test used to calculate p-values for pairwise comparisons. Default: F |
DETAILS
A matrix object containing what you see is also invisibly returned. This can be assinged a name and exported via write.csv.
library(survey) data(nhanes) nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) nhanesSvy <- svydesign( ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR, nest = TRUE, data = nhanes ) svyCreateTableOneJS( vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"), strata = "RIAGENDR", data = nhanesSvy, factorVars = c("HI_CHOL", "race", "RIAGENDR") )
library(survey) data(nhanes) nhanes$SDMVPSU <- as.factor(nhanes$SDMVPSU) nhanesSvy <- svydesign( ids = ~SDMVPSU, strata = ~SDMVSTRA, weights = ~WTMEC2YR, nest = TRUE, data = nhanes ) svyCreateTableOneJS( vars = c("HI_CHOL", "race", "agecat", "RIAGENDR"), strata = "RIAGENDR", data = nhanesSvy, factorVars = c("HI_CHOL", "race", "RIAGENDR") )
table for svyglm.object (survey package).
svyregress.display(svyglm.obj, decimal = 2)
svyregress.display(svyglm.obj, decimal = 2)
svyglm.obj |
svyglm.object |
decimal |
digit, Default: 2 |
DETAILS
table
library(survey) data(api) apistrat$tt <- c(rep(1, 20), rep(0, nrow(apistrat) - 20)) dstrat <- svydesign(id = ~1, strata = ~stype, weights = ~pw, data = apistrat, fpc = ~fpc) ds <- svyglm(api00 ~ ell + meals + cname + mobility, design = dstrat) ds2 <- svyglm(tt ~ ell + meals + cname + mobility, design = dstrat, family = quasibinomial()) svyregress.display(ds) svyregress.display(ds2)
library(survey) data(api) apistrat$tt <- c(rep(1, 20), rep(0, nrow(apistrat) - 20)) dstrat <- svydesign(id = ~1, strata = ~stype, weights = ~pw, data = apistrat, fpc = ~fpc) ds <- svyglm(api00 ~ ell + meals + cname + mobility, design = dstrat) ds2 <- svyglm(tt ~ ell + meals + cname + mobility, design = dstrat, family = quasibinomial()) svyregress.display(ds) svyregress.display(ds2)
Sub-group analysis table for Cox/svycox model.
TableSubgroupCox( formula, var_subgroup = NULL, var_cov = NULL, data, time_eventrate = 3 * 365, decimal.hr = 2, decimal.percent = 1, decimal.pvalue = 3, cluster = NULL, strata = NULL, weights = NULL, event = FALSE, count_by = NULL, labeldata = NULL )
TableSubgroupCox( formula, var_subgroup = NULL, var_cov = NULL, data, time_eventrate = 3 * 365, decimal.hr = 2, decimal.percent = 1, decimal.pvalue = 3, cluster = NULL, strata = NULL, weights = NULL, event = FALSE, count_by = NULL, labeldata = NULL )
formula |
formula with survival analysis. |
var_subgroup |
1 sub-group variable for analysis, Default: NULL |
var_cov |
Variables for additional adjust, Default: NULL |
data |
Data or svydesign in survey package. |
time_eventrate |
Time for kaplan-meier based event rate calculation, Default = 365 * 3 |
decimal.hr |
Decimal for hazard ratio, Default: 2 |
decimal.percent |
Decimal for percent, Default: 1 |
decimal.pvalue |
Decimal for pvalue, Default: 3 |
cluster |
Cluster variable for coxph, Default: NULL |
strata |
Strata variable for coxph, Default: NULL |
weights |
Weights variable for coxph, Default: NULL |
event |
Show number and rates of event in survival analysis default:F |
count_by |
Select variables to count by subgroup, Default: NULL |
labeldata |
Label info, made by 'mk.lev' function, Default: NULL |
This result is used to make forestplot.
Sub-group analysis table.
safely
,map
,map2
coxph
svycoxph
confint
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)) ) -> lung TableSubgroupCox(Surv(time, status) ~ sex, data = lung, time_eventrate = 100) TableSubgroupCox(Surv(time, status) ~ sex, var_subgroup = "kk", data = lung, time_eventrate = 100 ) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupCox(Surv(time, status) ~ sex, data = data.design, time_eventrate = 100) TableSubgroupCox(Surv(time, status) ~ sex, var_subgroup = "kk", data = data.design, time_eventrate = 100 )
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)) ) -> lung TableSubgroupCox(Surv(time, status) ~ sex, data = lung, time_eventrate = 100) TableSubgroupCox(Surv(time, status) ~ sex, var_subgroup = "kk", data = lung, time_eventrate = 100 ) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupCox(Surv(time, status) ~ sex, data = data.design, time_eventrate = 100) TableSubgroupCox(Surv(time, status) ~ sex, var_subgroup = "kk", data = data.design, time_eventrate = 100 )
Sub-group analysis table for GLM.
TableSubgroupGLM( formula, var_subgroup = NULL, var_cov = NULL, data, family = "binomial", decimal.estimate = 2, decimal.percent = 1, decimal.pvalue = 3, labeldata = NULL )
TableSubgroupGLM( formula, var_subgroup = NULL, var_cov = NULL, data, family = "binomial", decimal.estimate = 2, decimal.percent = 1, decimal.pvalue = 3, labeldata = NULL )
formula |
formula with survival analysis. |
var_subgroup |
1 sub-group variable for analysis, Default: NULL |
var_cov |
Variables for additional adjust, Default: NULL |
data |
Data or svydesign in survey package. |
family |
family, "gaussian" or "binomial" or 'poisson' or 'quasipoisson' |
decimal.estimate |
Decimal for estimate, Default: 2 |
decimal.percent |
Decimal for percent, Default: 1 |
decimal.pvalue |
Decimal for pvalue, Default: 3 |
labeldata |
Label info, made by 'mk.lev' function, Default: NULL |
This result is used to make forestplot.
Sub-group analysis table.
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)) ) -> lung TableSubgroupGLM(status ~ sex, data = lung, family = "binomial") TableSubgroupGLM(status ~ sex, var_subgroup = "kk", data = lung, family = "binomial") ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupGLM(status ~ sex, data = data.design, family = "binomial") TableSubgroupGLM(status ~ sex, var_subgroup = "kk", data = data.design, family = "binomial")
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)) ) -> lung TableSubgroupGLM(status ~ sex, data = lung, family = "binomial") TableSubgroupGLM(status ~ sex, var_subgroup = "kk", data = lung, family = "binomial") ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupGLM(status ~ sex, data = data.design, family = "binomial") TableSubgroupGLM(status ~ sex, var_subgroup = "kk", data = data.design, family = "binomial")
Multiple sub-group analysis table for Cox/svycox model.
TableSubgroupMultiCox( formula, var_subgroups = NULL, var_cov = NULL, data, time_eventrate = 3 * 365, decimal.hr = 2, decimal.percent = 1, decimal.pvalue = 3, line = F, cluster = NULL, strata = NULL, weights = NULL, event = FALSE, count_by = NULL, labeldata = NULL )
TableSubgroupMultiCox( formula, var_subgroups = NULL, var_cov = NULL, data, time_eventrate = 3 * 365, decimal.hr = 2, decimal.percent = 1, decimal.pvalue = 3, line = F, cluster = NULL, strata = NULL, weights = NULL, event = FALSE, count_by = NULL, labeldata = NULL )
formula |
formula with survival analysis. |
var_subgroups |
Multiple sub-group variables for analysis, Default: NULL |
var_cov |
Variables for additional adjust, Default: NULL |
data |
Data or svydesign in survey package. |
time_eventrate |
Time for kaplan-meier based event rate calculation, Default = 365 * 3 |
decimal.hr |
Decimal for hazard ratio, Default: 2 |
decimal.percent |
Decimal for percent, Default: 1 |
decimal.pvalue |
Decimal for pvalue, Default: 3 |
line |
Include new-line between sub-group variables, Default: F |
cluster |
Cluster variable for coxph, Default: NULL |
strata |
Strata variable for coxph, Default: NULL |
weights |
Weights variable for coxph, Default: NULL |
event |
Show number and rates of event in survival analysis default:F |
count_by |
Select variables to count by subgroup, Default: NULL |
labeldata |
Label info, made by 'mk.lev' function, Default: NULL |
This result is used to make forestplot.
Multiple sub-group analysis table.
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)), kk1 = factor(as.integer(pat.karno >= 60)) ) -> lung TableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), data = lung, time_eventrate = 100, line = TRUE ) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), data = data.design, time_eventrate = 100 )
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)), kk1 = factor(as.integer(pat.karno >= 60)) ) -> lung TableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), data = lung, time_eventrate = 100, line = TRUE ) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupMultiCox(Surv(time, status) ~ sex, var_subgroups = c("kk", "kk1"), data = data.design, time_eventrate = 100 )
Multiple sub-group analysis table for GLM.
TableSubgroupMultiGLM( formula, var_subgroups = NULL, var_cov = NULL, data, family = "binomial", decimal.estimate = 2, decimal.percent = 1, decimal.pvalue = 3, line = F, labeldata = NULL )
TableSubgroupMultiGLM( formula, var_subgroups = NULL, var_cov = NULL, data, family = "binomial", decimal.estimate = 2, decimal.percent = 1, decimal.pvalue = 3, line = F, labeldata = NULL )
formula |
formula with survival analysis. |
var_subgroups |
Multiple sub-group variables for analysis, Default: NULL |
var_cov |
Variables for additional adjust, Default: NULL |
data |
Data or svydesign in survey package. |
family |
family, "gaussian" or "binomial" or 'poisson' or 'quasipoisson' |
decimal.estimate |
Decimal for estimate, Default: 2 |
decimal.percent |
Decimal for percent, Default: 1 |
decimal.pvalue |
Decimal for pvalue, Default: 3 |
line |
Include new-line between sub-group variables, Default: F |
labeldata |
Label info, made by 'mk.lev' function, Default: NULL |
This result is used to make forestplot.
Multiple sub-group analysis table.
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)), kk1 = factor(as.integer(pat.karno >= 60)) ) -> lung TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), data = lung, line = TRUE, family = "binomial" ) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), data = data.design, family = "binomial" )
library(survival) library(dplyr) lung %>% mutate( status = as.integer(status == 1), sex = factor(sex), kk = factor(as.integer(pat.karno >= 70)), kk1 = factor(as.integer(pat.karno >= 60)) ) -> lung TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), data = lung, line = TRUE, family = "binomial" ) ## survey design library(survey) data.design <- svydesign(id = ~1, data = lung) TableSubgroupMultiGLM(status ~ sex, var_subgroups = c("kk", "kk1"), data = data.design, family = "binomial" )