Title: | Visualizing Sensitivity |
---|---|
Description: | Designed to help the user to determine the sensitivity of an proposed causal effect to unconsidered common causes. Users can create visualizations of sensitivity, effect sizes, and determine which pattern of effects would support a causal claim for between group differences. Number needed to treat formula from Kraemer H.C. & Kupfer D.J. (2006) <doi:10.1016/j.biopsych.2005.09.014>. |
Authors: | Erin M. Buchanan [aut, cre] |
Maintainer: | Erin M. Buchanan <[email protected]> |
License: | LGPL-3 |
Version: | 0.1.3 |
Built: | 2024-11-09 06:09:27 UTC |
Source: | https://github.com/doomlab/vise |
This function calculates the adjusted effect after controlling for confounding effects. You can use d values or standardized regression coefficients.
adjusted_coef(effect_xz, effect_uxz, effect_d)
adjusted_coef(effect_xz, effect_uxz, effect_d)
effect_xz |
Effect of x on y given z |
effect_uxz |
Effect of u on y given x and z |
effect_d |
Effect size difference of interest |
Adjusted effect size of x on y given u and z
adjusted_coef(effect_xz = .2, effect_uxz = .4, effect_d = .12)
adjusted_coef(effect_xz = .2, effect_uxz = .4, effect_d = .12)
A function that formats decimals and leading zeroes for creating reports in scientific style.
apa(value, decimals = 3, leading = TRUE)
apa(value, decimals = 3, leading = TRUE)
value |
A set of numeric values, either a single number, vector, or set of columns. |
decimals |
The number of decimal points desired in the output. |
leading |
Logical value: |
This function creates "pretty" character vectors from numeric variables for printing as part of a report. The value can take a single number, matrix, vector, or multiple columns from a data frame, as long as they are numeric. The values will be coerced into numeric if they are characters or logical values, but this process may result in an error if values are truly alphabetical.
Returns a nicely formatted character vector for numbers for reporting purposes.
apa(value = 0.54674, decimals = 3, leading = TRUE)
apa(value = 0.54674, decimals = 3, leading = TRUE)
for Between Subjects with Pooled SD DenominatorThis function displays d for two between subjects groups and gives the central and non-central confidence interval using the pooled standard deviation as the denominator.
calculate_d( m1 = NULL, m2 = NULL, sd1 = NULL, sd2 = NULL, n1 = NULL, n2 = NULL, t = NULL, model = NULL, df = NULL, x_col = NULL, y_col = NULL, d = NULL, a = 0.05, lower = TRUE )
calculate_d( m1 = NULL, m2 = NULL, sd1 = NULL, sd2 = NULL, n1 = NULL, n2 = NULL, t = NULL, model = NULL, df = NULL, x_col = NULL, y_col = NULL, d = NULL, a = 0.05, lower = TRUE )
m1 |
mean group one |
m2 |
mean group two |
sd1 |
standard deviation group one |
sd2 |
standard deviation group two |
n1 |
sample size group one |
n2 |
sample size group two |
t |
optional, calculate d from independent t, you must include n1 and n2 for degrees of freedom |
model |
optional, calculate d from t.test for independent t, you must still include n1 and n2 |
df |
optional dataframe that includes the x_col and y_col |
x_col |
name of the column that contains the factor levels OR a numeric vector of group 1 scores |
y_col |
name of the column that contains the dependent score OR a numeric vector of group 2 scores |
d |
a previously calculated d value from a study |
a |
significance level |
lower |
Use this to indicate if you want the lower or upper bound
of d for one sided confidence intervals. If d is positive, you generally
want |
To calculate , mean two is subtracted from mean one and divided
by the pooled standard deviation.
You should provide one combination of the following:
1: m1 through n2
2: t, n1, n2
3: model, n1, n2
4: df, "x_col", "y_col"
5: x_col, y_col as numeric vectors
6: d, n1, n2
You must provide alpha and lower to ensure the right confidence interval is provided for you.
Provides the effect size (Cohen's *d*) with associated central and non-central confidence intervals, the *t*-statistic, the confidence intervals associated with the means of each group, as well as the standard deviations and standard errors of the means for each group. The one-tailed confidence interval is also included for sensitivity analyses.
d |
effect size |
dlow |
noncentral lower level confidence interval of d value |
dhigh |
noncentral upper level confidence interval of d value |
dlow_central |
central lower level confidence interval of d value |
dhigh_central |
central upper level confidence interval of d value |
done_low |
noncentral lower bound of one tailed confidence interval |
done_low_central |
central lower bound of one tailed confidence interval |
M1 |
mean of group one |
sd1 |
standard deviation of group one mean |
se1 |
standard error of group one mean |
M1low |
lower level confidence interval of group one mean |
M1high |
upper level confidence interval of group one mean |
M2 |
mean of group two |
sd2 |
standard deviation of group two mean |
se2 |
standard error of group two mean |
M2low |
lower level confidence interval of group two mean |
M2high |
upper level confidence interval of group two mean |
spooled |
pooled standard deviation |
sepooled |
pooled standard error |
n1 |
sample size of group one |
n2 |
sample size of group two |
df |
degrees of freedom (n1 - 1 + n2 - 1) |
t |
t-statistic |
p |
p-value |
estimate |
the d statistic and confidence interval in APA style for markdown printing |
statistic |
the t-statistic in APA style for markdown printing |
calculate_d(m1 = 14.37, # neglect mean sd1 = 10.716, # neglect sd n1 = 71, # neglect n m2 = 10.69, # none mean sd2 = 8.219, # none sd n2 = 3653, # none n a = .05, # alpha/confidence interval lower = TRUE) # lower or upper bound
calculate_d(m1 = 14.37, # neglect mean sd1 = 10.716, # neglect sd n1 = 71, # neglect n m2 = 10.69, # none mean sd2 = 8.219, # none sd n2 = 3653, # none n a = .05, # alpha/confidence interval lower = TRUE) # lower or upper bound
This function allows you to convert d to
Cohen's f and statistics.
d_to_f2(d)
d_to_f2(d)
d |
the effect size to convert |
Both Cohen's f and f^2 statistics
f |
d values translated into f |
f2 |
d values translated into |
d_to_f2(.25)
d_to_f2(.25)
This function calculates the number needed to treat from continuous measures (Cohen's d) using Kraemer and Kupfer (2006) formula.
d_to_nnt(d = NULL)
d_to_nnt(d = NULL)
d |
the effect size |
nnt values from d
Kraemer H.C., Kupfer D.J. (2006) Size of treatment effects and their importance to clinical research and practice. Biolological Psychiatry, 59, 990–996. https://doi.org/10.1016/j.biopsych.2005.09.014
d_to_nnt(d = .25)
d_to_nnt(d = .25)
This function allows you to convert d to Pearson's correlation coefficient.
d_to_r(d)
d_to_r(d)
d |
the effect size to convert |
correlation coefficient
d_to_r(.25)
d_to_r(.25)
This function displays a visualization of effect sizes.
estimate_d( m1 = NULL, m2 = NULL, sd1 = NULL, sd2 = NULL, n1 = NULL, n2 = NULL, d = NULL, fill_1 = "lightblue", fill_2 = "pink", text_color = "black" )
estimate_d( m1 = NULL, m2 = NULL, sd1 = NULL, sd2 = NULL, n1 = NULL, n2 = NULL, d = NULL, fill_1 = "lightblue", fill_2 = "pink", text_color = "black" )
m1 |
mean from first group |
m2 |
mean from second group |
sd1 |
standard deviation from first group |
sd2 |
standard deviation from second group |
n1 |
sample size for first group |
n2 |
sample size for the second group |
d |
estimate of the effect size |
fill_1 |
a color code or name to fill the first distribution |
fill_2 |
a color code or name to fill the second distribution |
text_color |
a color code or name for the graph text |
Returns a pretty graph
d |
effect size |
graph |
A graph of the distributions of the effect size |
estimate_d(d = .25) estimate_d(m1 = 10, m2 = 8, sd1 = 5, sd2 = 4, n1 = 100, n2 = 75)
estimate_d(d = .25) estimate_d(m1 = 10, m2 = 8, sd1 = 5, sd2 = 4, n1 = 100, n2 = 75)
This function displays a visualization of effect sizes.
estimate_r(r = NULL)
estimate_r(r = NULL)
r |
a correlation to visualize |
Returns a pretty graph
graph |
A graph of the effect size |
estimate_r(r = .4)
estimate_r(r = .4)
This function allows you to convert other effect sizes to d including f, f squared, number needed to treat, correlation coefficient, probability of superiority, proportion overlap (u1, u2, u3, and proportion distribution overlap). Please note these are approximations.
other_to_d( f = NULL, f2 = NULL, nnt = NULL, r = NULL, prob = NULL, prop_u1 = NULL, prop_u2 = NULL, prop_u3 = NULL, prop_overlap = NULL )
other_to_d( f = NULL, f2 = NULL, nnt = NULL, r = NULL, prob = NULL, prop_u1 = NULL, prop_u2 = NULL, prop_u3 = NULL, prop_overlap = NULL )
f |
Cohen's f |
f2 |
Cohen's f squared |
nnt |
Number needed to treat |
r |
Correlation coefficient |
prob |
Probability superiority |
prop_u1 |
Proportion Overlap U1 |
prop_u2 |
Proportion Overlap U2 |
prop_u3 |
Proportion Overlap U3 |
prop_overlap |
Proportion Overlap of Distributions |
d effect size
other_to_d(f = .1)
other_to_d(f = .1)
This function calculates the probability of superiority from independent samples Cohen's d calculation.
probability_superiority( d = NULL, m1 = NULL, m2 = NULL, sd1 = NULL, sd2 = NULL, n1 = NULL, n2 = NULL, a = 0.05, t = NULL, model = NULL, df = NULL, x_col = NULL, y_col = NULL )
probability_superiority( d = NULL, m1 = NULL, m2 = NULL, sd1 = NULL, sd2 = NULL, n1 = NULL, n2 = NULL, a = 0.05, t = NULL, model = NULL, df = NULL, x_col = NULL, y_col = NULL )
d |
the effect size |
m1 |
mean group one |
m2 |
mean group two |
sd1 |
standard deviation group one |
sd2 |
standard deviation group two |
n1 |
sample size group one |
n2 |
sample size group two |
a |
significance level |
t |
optional, calculate d from independent t, you must include n1 and n2 for degrees of freedom |
model |
optional, calculate d from t.test for independent t, you must still include n1 and n2 |
df |
optional dataframe that includes the x_col and y_col |
x_col |
name of the column that contains the factor levels OR a numeric vector of group 1 scores |
y_col |
name of the column that contains the dependent score OR a numeric vector of group 2 scores |
You should provide one combination of the following:
1: d
2: m1 through n2
3: t, n1, n2
4: model, n1, n2
5: df, "x_col", "y_col"
6: x_col, y_col as numeric vectors
The probability of superiority.
probability_superiority(d = .25)
probability_superiority(d = .25)
This function calculates the proportion overlap from two independent group d effect size calculations. Cohen's u1, u2, u3 and proportion overlap are provided.
proportion_overlap( model = NULL, x_col = NULL, y_col = NULL, df = NULL, d = NULL )
proportion_overlap( model = NULL, x_col = NULL, y_col = NULL, df = NULL, d = NULL )
model |
a saved independent t-test model |
x_col |
name of the column that contains the factor levels OR a numeric vector of group 1 scores |
y_col |
name of the column that contains the dependent score OR a numeric vector of group 2 scores |
df |
optional dataframe that includes the x_col and y_col |
d |
previously calculated d value |
A list of the following:
u1 |
Proportion of non-overlap across both distributions |
u2 |
Proportion that one group is more than the same proportion in the other group |
u3 |
Proportion of one group that is smaller than the median of the other group |
p_o |
Proportional overlap of distributions |
proportion_overlap(d = .25)
proportion_overlap(d = .25)
This function is a convenience function to help you easily run the shiny app for the package.
runExample()
runExample()
Opens the shiny app version of the package to use interactively.
This function displays a visualization of the possible bias c that allows for a non-zero effect in sensitivity.
visualize_c(dlow, lower = TRUE, ribbon_color = "lightblue")
visualize_c(dlow, lower = TRUE, ribbon_color = "lightblue")
dlow |
The lower limit of the possible effect size |
lower |
Use this to indicate if you want the lower or upper bound
of d for one sided confidence intervals. If d is positive, you generally
want |
ribbon_color |
background coloring for c values that support a non-zero effect in sensitivity |
Returns a pretty graph
graph |
The graph of possible values for c |
visualize_c(dlow = .25, lower = TRUE)
visualize_c(dlow = .25, lower = TRUE)
This function displays a visualization of the possible bias c that allows for a non-zero effect in sensitivity. This function includes the ability to add values of effect size and correlation to see how they map onto the proposed c value.
visualize_c_map( dlow, r_values, d_values = NULL, f_values = NULL, f2_values = NULL, nnt_values = NULL, prob_values = NULL, prop_u1_values = NULL, prop_u2_values = NULL, prop_u3_values = NULL, prop_overlap_values = NULL, point_colors = c("red", "green", "blue"), size = 2, shape_1 = 2, shape_2 = 3, ribbon_color = "lightblue", lower = TRUE )
visualize_c_map( dlow, r_values, d_values = NULL, f_values = NULL, f2_values = NULL, nnt_values = NULL, prob_values = NULL, prop_u1_values = NULL, prop_u2_values = NULL, prop_u3_values = NULL, prop_overlap_values = NULL, point_colors = c("red", "green", "blue"), size = 2, shape_1 = 2, shape_2 = 3, ribbon_color = "lightblue", lower = TRUE )
dlow |
The lower limit of the possible effect size (required). |
r_values |
A vector of correlation values that are possible (required). |
d_values |
A vector of effect size values that are possible. |
f_values |
A vector of f effect size values that are possible. |
f2_values |
A vector of f2 effect size values that are possible. |
nnt_values |
A vector of number needed to treat effect size values that are possible. |
prob_values |
A vector of probability of superiority effect size values that are possible. |
prop_u1_values |
A vector of proportion of overlap u1 effect size values that are possible. |
prop_u2_values |
A vector of proportion of overlap u2 effect size values that are possible. |
prop_u3_values |
A vector of proportion of overlap u3 effect size values that are possible. |
prop_overlap_values |
A vector of proportion of distribution overlap effect size values that are possible. |
point_colors |
A vector of color names or codes to plot the effect sizes on the graph. You should use as many color names/codes as you have max of an effect size (i.e, if r has 4, d has 3, and prob has 5, then use 5 as the max number of colors). |
size |
The size of the symbols on the chart. |
shape_1 |
a numeric value of one of the ggplot2 shapes |
shape_2 |
a numeric value of one of the ggplot2 shapes - if you use different numbers, the two shapes are overlaid, as we found this effect made it easier to read with many effect sizes plotted on the same graph. |
ribbon_color |
a color name or code to shade the area that shows a non-zero effect in sensitivity. |
lower |
Use this to indicate if you want the lower or upper bound
of d for one sided confidence intervals. If d is positive, you generally
want |
Returns a pretty graph of the possible effect size and correlation combinations with the region of effect colored in. Note that all effect sizes are converted to d for the graph.
graph |
The graph of possible values for c |
visualize_c_map(dlow = .25, d_values = c(.2, .3, .8), r_values = c(.1, .4, .3), lower = TRUE)
visualize_c_map(dlow = .25, d_values = c(.2, .3, .8), r_values = c(.1, .4, .3), lower = TRUE)
This function displays a visualization the same effect in
various effect sizes including d, f, , proportion
overlap, correlation, number needed to treat, and more.
visualize_effects( d, circle_color = "lightblue", circle_fill = "grey", percent_color = "black", percent_size = 12, text_color = "black", font_family = "Times" )
visualize_effects( d, circle_color = "lightblue", circle_fill = "grey", percent_color = "black", percent_size = 12, text_color = "black", font_family = "Times" )
d |
d effect size to convert to other numbers |
circle_color |
a color name or code for the highlighted part of the donut circle |
circle_fill |
a color name or code for the rest of the circle |
percent_color |
a color name or code for the text of the effect size |
percent_size |
a numeric value representing the font size of the larger effect size text inside the circle |
text_color |
a color name or code that changes the color of the effect size text label |
font_family |
A font family name for the font of the effect size text label |
Returns a pretty graph of all the effects
graph |
ggplot object of converted effect sizes |
visualize_effects(d = .25)
visualize_effects(d = .25)