Anda di halaman 1dari 3

inimiiiiiii!!!!!!!!!!!!!!!!!!!!!!

************************Olah Data************************
> xi<-
c(0.1,0.2,1,1,1,1,1,2,3,6,7,11,12,18,18,18,18,18,21,32,36,40,45,46,47,50,55,60,63,6
3,67,67,67,67,72,75,79,82,82,83,84,84,84,85,85,85,85,85,86,86)
> #Distribusi EMWE
> p1=49.05
> p2=3.148
> p3=0.145
> p4=7.181/100000
> pdf_EMWE=p4*p2*p3*((xi/p1)^(p2-1))*(exp(((xi/p1)^(p2))+(p4*p1*(1-
(exp((xi/p1)^(p2)))))))*((1-(exp((p4*p1*(1-(exp((xi/p1)^(p2))))))))^(p3-1))
> hazard_EMWE=(p4*p2*p3*((xi/p1)^(p2-1))*(exp(((xi/p1)^(p2))+(p4*p1*(1-
(exp((xi/p1)^(p2)))))))*((1-(exp((p4*p1*(1-(exp((xi/p1)^(p2))))))))^(p3-1)))/(1-
(((1-(exp((p4*p1*(1-(exp((xi/p1)^(p2))))))))^(p3))))
> kum_EMWE=((1-(exp((p4*p1*(1-(exp((xi/p1)^(p2))))))))^(p3))

> #Distribusi MWE


> a1=110.0909
> a2=0.8408
> a3=0.0141
> pdf_MWE=a3*a2*((xi/a1)^(a2-1))*(exp(((xi/a1)^(a2))+(a3*a1*(1-
(exp((xi/a1)^(a2)))))))
> hazard_MWE=a3*a2*((xi/a1)^(a2-1))*(exp(((xi/a1)^(a2))))
>
> #Distribusi Weibull 2 Parameter oleh Chen
> b2=0.4
> b3=0.01
> pdf_Chen=b3*b2*((xi)^(b2-1))*(exp(((xi)^(b2))+(b3*(1-(exp((xi)^(b2)))))))
> hazard_Chen=b3*b2*((xi)^(b2-1))*(exp(((xi)^(b2))))

> #Distribusi Weibull 2 Parameter


> c1=50.604
> c2=0.62777
> pdf_Weibull=(c2/c1)*((xi/c1)^(c2-1))*(exp(-(xi/c1)^(c2)))
> hazard_Weibull=(c2/c1)*((xi/c1)^(c2-1))

