Title: | Perform Permutation Test on General Linear and Mixed Linear Regression |
---|---|
Description: | We provide a solution for performing permutation tests on linear and mixed linear regression models. It allows users to obtain accurate p-values without making distributional assumptions about the data. By generating a null distribution of the test statistics through repeated permutations of the response variable, permutation tests provide a powerful alternative to traditional parameter tests (Holt et al. (2023) <doi:10.1007/s10683-023-09799-6>). In this early version, we focus on the permutation tests over observed t values of beta coefficients, i.e.original t values generated by parameter tests. After generating a null distribution of the test statistic through repeated permutations of the response variable, each observed t values would be compared to the null distribution to generate a p-value. To improve the efficiency,a stop criterion (Anscombe (1953) <doi:10.1111/j.2517-6161.1953.tb00121.x>) is adopted to force permutation to stop if the estimated standard deviation of the value falls below a fraction of the estimated p-value. By doing so, we avoid the need for massive calculations in exact permutation methods while still generating stable and accurate p-values. |
Authors: | Wentao Zeng [aut, cre, cph] |
Maintainer: | Wentao Zeng <[email protected]> |
License: | GPL-3 |
Version: | 0.1.9 |
Built: | 2024-12-25 06:47:15 UTC |
Source: | CRAN |
perform general and mixed linear regression by lm function in R base or lmer function in lmer/lmertest package and permutation tests on observed t values of beta coef -ficients
lmerp(formula, data, thresh, R, mixed, minimum)
lmerp(formula, data, thresh, R, mixed, minimum)
formula |
Regression formula in the form 'y~x1+x2+x3' for general linear function or 'y~x1+x2+x3+(1|x4)' or 'y~x1+x2+x3+(x3|x4)' for mixed linear function |
data |
A data frame specifying the data to be analysed |
thresh |
Threshold to stop iteration, default value is 0.1 |
R |
The maximum number of iteration, default value is 1000 |
mixed |
A logic value indicates if you desire to perform mixed linear model or not. Default value is FALSE. |
minimum |
The minimum number of iteration, default value is 50 |
A list contains 2 items: Results and T_perm, the former contains results of origi -nal parameter test and results of permutation test including adjusted confident interval (Ci_perm), p values (P_perm), iteration number(Iteration), the later contains a list cont -ains all t values generated in each permutation
formula<-mpg~cyl data<-mtcars my_perm<-lmerp(formula,data)
formula<-mpg~cyl data<-mtcars my_perm<-lmerp(formula,data)
perform permuation on response variable i.e. y, using the stop criterion suggested by Anscombe
permute_fun(data, mle)
permute_fun(data, mle)
data |
A data frame specifying the data to be analysed. |
mle |
A string that indicated response variable |
A data frame containing the data with a permuted y.
data<-mtcars permute<-permute_fun(data=data,mle='mpg')
data<-mtcars permute<-permute_fun(data=data,mle='mpg')
perform mixed linear regression in lmer/lmertest package for getting observed t values or permutation test
s1(data, formula)
s1(data, formula)
data |
A dataframe specifying the data to be analysed |
formula |
A formula in the form like'y~x1+x2+x3 in lm function |
An object of class "lm"
data<-mtcars formula<-mpg~cyl s1(data=data,formula=formula)
data<-mtcars formula<-mpg~cyl s1(data=data,formula=formula)
perform mixed linear regression in lmerTest package for getting observed t values or permutation test
s2(data, formula)
s2(data, formula)
data |
A dataframe specifying the data to be analysed |
formula |
A formula in the form like'y~x1+x2+x3+(1|x4) or like'y~x1+x2+x3 +(x3|x4) in lmer function |
An object of class "lmerTest"
data<-mtcars formula<-mpg~cyl+(1|gear) statistic<-s2(data=data,formula=formula)
data<-mtcars formula<-mpg~cyl+(1|gear) statistic<-s2(data=data,formula=formula)