Professional Documents
Culture Documents
************************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))
************************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 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)
************************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