************************Membuat Plot************************
> #Plot Fungsi hazard
> plot(xi,hazard_EMWE,type="l" ,main="Plot Fungsi Hazard",xlab="x",ylab="Fungsi
Hazard",col = "black",lty=1,lwd=3,ylim=c(0,0.07))
> lines(xi,hazard_MWE,col="black", lty = 2, lwd = 3)
> lines(xi,hazard_Chen,col="black", lty = 3, lwd = 3)
> lines(xi,hazard_Weibull,col="black", lty = 4, lwd = 3)
> legend(8,0.07,c("Distribusi EMWE","Distribusi MWE","Distribusi Chen","Distribusi
Weibull"), lty=c(1,2,3,4),lwd=c(3,3,3,3),col=c("black","black","black","black"))

> plot(xi,hazard_EMWE,type="l" ,main="Plot Fungsi Hazard",xlab="x",ylab="Fungsi


Hazard",col = "black",lty=1,lwd=3,ylim=c(0,0.07))
> lines(xi,hazard_MWE,col="black", lty = 2, lwd = 3)
> lines(xi,hazard_Chen,col="black", lty = 3, lwd = 3)
> legend(8,0.063,c("Distribusi EMWE","Distribusi MWE","Distribusi Chen"),
lty=c(1,2,3),lwd=c(3,3,3),col=c("black","black","black"))
> #Plot PDF
> plot(xi,pdf_EMWE,type="l" ,main="Plot Fungsi Kepadatan
Peluang",xlab="x",ylab="Fungsi Kepadatan Peluang",col =
"black",lty=1,lwd=3,ylim=c(0,0.03))
> lines(xi,pdf_MWE,col="black", lty = 2, lwd = 3)
> lines(xi,pdf_Chen,col="black", lty = 3, lwd = 3)
> lines(xi,pdf_Weibull,col="black", lty = 4, lwd = 3)
> legend(40,0.03,c("Distribusi EMWE","Distribusi MWE","Distribusi Chen","Distribusi
Weibull"), lty=c(1,2,3,4),lwd=c(3,3,3,3),col=c("black","black","black","black"))

************************Untuk uji kolmogorov************************


>
data=c(0.1,0.2,0.2,1,1,2,2,3,3,6,6,7,7,11,11,12,12,18,18,21,21,32,32,36,36,40,40,45
,45,46,46,47,47,50,50,55,55,60,60,63,63,67,67,72,72,75,75,79,79,82,82,83,83,84,84,8
5,85,86,86)
>
F_n=c(0.02,0.02,0.14,0.14,0.16,0.16,0.18,0.18,0.2,0.2,0.22,0.22,0.24,0.24,0.26,0.26
,0.36,0.36,0.38,0.38,0.4,0.4,0.42,0.42,0.44,0.44,0.46,0.46,0.48,0.48,0.5,0.5,0.52,0
.52,0.54,0.54,0.56,0.56,0.6,0.6,0.68,0.68,0.7,0.7,0.72,0.72,0.74,0.74,0.78,0.78,0.8
,0.8,0.86,0.86,0.96,0.96,1,1,1)
>
F_x=c(0.02606877,0.02606877,0.03577079,0.03577079,0.07457281,0.07457281,0.10232691,
0.10232691,0.12313227,0.12313227,0.16897303,0.16897303,0.18130184,0.18130184,0.2229
5558,0.22295558,0.23203678,0.23203678,0.27983595,0.27983595,0.30081856,0.30081856,0
.36980574,0.36980574,0.39371729,0.39371729,0.41790057,0.41790057,0.44936777,0.44936
777,0.45592076,0.45592076,0.46258425,0.46258425,0.48335040,0.48335040,0.52129955,0.
52129955,0.56501648,0.56501648,0.59492851,0.59492851,0.64026214,0.64026214,0.707673
05,0.70767305,0.75471357,0.75471357,0.82497759,0.82497759,0.88120313,0.88120313,0.8
9980884,0.89980884,0.91789802,0.91789802,0.93510270,0.93510270,0.95099343)

plot kolmogorov-smirnov
> plot(data,F_n,type="l" ,main="Plot Uji Kolmogorov-
Smirnov",xlab="x",ylab="F(x)",col = "blue",lty=1,lwd=3)
> lines(data,F_x,col="red", lty = 1, lwd = 3)
> legend(0,1,c("Empirical Distribution Function","Cumulative Distribution
Function"), lty=c(1,1),lwd=c(3,3),col=c("blue","red"))

data=c(115,181,255,418,441,461,516,739,743,789,807,865,924,983,1024,1062,1063,1165,
1191,1222,1222,1251,1277,1290,1357,1369,1408,1455,1478,1549,1578,1578,1599,1603,160
5,1696,1735,1799,1815,1852,1899,1925,1965)

************************Membuat Plot Cdf************************


untuk membuat plot ecdf bisa juga dengan:
plot(ecdf(data))

************************Membangkitkan data************************
> uni=runif(50, min=0, max=1)
Warning messages:
1: package �maxLik� was built under R version 3.2.3
2: package �miscTools� was built under R version 3.2.3
> n1=log(1-(uni^(1/0.145)))
> n2=n1/(49.05*0.00007181)
> n3=1-n2
> n4=log(n3)
> n5=n4^(1/3.148)
> n6=49.05*n5
> n6
[1] 84.256846012 73.093267218 65.633346669 69.622137180 5.356737902 52.692587365
[7] 60.194361852 45.908405606 77.468038812 39.437032327 63.035102778 64.446094963
[13] 23.807028406 77.457540746 0.006531866 71.108523839 0.008075492 75.852217071
[19] 28.966499585 85.089810033 65.434167273 43.443473584 7.275776562 84.756137354
[25] 84.547253263 67.294505200 38.378508263 74.666425217 0.000000000 51.496054143
[31] 35.027337126 13.962970193 77.861721945 2.889295592 1.196145403 80.811883349
[37] 75.299039270 87.987950133 44.036696995 90.747959657 42.939667980 37.814479970
[43] 80.053250194 64.497037039 67.892392718 84.699749369 55.828977793 0.588117657
[49] 81.499351315 8.067090109
> sort(n6)
[1] 0.000000000 0.006531866 0.008075492 0.588117657 1.196145403 2.889295592
[7] 5.356737902 7.275776562 8.067090109 13.962970193 23.807028406 28.966499585
[13] 35.027337126 37.814479970 38.378508263 39.437032327 42.939667980 43.443473584
[19] 44.036696995 45.908405606 51.496054143 52.692587365 55.828977793 60.194361852
[25] 63.035102778 64.446094963 64.497037039 65.434167273 65.633346669 67.294505200
[31] 67.892392718 69.622137180 71.108523839 73.093267218 74.666425217 75.299039270
[37] 75.852217071 77.457540746 77.468038812 77.861721945 80.053250194 80.811883349
[43] 81.499351315 84.256846012 84.547253263 84.699749369 84.756137354 85.089810033
[49] 87.987950133 90.747959657
>

************************Estimasi Parameter************************
> log_likelihood<-function(theta){n*(log(theta[1])+log(theta[2])+log(theta[3])+(1-
theta[2])*log(theta[4])+theta[1]*theta[4])+(theta[2]-1)*sum(log(n6))+(1/
(theta[4]^theta[2]))*sum(n6^theta[2])-
(theta[1]*theta[4])*sum(exp((n6/theta[4])^theta[2]))+(theta[3]-1)*sum(1-
(exp((theta[1]*theta[4])*(1-(exp((n6/theta[4])^theta[2]))))))}
> par<-nlm(log_likelihood,theta<-c(0.00007181,3.148,0.145,49.05),hessian=TRUE)
There were 19 warnings (use warnings() to see them)
> par
$minimum
[1] 1.797693e+308

$estimate
[1] 7.181e-05 3.148e+00 1.450e-01 4.905e+01

$gradient
[1] 0 0 0 0

$hessian
[,1] [,2] [,3] [,4]
[1,] 0 0 0 0
[2,] 0 0 0 0
[3,] 0 0 0 0
[4,] 0 0 0 0

$code
[1] 1

$iterations
[1] 0