Package 'homnormal'

Title: Tests of Homogeneity of Variances
Description: Most common exact, asymptotic and resample based tests are provided for testing the homogeneity of variances of k normal distributions under normality. These tests are Barlett, Bhandary & Dai, Brown & Forsythe, Chang et al., Gokpinar & Gokpinar, Levene, Liu and Xu, Gokpinar. Also, a data generation function from multiple normal distribution is provided using any multiple normal parameters. Bartlett, M. S. (1937) <doi:10.1098/rspa.1937.0109> Bhandary, M., & Dai, H. (2008) <doi:10.1080/03610910802431011> Brown, M. B., & Forsythe, A. B. (1974).<doi:10.1080/01621459.1974.10482955> Chang, C. H., Pal, N., & Lin, J. J. (2017) <doi:10.1080/03610918.2016.1202277> Gokpinar E. & Gokpinar F. (2017) <doi:10.1080/03610918.2014.955110> Liu, X., & Xu, X. (2010) <doi:10.1016/j.spl.2010.05.017> Levene, H. (1960) <https://cir.nii.ac.jp/crid/1573950400526848896> Gökpınar, E. (2020) <doi:10.1080/03610918.2020.1800037>.
Authors: Fikri Gökpınar [aut, cre] , Esra Gökpınar [aut]
Maintainer: Fikri Gökpınar <[email protected]>
License: GPL-2
Version: 0.1
Built: 2025-03-12 03:13:51 UTC
Source: https://github.com/cran/homnormal

Help Index


Bartlett Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups.

Usage

