multi_compare {sampcompR} | R Documentation |
Compares data frames using different regression methods.
Description
multi_compare
compares data frames using regression models based on
differing methods. All glm
Models can be compared.
Usage
multi_compare(
df,
benchmark,
independent = NULL,
dependent = NULL,
formula_list = NULL,
family = "ols",
rm_na = "pairwise",
out_output_list = TRUE,
out_df = FALSE,
out_models = FALSE,
print_p = FALSE,
print_se = FALSE,
weight = NULL,
id = NULL,
strata = NULL,
nest = FALSE,
weight_bench = NULL,
id_bench = NULL,
strata_bench = NULL,
nest_bench = FALSE,
robust_se = FALSE,
p_adjust = NULL,
names_df_benchmark = NULL,
silence_summary = FALSE,
nboots = 0,
parallel = FALSE,
adjustment_vars = NULL,
raking_targets = NULL,
post_targets = NULL
)
Arguments
df , benchmark |
A data frame containing the set of respondents or benchmark set of respondents to compare, or a character string containing the name of the set of respondents or benchmark set of respondents. All independent and dependent variables must be inside both data frames. |
independent |
A list of strings containing the independent variables (x)
for comparison. Every independent variable will be used in every model to
estimate the dependent variable (y). When a |
dependent |
A list of strings containing the dependent variables (y) for
comparison. One model will be computed for every dependent variable (y)
provided. When a |
formula_list |
A list of formulas to use in the regression models. If
given, |
family |
A family input, that can be given to |
rm_na |
A character to determine how to handle missing values. For this two
options are supported. If |
out_output_list |
A logical value. If |
out_df |
If |
out_models |
If True, GLM model objects will be part of the returned object. |
print_p |
If |
print_se |
If |
weight , weight_bench |
A character vector containing the name of the weight
variable in the respective data frame. If provided the data frame will be weighted
using the |
id , id_bench |
A character vector containing the name of the id variable in the respectiv data frame. Only needed for weighting. |
strata , strata_bench |
A character vector containing the name of the strata variable
in the respective data frame. It is used in the |
nest , nest_bench |
A logical vector that is used in the |
robust_se |
A logical value If |
p_adjust |
A logical input or character string indicating an adjustment
method usable in the |
names_df_benchmark |
A vector containing first the name of |
silence_summary |
A logical value, to indicate if the printed summary should not be printed instead. |
nboots |
A numeric value indicating the number of bootstrap replications.
If nboots = 0 no bootstrapping will be performed. Else |
parallel |
If |
adjustment_vars |
Variables used to adjust the survey when using raking or post-stratification. |
raking_targets |
A List of raking targets that can be given to the rake
function of |
post_targets |
A List of post_stratification targets that can be given to the rake
function of |
Value
A table is printed showing the difference between the set of respondents
for each model, as well as an indicator, if they differ significantly from each
other. It is generated using the chosen method
.
Ifout_output_list
= TRUE, also a list with additional information will
be returned that can be used in some additional packages of this function to
reprint the summary or to visualize the results.
Examples
#Example 1
## Make a comparison specifiying dependent and independent variables.
## Get Data for comparison
require(wooldridge)
card<-wooldridge::card
south <- card[card$south==1,]
north <- card[card$south==0,]
## use the function to plot the data
multi_data1<-sampcompR::multi_compare(df = north,
bench = south,
independent = c("age","fatheduc","motheduc","IQ"),
dependent = c("educ","wage"),
family="ols")
plot_multi_compare("multi_data1")
#Example 2
## Make a comparison with a formula_list
card<-wooldridge::card
south <- card[card$south==1,]
north <- card[card$south==0,]
form_list<-list(formula(educ~age+fatheduc+motheduc+IQ),
formula(wage~age+fatheduc+motheduc+IQ))
multi_data2 <- sampcompR::multi_compare(df = north,
bench = south,
formula_list = form_list,
family="ols")
plot_multi_compare("multi_data2")