| Title: | Permutation-Based Significance Testing for Regression Models |
|---|---|
| Description: | Wraps glm(), lme4::lmer(), and binomial glm() with a permutation loop to compute nonparametric p-values. For each model, ptestR generates a null distribution of the test statistic by randomly rearranging the outcome variable, then computes p.perm as the proportion of permuted statistics at least as extreme as the observed one. This approach requires far fewer distributional assumptions than standard Wald or likelihood-ratio tests, making it well-suited to neuroimaging, EEG, and other biomedical datasets with repeated measures and small samples. |
| Authors: | Lucas G. S. França [aut, cre] (ORCID: <https://orcid.org/0000-0003-0853-1319>), Yan Ge [aut], Dafnis Batalle [aut] (ORCID: <https://orcid.org/0000-0003-2097-979X>) |
| Maintainer: | Lucas G. S. França <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.1 |
| Built: | 2026-07-02 15:02:22 UTC |
| Source: | https://github.com/CoDe-Neuro/ptestR |
grouped_perm_binoglm is a nonparametric test for binomial
logistic regression. It assesses the significance of coefficients by
permutation, computing the null distribution of the z-statistic by
randomly rearranging the binary outcome variable.
grouped_perm_binoglm(tbl, formla, var_to_perm, permNum = 1000, seed = 42)grouped_perm_binoglm(tbl, formla, var_to_perm, permNum = 1000, seed = 42)
tbl |
A data frame or tibble containing all model variables. |
formla |
A formula describing the logistic regression model;
passed to |
var_to_perm |
Character. Name of the binary outcome column to permute. |
permNum |
Integer. Number of permutations to generate. Default |
seed |
Integer. Random seed for reproducibility; passed to
|
A tibble with one row per model term and columns:
termName of the regression term.
estimateEstimated log-odds coefficient.
statisticObserved z-statistic.
p.valueAsymptotic two-sided p-value from the fitted model.
p.permPermutation p-value: proportion of permuted |statistics|
>= |observed statistic|. A value of 0 means no permuted statistic
was as extreme; report as p < 1/permNum.
counts <- c(10, 11, 8, 9, 6, 3, 5, 1) gender <- c(0, 0, 0, 0, 0, 1, 1, 1) TBL <- data.frame(counts, gender) grouped_perm_binoglm(TBL, gender ~ counts, "gender", permNum = 500, seed = 1)counts <- c(10, 11, 8, 9, 6, 3, 5, 1) gender <- c(0, 0, 0, 0, 0, 1, 1, 1) TBL <- data.frame(counts, gender) grouped_perm_binoglm(TBL, gender ~ counts, "gender", permNum = 500, seed = 1)
grouped_perm_glm is a nonparametric test for generalised
linear models. It assesses the significance of coefficients by
permutation, computing the distribution of the test statistic by
randomly rearranging the outcome variable.
grouped_perm_glm( tbl, formla, var_to_perm, family = gaussian, permNum = 1000, seed = 42 )grouped_perm_glm( tbl, formla, var_to_perm, family = gaussian, permNum = 1000, seed = 42 )
tbl |
A data frame or tibble containing all model variables. |
formla |
A formula describing the regression model to fit;
passed directly to |
var_to_perm |
Character. Name of the column to permute (typically the outcome variable). |
family |
A description of the error distribution and link function;
passed to |
permNum |
Integer. Number of permutations to generate. Default |
seed |
Integer. Random seed for reproducibility; passed to
|
A tibble with one row per model term and columns:
termName of the regression term.
estimateEstimated coefficient.
statisticObserved t-statistic.
p.valueAsymptotic two-sided p-value from the fitted model.
p.permPermutation p-value: proportion of permuted |statistics|
>= |observed statistic|. A value of 0 means no permuted statistic
was as extreme; report as p < 1/permNum.
counts <- sample(1:100, 9, replace = TRUE) outcomes <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) treatment <- gl(3, 3) TBL <- data.frame(counts, outcomes, treatment) grouped_perm_glm(TBL, outcomes ~ counts + treatment, "outcomes")counts <- sample(1:100, 9, replace = TRUE) outcomes <- c(18, 17, 15, 20, 10, 20, 25, 13, 12) treatment <- gl(3, 3) TBL <- data.frame(counts, outcomes, treatment) grouped_perm_glm(TBL, outcomes ~ counts + treatment, "outcomes")
grouped_perm_glmm is a nonparametric test for linear
mixed-effects models. It assesses the significance of fixed-effect
coefficients by permutation, computing the null distribution of the
test statistic by randomly rearranging the outcome variable while
preserving the random-effects structure.
grouped_perm_glmm(tbl, formla, var_to_perm, permNum = 1000, seed = 42)grouped_perm_glmm(tbl, formla, var_to_perm, permNum = 1000, seed = 42)
tbl |
A data frame or tibble containing all model variables. |
formla |
A formula with both fixed- and random-effects parts;
passed directly to |
var_to_perm |
Character. Name of the column to permute (typically the outcome variable). |
permNum |
Integer. Number of permutations to generate. Default |
seed |
Integer. Random seed for reproducibility; passed to
|
A tibble with one row per fixed-effect term and columns:
termName of the regression term.
effectAlways "fixed" (random-parameter rows are dropped).
estimateEstimated coefficient.
statisticObserved t-statistic.
p.permPermutation p-value: proportion of permuted |statistics|
>= |observed statistic|. Replaces the conventional p.value because
lme4::lmer does not compute degrees of freedom or p-values by
default. A value of 0 means no permuted statistic was as extreme;
report as p < 1/permNum.
## Not run: library(sdamr) data("anchoring") grouped_perm_glmm( anchoring, everest_feet ~ anchor + sex + (1 | referrer), "everest_feet" ) ## End(Not run)## Not run: library(sdamr) data("anchoring") grouped_perm_glmm( anchoring, everest_feet ~ anchor + sex + (1 | referrer), "everest_feet" ) ## End(Not run)