bart(x1, x2, alfa = 0.05, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Bartlett, M. S. (1937). "Properties of sufficiency and statistical tests". Proceedings of the Royal Statistical Society, Series A 160, 268–282 JSTOR.

See Also

levene Brown_Forsythe, Cat_GG, Cat_LR, genp, slrt, bdai

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   bart(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   bart(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
    bart(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    bart(x1,x2,alfa=0.10,table=FALSE,graph="centerized")
     readline(prompt = "Pause. Press <Enter> to continue...")
    bart(x1,x2,alfa=0.10,table=FALSE,graph="none")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value

Bahandary-Dai Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups using Bahandary-Dai test.

Usage

bdai(x1, x2, alfa = 0.05, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Bhandary, M., & Dai, H. (2008). An alternative test for the equality of variances for several populations when the underlying distributions are normal. Communications in Statistics-Simulation and Computation, 38(1), 109-117.

See Also

Brown_Forsythe, Cat_GG, Cat_LR, genp, slrt, levene

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   bdai(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   bdai(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
    bdai(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    bdai(x1,x2,alfa=0.10,table=FALSE,graph="raw")
    readline(prompt = "Pause. Press <Enter> to continue...")
    bdai(x1,x2,alfa=0.10,table=FALSE,graph="none")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value

Brown-Forsythe Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups.

Usage

Brown_Forsythe(x1, x2, alfa = 0.05, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Brown, M. B., & Forsythe, A. B. (1974). Robust tests for the equality of variances. Journal of the American Statistical Association, 69(346), 364-367.

See Also

bdai, Cat_GG, Cat_LR, genp, slrt, levene,

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   Brown_Forsythe(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   Brown_Forsythe(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
    Brown_Forsythe(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    Brown_Forsythe(x1,x2,alfa=0.10,table=FALSE,graph="raw")
    readline(prompt = "Pause. Press <Enter> to continue...")
    Brown_Forsythe(x1,x2,alfa=0.10,table=FALSE,graph="none")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value

Computational Approach Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups using standartized likelihood ratio test.

Usage

Cat_GG(x1, x2, alfa = 0.05, m = 2000, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

m

number of resampling.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Gokpinar, E., & Gokpinar, F. (2017). Testing equality of variances for several normal populations. Communications in Statistics-Simulation and Computation, 46(1), 38-52.

See Also

Brown_Forsythe, bdai, Cat_LR, genp, slrt, levene

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   Cat_GG(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   Cat_GG(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
    Cat_GG(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    Cat_GG(x1,x2,alfa=0.10,table=FALSE,graph="raw")
    readline(prompt = "Pause. Press <Enter> to continue...")
    Cat_GG(x1,x2,alfa=0.10,table=FALSE,graph="none")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value

Computational Approach Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups using standartized likelihood ratio test.

Usage

Cat_LR(x1, x2, alfa = 0.05, m = 2000, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

m

number of resampling.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Chang, C. H., Pal, N., & Lin, J. J. (2017). A revisit to test the equality of variances of several populations. Communications in Statistics-Simulation and Computation, 46(8), 6360-6384.

See Also

Brown_Forsythe, Cat_GG, bdai, genp, slrt, levene

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   Cat_LR(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   Cat_LR(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
    Cat_LR(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    Cat_LR(x1,x2,alfa=0.10,table=FALSE,graph="raw")
    readline(prompt = "Pause. Press <Enter> to continue...")
    Cat_LR(x1,x2,alfa=0.10,m=5000,table=FALSE,graph="none")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value

Multiple Normal Distribution Data Generation

Description

This function generates data from multiple normal distribution.

Usage

datagen(n, mu, sigma, tn = 1)

Arguments

n

Sample sizes of each group. n=c(n1,n2,...nk); for example: n=c(3, 4, 5).

mu

Mean of each group.mu=c(mu1,mu2,...muk); for example: mu=c(3, 4, 5).

sigma

Standard deviation of each group.sigma=c(sigma1,sigma2,...sigmak); for example: sigma=c(1, 2, 3).

tn

Trial number for all groups. Default of the parameter is 1. This parameter for use more than 1, is especially useful for resampling such as Monte Carlo, Parametric Bootstrap.

Value

a data matrix with size (n1,n2,...nk) with group number 1,2,...k at first row and random number with mnean mu=(mu1,mu2,...muk) and standard deviation sigma=(sigma1,sigma2,...sigmak)

Examples

n=c(3, 4, 5)
mu=c(3, 4, 5)
sigma=c(3, 4, 5)
F=datagen(n,mu,sigma);muh=F[1];S2h=F[2];x=F[3]
muh
S2h
x

# Following example especially useful for simulation based tecnhiques
# such as Monte Carlo, Parametric Bootstrap and comparison studies
# by using simulation.

 Fm=datagen(c(3, 4, 5),c(3, 4, 5),c(3, 4, 5),10);muhm=Fm[1];S2hm=Fm[2];xm=Fm[3]
muhm
S2hm
xm

Fleming and Harrington Data

Description

The data related to survival times of patients was collected from 4 hospitals, which was a part of the data by given Fleming and Harrington(1991). The data contain failure time of the patients.

Usage

data(FH_data)

Format

A dataframe with 21 rows 2 variables

HospitalNo

Hospital No

SurvivalTime

Survival Time of Patients

Source

T.R. Fleming and D.P. Harrington, Counting processes and survival analysis. Wiley Online Library, Vol. 8., 1991.

Examples

data("FH_data")
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo

Generalized p value Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups using generalized p value test.

Usage

genp(x1, x2, alfa = 0.05, m = 2000, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

m

number of resampling.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Liu, X., & Xu, X. (2010). A new generalized p-value approach for testing the homogeneity of variances. Statistics & probability letters, 80(19-20), 1486-1491.

See Also

Brown_Forsythe, Cat_GG, Cat_LR, bdai, slrt, levene

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   genp(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   genp(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
   genp(x1,x2,alfa=0.10,m=5000)
   readline(prompt = "Pause. Press <Enter> to continue...")
    genp(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    genp(x1,x2,alfa=0.10,table=FALSE,graph="raw")
    readline(prompt = "Pause. Press <Enter> to continue...")
    genp(x1,x2,alfa=0.10,table=FALSE,graph="none")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value

Levene Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups.

Usage

levene(x1, x2, alfa = 0.05, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Levene, H. (1960). Robust tests for equality of variances, p 278–292. Contributions to probability and statistics: essays in honor of Harold Hotelling. Stanford University Press, Palo Alto, CA.

See Also

Brown_Forsythe, Cat_GG, Cat_LR, genp, slrt, bdai

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   levene(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   levene(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
    levene(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    levene(x1,x2,alfa=0.10,table=FALSE,graph="raw")
    readline(prompt = "Pause. Press <Enter> to continue...")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value

Standartized Likelihood Ratio Test for Homogeniety

Description

Tests the homogeniety of variances for more than two normal groups using standartized likelihood ratio test.

Usage

slrt(x1, x2, alfa = 0.05, table = TRUE, graph = "none")

Arguments

x1

a numeric matrix containing the values of groups.

x2

numeric matrix containing the values of group numbers.

alfa

significance level of the test. Default number is 0.05.

table

a logical variable that indicates table will appear or not. Default is TRUE.

graph

box plot of groups of raw or centered data.

Value

if table is TRUE, then it gives a detailed table, else it gives a vector of r value(r=1 when null hypothesis was rejected and r=0 when null hypothesis was accepted) p-value and test statistic value.

References

Gökpınar, E. (2020). Standardized likelihood ratio test for homogeneity of variance of several normal populations. Communications in Statistics-Simulation and Computation, 1-11.

See Also

Brown_Forsythe, datagen,levene, Cat_LR, genp

Examples

data(FH_data)
   x1=FH_data$SurvivalTime
   x2=FH_data$HospitalNo
   slrt(x1,x2)
   readline(prompt = "Pause. Press <Enter> to continue...")
   slrt(x1,x2,alfa=0.10)
   readline(prompt = "Pause. Press <Enter> to continue...")
    slrt(x1,x2,alfa=0.10,table=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    slrt(x1,x2,alfa=0.10,table=FALSE,graph=FALSE)
    readline(prompt = "Pause. Press <Enter> to continue...")
    slrt(x1,x2,alfa=0.10,table=FALSE,graph="none")
# ---THIS VERSION IS ESPECIALLY USEFUL FOR COMPARISON STUDIES BY SIMULATION---
#    #first value of the vector is r value(r=1 when rejected and r=0 when accepted null hypothesis)
# second value of the vector is the p-value and third value is the tests statistic value