| Title: | Estimation and Testing of Hypothesis |
|---|---|
| Description: | A collection of functions to do some statistical inferences. On estimation, it has the function to get the method of moments estimates, the sampling interval. In terms of testing it has function of doing most powerful test. |
| Authors: | Produymna Ghose Majumdar [aut, cre], Sangbartta Banerjee [aut] |
| Maintainer: | Produymna Ghose Majumdar <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-18 07:57:26 UTC |
| Source: | https://github.com/cran/MOM |
function to get the method of moment estimate(s) of beta distribution
beta_est( data, unknown = c("shape1", "shape2", "both"), shape1 = NULL, shape2 = NULL, plot = TRUE, curvecol = "red", ... )beta_est( data, unknown = c("shape1", "shape2", "both"), shape1 = NULL, shape2 = NULL, plot = TRUE, curvecol = "red", ... )
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
shape1, shape2
|
Non-negative parameters of the Beta distribution. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical beta distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is beta distribution
beta_est(rbeta(1000,shape1=2,shape2=1),unknown="shape2",shape1=2)#shape1 is known beta_est(rbeta(1000,shape1=2,shape2=1),unknown="shape1",shape2=1)#shape2 is known beta_est(rbeta(1000,shape1=2,shape2=1),unknown="both")#both will be estimatedbeta_est(rbeta(1000,shape1=2,shape2=1),unknown="shape2",shape1=2)#shape1 is known beta_est(rbeta(1000,shape1=2,shape2=1),unknown="shape1",shape2=1)#shape2 is known beta_est(rbeta(1000,shape1=2,shape2=1),unknown="both")#both will be estimated
function to get the method of moment estimate(s) of binomial distribution
binom_est( data, size.known = FALSE, size = NULL, plot = TRUE, curvecol = "red", ... )binom_est( data, size.known = FALSE, size = NULL, plot = TRUE, curvecol = "red", ... )
data |
A numeric vector. |
size.known |
logical indicating whether the size of the binomial distribution is known or not. |
size |
integer valued parameter of binomial distribution. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical binomial distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is binomial distribution
binom_est(rbinom(1000,size=5,prob=0.2),size.known=TRUE,size=5)#no of trials known binom_est(rbinom(1000,size=10,prob=0.6))binom_est(rbinom(1000,size=5,prob=0.2),size.known=TRUE,size=5)#no of trials known binom_est(rbinom(1000,size=10,prob=0.6))
function to get the method of moment estimate(s) of chi-square distribution
chisq_est(data, plot = TRUE, curvecol = "red", ...)chisq_est(data, plot = TRUE, curvecol = "red", ...)
data |
A numeric vector. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical chi square distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
the estimated degree of freedom by the method of moments of the data assuming the underlying distribution is chi square distribution
chisq_est(rchisq(1000,df=3))chisq_est(rchisq(1000,df=3))
function to get the method of moment estimate of exponential distribution
exp_est(data, plot = TRUE, curvecol = "red", ...)exp_est(data, plot = TRUE, curvecol = "red", ...)
data |
An object of numeric vector. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical exponential distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
the estimated positive rate parameter by the method of moments of the data assuming the underlying distribution is exponential distribution
exp_est(rexp(1000,rate=0.1))exp_est(rexp(1000,rate=0.1))
function to get the method of moment estimate(s) of gamma distribution
gamma_est( data, unknown = c("shape", "scale", "both"), shape = NULL, scale = NULL, plot = TRUE, curvecol = "red", ... )gamma_est( data, unknown = c("shape", "scale", "both"), shape = NULL, scale = NULL, plot = TRUE, curvecol = "red", ... )
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
shape, scale
|
positive shape and scale parameters of the gamma distribution. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical gamma distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is gamma distribution
gamma_est(rgamma(1000,shape=2,scale=1),unknown="scale",shape=2)#shape is known gamma_est(rgamma(1000,shape=2,scale=1),unknown="shape",scale=1)#scale is known gamma_est(rgamma(1000,shape=2,scale=1),unknown="both")#both will be estimatedgamma_est(rgamma(1000,shape=2,scale=1),unknown="scale",shape=2)#shape is known gamma_est(rgamma(1000,shape=2,scale=1),unknown="shape",scale=1)#scale is known gamma_est(rgamma(1000,shape=2,scale=1),unknown="both")#both will be estimated
function to get the method of moment estimate(s) of negative binomial distribution
geom_est(data, plot = TRUE, curvecol = "red", ...)geom_est(data, plot = TRUE, curvecol = "red", ...)
data |
A numeric vector. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical negative binomial distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is geometric distribution
geom_est(rgeom(1000,prob=0.2))geom_est(rgeom(1000,prob=0.2))
function to get the method of moment estimate(s) of log-normal distribution
lnorm_est( data, unknown = c("meanlog", "sdlog", "both"), meanlog = NULL, sdlog = NULL, plot = TRUE, curvecol = "red", ... )lnorm_est( data, unknown = c("meanlog", "sdlog", "both"), meanlog = NULL, sdlog = NULL, plot = TRUE, curvecol = "red", ... )
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
meanlog, sdlog
|
mean and standard deviation of the distribution on the log scale. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical log normal distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is log normal distribution
lnorm_est(rlnorm(1000),unknown="meanlog",sdlog=1)#meanlog unknown, but sdlog known lnorm_est(rlnorm(1000),unknown="sdlog",meanlog=0)#sdlog unknown, but meanlog known lnorm_est(rlnorm(1000),unknown="both")#both will be estimatedlnorm_est(rlnorm(1000),unknown="meanlog",sdlog=1)#meanlog unknown, but sdlog known lnorm_est(rlnorm(1000),unknown="sdlog",meanlog=0)#sdlog unknown, but meanlog known lnorm_est(rlnorm(1000),unknown="both")#both will be estimated
function to get the method of moment estimate(s) of logarithmic distribution
logarithmic_est(data, plot = TRUE, curvecol = "red", ...)logarithmic_est(data, plot = TRUE, curvecol = "red", ...)
data |
A numeric vector. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical poisson distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is logarithmic distribution
require(actuar) logarithmic_est(rlogarithmic(1000,prob=0.6))require(actuar) logarithmic_est(rlogarithmic(1000,prob=0.6))
function to get the method of moment estimate(s) of negative binomial distribution
nbinom_est( data, size.known = FALSE, size = NULL, plot = TRUE, curvecol = "red", ... )nbinom_est( data, size.known = FALSE, size = NULL, plot = TRUE, curvecol = "red", ... )
data |
A numeric vector. |
size.known |
logical indicating whether the size of the binomial distribution is known or not. |
size |
integer valued parameter of binomial distribution. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical negative binomial distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is negative binomial distribution
nbinom_est(rnbinom(1000,size=5,prob=0.2),size.known=TRUE,size=5)#no of successes known nbinom_est(rnbinom(1000,size=10,prob=0.6))nbinom_est(rnbinom(1000,size=5,prob=0.2),size.known=TRUE,size=5)#no of successes known nbinom_est(rnbinom(1000,size=10,prob=0.6))
function to get the method of moment estimate(s) of normal distribution
norm_est( data, unknown = c("mean", "sd", "both"), mean = NULL, sd = NULL, plot = TRUE, curvecol = "red", ... )norm_est( data, unknown = c("mean", "sd", "both"), mean = NULL, sd = NULL, plot = TRUE, curvecol = "red", ... )
data |
A numeric vector. |
unknown |
A character string specifying which parameter is (are) unknown to the user. |
mean, sd
|
mean and standard deviation of the distribution of the normal distribution, sd must be strictly positive. |
plot |
logical which controls whether the histogram of the data along with the density curve of the theoretical normal distribution with the estimated parameters. |
curvecol |
color of the theoretical density curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is normal distribution
norm_est(rnorm(1000),unknown="mean",sd=1)#mean unknown, but sd known norm_est(rnorm(1000),unknown="sd",mean=0)#sd unknown, but mean known norm_est(rnorm(1000),unknown="both")#both will be estimatednorm_est(rnorm(1000),unknown="mean",sd=1)#mean unknown, but sd known norm_est(rnorm(1000),unknown="sd",mean=0)#sd unknown, but mean known norm_est(rnorm(1000),unknown="both")#both will be estimated
function to get the method of moment estimate(s) of poisson distribution
pois_est(data, plot = TRUE, curvecol = "red", ...)pois_est(data, plot = TRUE, curvecol = "red", ...)
data |
A numeric vector. |
plot |
logical which controls whether the barplot of the data along with the probability curve of the theoretical poisson distribution with the estimated parameters. |
curvecol |
color of the theoretical probability curve |
... |
additional plotting parameters |
the estimated parameters by the method of moments of the data assuming the underlying distribution is poisson distribution
pois_est(data=rpois(1000,lambda=2),plot=TRUE) pois_est(data=rpois(1000,lambda=0.2),plot=FALSE)#will not give the plotpois_est(data=rpois(1000,lambda=2),plot=TRUE) pois_est(data=rpois(1000,lambda=0.2),plot=FALSE)#will not give the plot
It can be used to check whether a data comes from null distribution or from the alternative distribution
sim_mp_test( data, null.dist = c("uniform", "normal", "lognormal", "gamma", "cauchy", "pareto", "weibull", "rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial", "geometric", "t", "f", "logarithmic"), null.par, alter.dist = c("uniform", "normal", "lognormal", "gamma", "cauchy", "pareto", "weibull", "rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial", "geometric", "t", "f", "logarithmic"), alter.par, test.level = 0.95, sim.size = 1, power = TRUE )sim_mp_test( data, null.dist = c("uniform", "normal", "lognormal", "gamma", "cauchy", "pareto", "weibull", "rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial", "geometric", "t", "f", "logarithmic"), null.par, alter.dist = c("uniform", "normal", "lognormal", "gamma", "cauchy", "pareto", "weibull", "rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial", "geometric", "t", "f", "logarithmic"), alter.par, test.level = 0.95, sim.size = 1, power = TRUE )
data |
A numeric vector |
null.dist |
The family of null distribution |
null.par |
The parameter values of the null distribution |
alter.dist |
The family of alternative distribution |
alter.par |
The parameter values of the alternative distribution |
test.level |
The level of significance of the test |
sim.size |
simulation size, increasing it will gives more accuracy. |
power |
A loogical vector, whether power of the test will be calculated. |
This function mainly test whether data comes from the null distribution or alternative distribution. It uses the theory of the Most Powerful (MP) test. It basically uses simulation to get the p value and make the decision. Increasing sim.size give more accuracy as well as test can be failed if you increase it heavily.
A list of class "momtest" will be returned having the following components:
The Method's Name
The first 6 elements of input data
The family of null distribution
The parameter values of the null distribution
The family of alternative distribution
The parameter values of the alternative distribution
The sample size
The level of the significance of the test
The Test Result, wheter the null hypotheis is rejected or not
Power of the Test
sim_mp_test(rnorm(100),null.dist="normal",null.par=c(0,1),alter.dist="cauchy",alter.par=c(0,1)) sim_mp_test(rnorm(100),null.dist="nor",null.par=c(2,1),alter.dist="nor",alter.par=c(0,1))sim_mp_test(rnorm(100),null.dist="normal",null.par=c(0,1),alter.dist="cauchy",alter.par=c(0,1)) sim_mp_test(rnorm(100),null.dist="nor",null.par=c(2,1),alter.dist="nor",alter.par=c(0,1))
A function that returns a sampling interval for a statistic formed from random sample of certain probability distributions. The function generates the confidence interval using Monte Carlo simulations. The results might be unreliable if the resulting statistic has fat tailed distribution.
sim_sam_int( dist = c("normal", "lognormal", "gamma", "chisquare", "cauchy", "pareto", "weibull", "rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial", "geometric", "t", "f", "uniform"), pop.par, FUN, side = c("lower", "upper", "both"), conf.coeff = 0.95, range = 1, n = 100, sim.size = 1000 )sim_sam_int( dist = c("normal", "lognormal", "gamma", "chisquare", "cauchy", "pareto", "weibull", "rayleigh", "laplace", "beta", "binomial", "poisson", "negativebinomial", "geometric", "t", "f", "uniform"), pop.par, FUN, side = c("lower", "upper", "both"), conf.coeff = 0.95, range = 1, n = 100, sim.size = 1000 )
dist |
The parent population distribution |
pop.par |
The value of the population parameters |
FUN |
The statistic as a function of random data |
side |
The type of the confidence interval (both sided, only lower bound or only upper bound) |
conf.coeff |
The confidence coefficient of the sampling interval |
range |
It controls the length of the interval in which the boundary points are searched for. One may increase the range in case the distribution of statistic is suspected to be fat tailed. |
n |
sample size |
sim.size |
simulation size, increasing it will gives more accuracy. |
The function asks the user to specify a distribution from which random sample is drawn and to specify a function of the random variables for which an approximate sampling Interval is to be provided. The function then uses Monte Carlo simulation technique to provide an approximate sampling interval of the statistic. This function might be useful when the sampling distribution for a particular statistic is unknown, but that statistic might be useful in drawing meaningful inference. Although this function is inferior to other sophisticated techniques to deal with this problem, it might come handy for a beginner.
A list of class "momint" will be returned having the following components:
The Method's Name
The family of population distribution
The parameter values of the population distribution
The function of which the interval will be provided
The sample size
The confidence coefficient of the sampling interval
The estimated sampling interval
sim_sam_int(dist="normal",pop.par=c(0,1),FUN=mean,side="both") sim_sam_int(dist="binomial",pop.par=c(5,0.5),FUN=sum,side="lower")sim_sam_int(dist="normal",pop.par=c(0,1),FUN=mean,side="both") sim_sam_int(dist="binomial",pop.par=c(5,0.5),FUN=sum,side="lower")