You are on page 1of 3

kodingan

ujison<-function(k,shape,rate,alpha=0.05)
{
samplesize<-c(150,200,250,500,750)
nsample<-length(samplesize)
temjhit<-temjmod<-rep(0,nsample)

for(j in 1:nsample) {

pvthit<-pvtmod<-tmod<-thit<-rep(0,k)

for(i in 1:k) {
data<-rgamma(samplesize[j],shape=shape, rate=rate)
n<-length(data)
xbar<-mean(data)
s2<-var(data)
Ex<-shape/rate
varx<-shape/(rate^2)
mu0<-Ex-2*sqrt(varx/samplesize[j])
mu3<-n*sum((data-xbar)^3)/((n-1)*(n-2))
thit[i]<-(xbar-mu0)/(sqrt(s2/n))
tmod[i]<-(((xbar-mu0)+(mu3/6*s2*n))+((mu3*(xbar-mu0)^2)/(3*s2^2))
)/sqrt(s2/n)
pvthit[i]<- 1-pt(thit[i],n-1)
pvtmod[i]<- 1-pt(tmod[i],n-1)
}

a<-ifelse(pvthit<alpha,1,0)
temjhit[j]<-(sum(a)/k)
b<-ifelse(pvtmod<alpha,1,0)
temjmod[j]<-(sum(b)/k)
}

list(temjhit=temjhit, temjmod=temjmod)

ujison(k=1000,shape=7,rate=1)

OUTPUT
$temjhit
[1] 0.659 0.621 0.660 0.618 0.657

$temjmod
[1] 0.999 1.000 1.000 1.000 1.000
tidak simetrik

You might also like