The asymptotic variance of trimmed mean of a normal(0,1) distribution:
pi=22/7
f1=function(y){(1/sqrt(2*pi))*exp((-y^2)/2)}
We will calculate trimmed mean for different values of \(\alpha\) and check how the asymptotic variance is changing wrt \(\alpha\).
alpha=seq(0.01,0.5,0.001)
Now we will calculate \[F^{-1}(1-\alpha)\]
uplim1=array(dim=1)
for(i in 1:length(alpha)) {
uplim1[i]=qnorm(1-alpha[i])
}
we have to calculate G(\(\alpha\))=\[\int_{0}^{F^{-1}(1-\alpha)} t^2f(t)\,dt\]
h1=function(y){y^2*exp((-y^2)/2)*(1/sqrt(2*pi))}
G1=array(dim=1)
for(i in 1:length(alpha)) {
G1[i]=integrate(h1,lower=0,upper=uplim1[i])
}
Now we have to calculate the Asymptotic variance of trimmed mean \(\sigma^{2}(\alpha)\) =\[2[G(\alpha)+\alpha{(F^{-1}(1-\alpha)})^{2}]/(1-2\alpha)^{2}\]
Sigma1=array(dim=1)
for(i in 1:length(alpha)) {
Sigma1[i]=2*as.numeric(G1[i])+as.numeric(alpha[i])*as.numeric((uplim1[i]*uplim1[i]))/(1-2*as.numeric(alpha[i])^2)
}
now we will plot the \(\sigma^{2}(\alpha)\) vs \(\alpha\)
plot(alpha,Sigma1,main=" Av of Normal Trimmed mean vs alpha plot", col='blue',xlab="Alpha",ylab="A.V")
Comment: The normal TM Asymptotic variance decreases as \(\alpha\) increases from 0 to 1.
Double exponential distribution The pdf of double exponential distribution is
\(f_1(y)\) = \[\frac{1} 2e^{-|y|}\] we find the asymptotic variance of double exponential distribution. The procedure will be same as before.
f2=function(y){
z=exp(-abs(y))/2
return(z)
}
the quantile function of double exponential will be found in nimble package
uplim2=array(dim=1)
library(nimble)
for(i in 1:length(alpha)) {
uplim2[i]=qdexp(1-alpha[i])
}
h2=function(y){y^2*(exp(-abs(y))/2)}
G2=array(dim=1)
for(i in 1:length(alpha)) {
G2[i]=integrate(h2,lower=0,upper=uplim2[i])
}
Asymptotic variance of Double exponential distribution
Sigma2=array(dim=1)
for(i in 1:length(alpha)) {
Sigma2[i]=2*as.numeric(G2[i])+as.numeric(alpha[i])*as.numeric((uplim2[i]*uplim2[i]))/(1-2*as.numeric(alpha[i])^2)
}
Plotting of asymptotic variance
plot(alpha,Sigma2,main=" AV of Double Exponential trimmed mean vs alpha plot",col='blue',xlab="Alpha",ylab="A.V")
Comment: The asymptotic variance decreases when \(\alpha\) increases.For double exponential(0,1) distribution AV decreases faster than N(0,1) Distribution.
Cauchy distribution:
The pdf of cauchy distribution is \(f_3(y)\)=\[\frac{1}{\pi(1+y^{2})}\]
f3=function(y){
z=1/(pi*(1+y^2))
return(z)
}
uplim3=array(dim=1)
for(i in 1:length(alpha)) {
uplim3[i]=qcauchy(1-alpha[i])
}
h3=function(y){y^2*(1/(pi*(1+y^2)))}
G3=array(dim=1)
for(i in 1:length(alpha)) {
G3[i]=integrate(h3,lower=0,upper=uplim3[i])
}
Sigma3=array(dim=1)
for(i in 1:length(alpha)) {
Sigma3[i]=2*as.numeric(G3[i])+as.numeric(alpha[i])*as.numeric((uplim3[i]*uplim3[i]))/(1-2*as.numeric(alpha[i])^2)
}
Plotting
plot(alpha,Sigma3,main=" AV of Cauchy Trimmed mean vs alpha plot",col='blue',xlab="Alpha",ylab="A.V")
Comment: when \(\alpha\) increases The asymptotic variance decreases faster than Normal or Double exponential distribution
The Exponential distribution the pdf of exp(1) distribution is,
\(f_4(y)\)=\[e^{-x}\]
f4=function(y){exp(-y)}
uplim4=array(dim=1)
for(i in 1:length(alpha)) {
uplim4[i]=qexp(1-alpha[i])
}
h4=function(y){y^2*exp(-y)}
G4=array(dim=1)
for(i in 1:length(alpha)) {
G4[i]=integrate(h4,lower=0,upper=uplim4[i])
}
Sigma4=array(dim=1)
for(i in 1:length(alpha)) {
Sigma4[i]=2*as.numeric(G4[i])+as.numeric(alpha[i])*as.numeric((uplim4[i]*uplim4[i]))/(1-2*as.numeric(alpha[i])^2)
}
plot(alpha,Sigma4,main=" Av of exponential Trimmed mean vs alpha plot", col='blue',xlab="Alpha",ylab="A.V")
Uniform Distribution: The pdf of uniform distribution is, \(f_5(y)\)=1 when 0 <=x<=1
uplim5=array(dim=1)
for(i in 1:length(alpha)) {
uplim5[i]=qunif(1-alpha[i],0,1)
}
h5=function(y){y^2}
G5=array(dim=1)
for(i in 1:length(alpha)) {
G5[i]=integrate(h5,lower=0,upper=uplim5[i])
}
Sigma5=array(dim=1)
for(i in 1:length(alpha)) {
Sigma5[i]=2*as.numeric(G5[i])+as.numeric(alpha[i])*as.numeric((uplim5[i]*uplim5[i]))/(1-2*as.numeric(alpha[i])^2)
}
plot(alpha,Sigma5,main=" Av of uniform Trimmed mean vs alpha plot", col='blue',xlab="Alpha",ylab="A.V")
Gamma(2,1) distribution
The Gamma(2,1) distribution is denoted as, \(f_6(y)\)=\[xe^{-x}\]
uplim6=array(dim=1)
for(i in 1:length(alpha)) {
uplim6[i]=qgamma(1-alpha[i],shape=2,rate=1)
}
h6=function(y){y^3*exp(-y)}
G6=array(dim=1)
for(i in 1:length(alpha)) {
G6[i]=integrate(h6,lower=0,upper=uplim6[i])
}
Sigma6=array(dim=1)
for(i in 1:length(alpha)) {
Sigma6[i]=2*as.numeric(G6[i])+as.numeric(alpha[i])*as.numeric((uplim6[i]*uplim6[i]))/(1-2*as.numeric(alpha[i])^2)
}
plot(alpha,Sigma6,main=" Av of gamma Trimmed mean vs alpha plot", col='blue',xlab="Alpha",ylab="A.V")
Beta(2,2) distribution
uplim8=array(dim=1)
for(i in 1:length(alpha)) {
uplim8[i]=qbeta(1-alpha[i],shape1=2,shape2=2)
}
h8=function(y){y^3*(1-y)}
G8=array(dim=1)
for(i in 1:length(alpha)) {
G8[i]=integrate(h8,lower=0,upper=uplim8[i])
}
Sigma8=array(dim=1)
for(i in 1:length(alpha)) {
Sigma8[i]=2*as.numeric(G8[i])+as.numeric(alpha[i])*as.numeric((uplim8[i]*uplim8[i]))/(1-2*as.numeric(alpha[i])^2)
}
plot(alpha,Sigma8,main=" Av of beta Trimmed mean vs alpha plot", col='blue',xlab="Alpha",ylab="A.V")
Comment: In case of Beta distribution,The Asymptotic variance is increasing while alpha is increasing.
Log_Normal Distribution
uplim9=array(dim=1)
for(i in 1:length(alpha)) {
uplim9[i]=qlnorm(1-alpha[i])
}
h9=function(y){y^2*(exp(-log(y)^2)/(2*y))/sqrt(2*pi)}
G9=array(dim=1)
for(i in 1:length(alpha)) {
G9[i]=integrate(h9,lower=0,upper=uplim9[i])
}
Sigma9=array(dim=1)
for(i in 1:length(alpha)) {
Sigma9[i]=2*as.numeric(G9[i])+as.numeric(alpha[i])*as.numeric((uplim9[i]*uplim9[i]))/(1-2*as.numeric(alpha[i])^2)
}
plot(alpha,Sigma9,main=" Av of logN Trimmed mean vs alpha plot", col='blue',xlab="Alpha",ylab="A.V")
Comment: The asymptotic Variance of log-Normal Trimmed mean decreases when alpha increases.