View source: R/robincar-linear.R
robincar_linear | R Documentation |
Estimate treatment-group-specific response means and (optionally) treatment group contrasts.
robincar_linear( df, treat_col, response_col, strata_cols, covariate_cols, car_scheme = "simple", adj_method = "ANOVA", vcovHC = "HC0", covariate_to_include_strata = NULL, conf_level = 0.95, contrast_h = NULL, contrast_dh = NULL )
df |
A data.frame with the required columns |
treat_col |
Name of column in df with treatment variable |
response_col |
Name of the column in df with response variable |
strata_cols |
Names of columns in df with strata variables |
covariate_cols |
Names of columns in df with covariate variables |
car_scheme |
Name of the type of covariate-adaptive randomization scheme |
adj_method |
Name of linear adjustment method to use |
vcovHC |
Type of heteroskedasticity-consistent variance estimates |
covariate_to_include_strata |
Whether to include strata variables in covariate adjustment. Defaults to F for ANOVA and ANCOVA; defaults to T for ANHECOVA. User may override by passing in this argument. |
conf_level |
Level for confidence intervals |
contrast |
An optional function to specify a desired contrast |
data<-RobinCar:::data_sim data$A<-as.factor(data$A) fit.anova<-robincar_linear(df = data, response_col="y", treat_col="A", strata_cols=c("z1", "z2"), covariate_cols=c("x1", "x3"), car_scheme="simple", adj_method="ANOVA", vcovHC="HC0") fit.ancova<-robincar_linear(df = data, response_col="y", treat_col="A", strata_cols=c("z1", "z2"), covariate_cols=c("x1", "x3"), car_scheme="simple", adj_method="ANCOVA", vcovHC="HC0") fit.anhecova<-robincar_linear(df = data, response_col="y", treat_col="A", strata_cols=c("z1", "z2"), covariate_cols=c("x1", "x3"), car_scheme="simple", adj_method="ANHECOVA", vcovHC="HC0") fit.anova<-robincar_linear(df = data, response_col="y", treat_col="A", strata_cols=c("z1", "z2"), covariate_cols=c("x1", "x3"), car_scheme="simple", adj_method="ANOVA", vcovHC="HC0", contrast_h="diff") odds.ratio<-function(theta){ theta0<-theta[1] theta1<-theta[2] theta2<-theta[3] OR01<-theta1/(1-theta1)/(theta0/(1-theta0)) OR02<-theta2/(1-theta2)/(theta0/(1-theta0)) return(c(OR01,OR02)) } robincar_contrast(fit.anova$main, contrast_h=odds.ratio) n <- 1000 df <- data.frame(A=rbinom(n, size=1, prob=0.5), y=rnorm(n), x1=rnorm(n), x2=rnorm(n), x3=as.factor(rbinom(n, size=1, prob=0.5)), z1=rbinom(n, size=1, prob=0.5), z2=rbinom(n, size=1, prob=0.5)) df$A <- as.factor(df$A) fit.ancova<-robincar_linear(df = df, response_col="y", treat_col="A", strata_cols=c("z1", "z2"), covariate_cols=c("x1", "x2"), car_scheme="biased-coin", adj_method="ANCOVA", vcovHC="HC0") fit.anhecova<-robincar_linear(df = df, response_col="y", treat_col="A", strata_cols=c("z1", "z2"), covariate_cols=c("x1"), car_scheme="biased-coin", adj_method="ANHECOVA", vcovHC="HC0")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.