Title: | Higher Order Likelihood Inference Web Applications |
---|---|
Description: | Higher order likelihood inference is a promising approach for analyzing small sample size data. The 'holi' package provides web applications for higher order likelihood inference. It currently supports linear, logistic, and Poisson generalized linear models through the rstar_glm() function, based on Pierce and Bellio (2017) <doi:10.1111/insr.12232> and 'likelihoodAsy'. The package offers two main features: LA_rstar(), which launches an interactive 'shiny' application allowing users to fit models with rstar_glm() through their web browser, and sim_rstar_glm_pgsql(), which streamlines the process of launching a web-based 'shiny' simulation application that saves results to a user-created 'PostgreSQL' database. |
Authors: | Mackson Ncube [aut, cre], mightymetrika, LLC [cph, fnd] |
Maintainer: | Mackson Ncube <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1.9000 |
Built: | 2024-11-03 06:08:03 UTC |
Source: | https://github.com/mightymetrika/holi |
This function launches a Shiny application that facilitates the setup and execution of likelihoodAsy rstar analysis. The app allows users to upload a dataset, specify a model and parameters of interest, and perform the analysis with the option to compute confidence intervals for r* statistics.
LA_rstar()
LA_rstar()
A Shiny app object that can be run locally.
Pierce, D. A., & Bellio, R. (2017). Modern Likelihood-Frequentist Inference. International Statistical Review / Revue Internationale de Statistique, 85(3), 519–541. doi:10.1111/insr.12232
Bellio R, Pierce D (2020). likelihoodAsy: Functions for Likelihood Asymptotics. R package version 0.51, https://CRAN.R-project.org/package=likelihoodAsy.
if (interactive()) { LA_rstar() }
if (interactive()) { LA_rstar() }
The rstar_glm
function computes r* statistics for hypothesis testing
on coefficients of interest in generalized linear models (GLMs).
It supports logistic, linear, and Poisson regression models. For logistic
models, the outcome must be binary.
rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## S3 method for class 'logistic' rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## S3 method for class 'linear' rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## S3 method for class 'poisson' rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## Default S3 method: rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... )
rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## S3 method for class 'logistic' rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## S3 method for class 'linear' rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## S3 method for class 'poisson' rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... ) ## Default S3 method: rstar_glm( .formula, .data, .model = c("logistic", "linear", "poisson"), .psidesc = "Coefficient of Interest", .psival = 0, .fpsi = 2, .rstar.ci = FALSE, trace = FALSE, ... )
.formula |
A formula specifying the model. |
.data |
A data frame containing the variables in the model. |
.model |
The type of GLM model: "logistic", "linear", or "poisson". |
.psidesc |
A description of the parameter of interest. |
.psival |
The value of the parameter of interest under the null hypothesis. |
.fpsi |
The index of the parameter of interest. |
.rstar.ci |
Logical; if TRUE, compute confidence intervals for r*. |
trace |
Logical; if TRUE, print information about computation. (Default is FALSE) |
... |
Additional arguments passed to the likelihoodAsy functions. |
A list with the object returned from likelihoodAsy::rstar (rs
),
the object returned from likelihoodAsy::rstar.ci (rs_ci
), and the object
returned from stats::glm (fit_glm
).
Pierce, D. A., & Bellio, R. (2017). Modern Likelihood-Frequentist Inference. International Statistical Review / Revue Internationale de Statistique, 85(3), 519–541. doi:10.1111/insr.12232
Bellio R, Pierce D (2020). likelihoodAsy: Functions for Likelihood Asymptotics. R package version 0.51, https://CRAN.R-project.org/package=likelihoodAsy.
# Logistic model rstar_glm(law ~ DriversKilled + VanKilled + drivers + kms, .data = Seatbelts, .model = "logistic") |> suppressWarnings() # Poisson model rstar_glm(count ~ spray, .data = InsectSprays, .model = "poisson") |> suppressWarnings() # Linear model rstar_glm(mpg ~ wt + hp, .data = mtcars, .model = "linear") |> suppressWarnings()
# Logistic model rstar_glm(law ~ DriversKilled + VanKilled + drivers + kms, .data = Seatbelts, .model = "logistic") |> suppressWarnings() # Poisson model rstar_glm(count ~ spray, .data = InsectSprays, .model = "poisson") |> suppressWarnings() # Linear model rstar_glm(mpg ~ wt + hp, .data = mtcars, .model = "linear") |> suppressWarnings()
This function runs multiple iterations of simulation for the sim_rstar_glm
function and summarizes the results, including rejection rates, bias, empirical
standard error, mean squared error, and root mean squared error.
run_sim_rstar_glm( n_sims, alpha_level = 0.05, n_main, n_covariates, true_coef_main, n_control = NULL, true_coef_control = NULL, treatment_effect = NULL, model = c("logistic", "linear", "poisson"), skewness_main = NULL, skewness_control = NULL, Sigma_main = NULL, Sigma_control = NULL, ... )
run_sim_rstar_glm( n_sims, alpha_level = 0.05, n_main, n_covariates, true_coef_main, n_control = NULL, true_coef_control = NULL, treatment_effect = NULL, model = c("logistic", "linear", "poisson"), skewness_main = NULL, skewness_control = NULL, Sigma_main = NULL, Sigma_control = NULL, ... )
n_sims |
Number of simulations to run. |
alpha_level |
Significance level for hypothesis tests. |
n_main |
Number of observations in the main group. |
n_covariates |
Number of covariates. |
true_coef_main |
True coefficients for the main group. |
n_control |
Number of observations in the control group. |
true_coef_control |
True coefficients for the control group. |
treatment_effect |
Treatment effect size. |
model |
Type of model: "logistic", "linear", or "poisson". |
skewness_main |
Skewness for the main group covariates. |
skewness_control |
Skewness for the control group covariates. |
Sigma_main |
Covariance matrix for the main group covariates. |
Sigma_control |
Covariance matrix for the control group covariates. |
... |
Additional arguments passed to |
A list with the results of each simulation and a summary of the results.
Pierce, D. A., & Bellio, R. (2017). Modern Likelihood-Frequentist Inference. International Statistical Review / Revue Internationale de Statistique, 85(3), 519–541. doi:10.1111/insr.12232
Bellio R, Pierce D (2020). likelihoodAsy: Functions for Likelihood Asymptotics. R package version 0.51, https://CRAN.R-project.org/package=likelihoodAsy.
sim_summary <- run_sim_rstar_glm( n_sims = 2, alpha_level = 0.05, n_main = 100, n_covariates = 2, true_coef_main = c(0.5, -0.3), n_control = 100, true_coef_control = c(0.2, -0.1), treatment_effect = 1, model = "linear" ) |> suppressWarnings()
sim_summary <- run_sim_rstar_glm( n_sims = 2, alpha_level = 0.05, n_main = 100, n_covariates = 2, true_coef_main = c(0.5, -0.3), n_control = 100, true_coef_control = c(0.2, -0.1), treatment_effect = 1, model = "linear" ) |> suppressWarnings()
This function generates simulated data for main and control groups, fits a generalized linear model (GLM) and an r* model, and returns the results.
sim_rstar_glm( n_main, n_covariates, true_coef_main, n_control = NULL, true_coef_control = NULL, treatment_effect = NULL, model = c("logistic", "linear", "poisson"), skewness_main = NULL, skewness_control = NULL, Sigma_main = NULL, Sigma_control = NULL, ... )
sim_rstar_glm( n_main, n_covariates, true_coef_main, n_control = NULL, true_coef_control = NULL, treatment_effect = NULL, model = c("logistic", "linear", "poisson"), skewness_main = NULL, skewness_control = NULL, Sigma_main = NULL, Sigma_control = NULL, ... )
n_main |
Number of observations in the main group. |
n_covariates |
Number of covariates. |
true_coef_main |
True coefficients for the main group. |
n_control |
Number of observations in the control group. |
true_coef_control |
True coefficients for the control group. |
treatment_effect |
Treatment effect size. |
model |
Type of model: "logistic", "linear", or "poisson". |
skewness_main |
Skewness for the main group covariates. |
skewness_control |
Skewness for the control group covariates. |
Sigma_main |
Covariance matrix for the main group covariates. |
Sigma_control |
Covariance matrix for the control group covariates. |
... |
Additional arguments passed to |
A list with fitted GLM and r* models, and the simulated data.
Pierce, D. A., & Bellio, R. (2017). Modern Likelihood-Frequentist Inference. International Statistical Review / Revue Internationale de Statistique, 85(3), 519–541. doi:10.1111/insr.12232
Bellio R, Pierce D (2020). likelihoodAsy: Functions for Likelihood Asymptotics. R package version 0.51, https://CRAN.R-project.org/package=likelihoodAsy.
sim_result <- sim_rstar_glm( n_main = 100, n_covariates = 2, true_coef_main = c(0.5, -0.3), n_control = 100, true_coef_control = c(0.2, -0.1), treatment_effect = 0.5, model = "logistic" ) |> suppressWarnings()
sim_result <- sim_rstar_glm( n_main = 100, n_covariates = 2, true_coef_main = c(0.5, -0.3), n_control = 100, true_coef_control = c(0.2, -0.1), treatment_effect = 0.5, model = "logistic" ) |> suppressWarnings()
This function launches a Shiny application for setting up and running simulations
based on the rstar_glm
function. The app allows users to input parameters for the
simulation, run the simulation, view results, and save results to a PostgreSQL database.
sim_rstar_glm_pgsql(dbname, datatable, host, port, user, password)
sim_rstar_glm_pgsql(dbname, datatable, host, port, user, password)
dbname |
The name of the PostgreSQL database. |
datatable |
The name of the table in the PostgreSQL database to save the results. |
host |
The host of the PostgreSQL database. |
port |
The port of the PostgreSQL database. |
user |
The username for accessing the PostgreSQL database. |
password |
The password for accessing the PostgreSQL database. |
A Shiny app object that can be run locally.
Pierce, D. A., & Bellio, R. (2017). Modern Likelihood-Frequentist Inference. International Statistical Review / Revue Internationale de Statistique, 85(3), 519–541. doi:10.1111/insr.12232
Bellio R, Pierce D (2020). likelihoodAsy: Functions for Likelihood Asymptotics. R package version 0.51, https://CRAN.R-project.org/package=likelihoodAsy.
if (interactive()) { sim_rstar_glm_pgsql( dbname = "mydb", datatable = "simulation_results", host = "localhost", port = 5432, user = "myuser", password = "mypassword" ) }
if (interactive()) { sim_rstar_glm_pgsql( dbname = "mydb", datatable = "simulation_results", host = "localhost", port = 5432, user = "myuser", password = "mypassword" ) }