Average Attributable Fraction and Other Relevant Social Sciences Indicators

Compute Average Attributable Fraction (AAF) and produce a GT table with Odds.ratio, Average Marginal Effects and AAF, with confidence interval and p.value. Also compute other metrics such as Yule's Q and Cramer's V. For more details, see Fergusion and al. (2024) .


SocialFacts

R-CMD-check

SocialFacts brings a tool to produce easily multiple indicators commonly used in social sciences :

  • Odds Ratio, with p.value and CI
  • Average Marginal Effects, with CI
  • A cramer's V table, to check correlation between your categorical variables
  • A gt table with Yule's Q value compute against the vars_dep argument.
  • A new tool called Average Attributable Fraction, described by Ferguson and al. here : We use the original graphPAF library, and facilitate it's use to produce a table which resume all of this tools in one place.

Installation

You can install the development version of SocialFacts like so:

devtools::install_github("Geminy3/SocialFacts")

of install it via CRAN :

install.packages("SocialFacts")

Example

This is a basic example which shows you how to solve a common problem:

library(SocialFacts)
## basic example code

### Fit a logistic model
model <- glm(var_dep ~ some + var + you + have, data = data, family = binomial(...))

### You can check the correlation between your categorical data
get_cramer(var = c("var_1", "var_2"), metric = 'cramer', data = data)

### To compute and store the AAF
resAAF <- get_AAF(model = model, nvar = 3, vars_dep = "var_dep", data = data)

### To get the summary table
resume_tab <- result_tab(result_tab(model = model, var_ref = "var_dep", var_names = c("var_1", "var_2"),
                       res_AAF = resAAF$res, data = data)

### To view the table
resume_tab

### To export the table
resume_tab |>
  gtsave(filename = "~/the/path/to/store/it/TAB_RECAP.png", expand = 10)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("SocialFacts")

1.3.0 by Alioscha Massein, 3 months ago


https://github.com/Geminy3/SocialFacts, https://geminy3.github.io/SocialFacts/


Report a bug at https://github.com/Geminy3/SocialFacts/issues


Browse source code at https://github.com/cran/SocialFacts


Authors: Alioscha Massein [aut, cre, cph] (ORCID: , Brice Lefèvre [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports averisk, broom.helpers, dplyr, graphPAF, gt, psych, gtsummary, rcompanion, scales, stats, stringr, weights, questionr, katex, marginaleffects

Suggests knitr, rmarkdown, testthat


See at CRAN