Você está na página 1de 8

R version 3.2.

2 (2015-08-14) -- "Fire Safety"


Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
[Previously saved workspace restored]
> 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,5
5,60,63,63,67,67,67,67,72,75,79,82,82,83,84,84,84,85,85,85,85,85,86,86)
> n<-length(xi)
> logLikFun<-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(xi))+(1/(theta[4]^theta[2]))*sum(xi^theta[2])(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2]))+(theta[3]-1)*sum(1-(exp((th
eta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2]))))))
+ }
> mle<-maxLik(logLik=logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,
theta[4]theta[4]=49.05))
> mle<-maxLik(logLik=logLikFun,start=c(theta[1]=0.00007181,theta[2]=3.148,theta[
3]=0.145,theta[4]=49.05))
Error: unexpected '=' in "mle<-maxLik(logLik=logLikFun,start=c(theta[1]="
> mle<-maxLik(logLik=logLikFun,start=c(0.00007181,3.148,0.145,49.05))
Error: could not find function "maxLik"
> library(maxLik)
Loading required package: miscTools
Please cite the 'maxLik' package as:
Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihoo
d estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-0
10-0217-1.
If you have questions, suggestions, or comments regarding the 'maxLik' package,
please use a forum or 'tracker' at maxLik's R-Forge site:
https://r-forge.r-project.org/projects/maxlik/
Warning messages:
1: package maxLik was built under R version 3.2.3
2: package miscTools was built under R version 3.2.3
> mle<-maxLik(logLik=logLikFun,start=c(0.00007181,3.148,0.145,49.05))
There were 50 or more warnings (use warnings() to see the first 50)
> mle
Maximum Likelihood estimation
Newton-Raphson maximisation, 43 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.

Log-Likelihood: 2499507215 (4 free parameter(s))


Estimate(s): 0.605566 0.003926177 49990152 16.57889
> summary(mle)
-------------------------------------------Maximum Likelihood estimation
Newton-Raphson maximisation, 43 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 2499507215
4 free parameters
Estimates:
Estimate Std. error t value Pr(> t)
[1,] 6.056e-01
NA
NA
NA
[2,] 3.926e-03 2.195e-12 1.789e+09 <2e-16 ***
[3,] 4.999e+07 1.448e-03 3.452e+10 <2e-16 ***
[4,] 1.658e+01
NA
NA
NA
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
1
-------------------------------------------Warning messages:
1: In sqrt(diag(vc)) : NaNs produced
2: In sqrt(diag(vc)) : NaNs produced
>
> library(bbmle)
Loading required package: stats4
Attaching package: bbmle
The following object is masked from

package:miscTools :

stdEr
Warning message:
package bbmle was built under R version 3.2.3
> logLikFun<-function(theta){-(n*(log(theta[1])+log(theta[2])+log(theta[3])+(1-t
heta[2])*log(theta[4])+theta[1]*theta[4])+(theta[2]-1)*sum(log(xi))+(1/(theta[4]
^theta[2]))*sum(xi^theta[2])-(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2])
)+(theta[3]-1)*sum(1-(exp((theta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2]))))
)))}
> mle<-maxLik(logLik=logLikFun,start=c(0.00007181,3.148,0.145,49.05))
There were 50 or more warnings (use warnings() to see the first 50)
> summary(mle)
-------------------------------------------Maximum Likelihood estimation
Newton-Raphson maximisation, 1 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 516.6791
4 free parameters
Estimates:
Estimate Std. error t value Pr(> t)
[1,] 7.181e-05
NA
NA
NA
[2,] 3.148e+00
NA
NA
NA
[3,] 1.450e-01
NA
NA
NA
[4,] 4.905e+01
NA
NA
NA
-------------------------------------------Warning messages:
1: In sqrt(diag(vc)) : NaNs produced

2: In sqrt(diag(vc)) : NaNs produced


> mle<-maxLik(logLik=logLikFun,start=c(0.00007181,3.148,0.145,49.05),method="NR"
)
There were 50 or more warnings (use warnings() to see the first 50)
> mle
Maximum Likelihood estimation
Newton-Raphson maximisation, 1 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 516.6791 (4 free parameter(s))
Estimate(s): 7.181e-05 3.148 0.145 49.05
> summary(mle)
-------------------------------------------Maximum Likelihood estimation
Newton-Raphson maximisation, 1 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 516.6791
4 free parameters
Estimates:
Estimate Std. error t value Pr(> t)
[1,] 7.181e-05
NA
NA
NA
[2,] 3.148e+00
NA
NA
NA
[3,] 1.450e-01
NA
NA
NA
[4,] 4.905e+01
NA
NA
NA
-------------------------------------------Warning messages:
1: In sqrt(diag(vc)) : NaNs produced
2: In sqrt(diag(vc)) : NaNs produced
> m0<-mle2(logLikFun,start=c(0.00007181,3.148,0.145,49.05),data=xi)
Error in mle2(logLikFun, start = c(7.181e-05, 3.148, 0.145, 49.05), data = xi) :
'start' must be a named vector or named list
> m0<-mle2(logLikFun,start=c(theta[1]=0.00007181,theta[2]=3.148,theta[3]=0.145,t
heta[4]=49.05),data=xi)
Error: unexpected '=' in "m0<-mle2(logLikFun,start=c(theta[1]="
> logLikFun<-function(theta){lambda=theta[1],beta=theta[2],gamma=theta[3],alpha=
theta[4],-(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(xi))+(1/(theta[4]^theta[2]))*sum(xi^t
heta[2])-(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2]))+(theta[3]-1)*sum(1
-(exp((theta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2])))))))}
Error: unexpected ',' in "logLikFun<-function(theta){lambda=theta[1],"
> logLikFun<-function(theta){
+ lambda=theta[1]
+ beta=theta[2]
+ gamma=theta[3]
+ alpha=theta[4]
+ -(n*(log(theta[1])+log(theta[2])+log(theta[3])+(1-theta[2])*log(theta[4])+thet
a[1]*theta[4])+(theta[2]-1)*sum(log(xi))+(1/(theta[4]^theta[2]))*sum(xi^theta[2]
)-(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2]))+(theta[3]-1)*sum(1-(exp((
theta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2])))))))
+ }
> m0<-mle2(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.0
5),data=xi)
Error in mle2(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.1
45, :
'data' must be a list
> m0<-mle2(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.0

5),xi)
Error in mle2(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.1
45, :
some named arguments in 'start' are not arguments to the specified log-likelih
ood function
> m0<-mle2(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.0
5),data=xi)
Error in mle2(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.1
45, :
'data' must be a list
> m0<-mle2(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.0
5),xi=xi)
Error in mle2(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.1
45, :
some named arguments in 'start' are not arguments to the specified log-likelih
ood function
> m0<-maxLik(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49
.05))
There were 50 or more warnings (use warnings() to see the first 50)
> summary(m0)
-------------------------------------------Maximum Likelihood estimation
Newton-Raphson maximisation, 1 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 516.6791
4 free parameters
Estimates:
Estimate Std. error t value Pr(> t)
lambda 7.181e-05
NA
NA
NA
beta 3.148e+00
NA
NA
NA
gamma 1.450e-01
NA
NA
NA
aplha 4.905e+01
NA
NA
NA
-------------------------------------------Warning messages:
1: In sqrt(diag(vc)) : NaNs produced
2: In sqrt(diag(vc)) : NaNs produced
> logLikFun<-function(theta){
+ lambda=theta[1]
+ beta=theta[2]
+ gamma=theta[3]
+ alpha=theta[4]
+ (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(xi))+(1/(theta[4]^theta[2]))*sum(xi^theta[2])
-(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2]))+(theta[3]-1)*sum(1-(exp((t
heta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2])))))))
+ }
> m0<-maxLik(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49
.05))
There were 50 or more warnings (use warnings() to see the first 50)
> summary(m0)
-------------------------------------------Maximum Likelihood estimation
Newton-Raphson maximisation, 43 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 2499507215
4 free parameters

Estimates:
Estimate Std. error t value Pr(> t)
lambda 6.056e-01
NA
NA
NA
beta 3.926e-03 2.195e-12 1.789e+09 <2e-16 ***
gamma 4.999e+07 1.448e-03 3.452e+10 <2e-16 ***
aplha 1.658e+01
NA
NA
NA
--Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1
1
-------------------------------------------Warning messages:
1: In sqrt(diag(vc)) : NaNs produced
2: In sqrt(diag(vc)) : NaNs produced
>
>
> library(stats4)
> LL<-function(theta){
+ lambda=theta[1]
+ beta=theta[2]
+ gamma=theta[3]
+ alpha=theta[4]
+ -(n*(log(theta[1])+log(theta[2])+log(theta[3])+(1-theta[2])*log(theta[4])+thet
a[1]*theta[4])+(theta[2]-1)*sum(log(xi))+(1/(theta[4]^theta[2]))*sum(xi^theta[2]
)-(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2]))+(theta[3]-1)*sum(1-(exp((
theta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2])))))))
+ }
> mle(LL,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.05))
Error in mle(LL, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.145, :
'start' must be a named list
> mle(LL,start=list(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.05))
Error in mle(LL, start = list(lambda = 7.181e-05, beta = 3.148, gamma = 0.145,
:
some named arguments in 'start' are not arguments to the supplied log-likeliho
od
> mle(LL,start=list(lambda=0.00007181,beta=3.148,gamma=0.145,alpha=49.05))
Error in mle(LL, start = list(lambda = 7.181e-05, beta = 3.148, gamma = 0.145,
:
some named arguments in 'start' are not arguments to the supplied log-likeliho
od
> mle(LL,start=list(0.00007181,3.148,0.145,49.05))
Error in mle(LL, start = list(7.181e-05, 3.148, 0.145, 49.05)) :
'start' must be a named list
> mle(LL,start=c(0.00007181,3.148,0.145,49.05))
Error in mle(LL, start = c(7.181e-05, 3.148, 0.145, 49.05)) :
'start' must be a named list
> m0<-mle2(LL,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,alpha=49.05),data
=xi)
Error in mle2(LL, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.145, :
'data' must be a list
> m0<-mle2(LL,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,alpha=49.05))
Error in mle2(LL, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.145, :
some named arguments in 'start' are not arguments to the specified log-likelih
ood function
> m0<-mle2(LL,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,alpha=49.05),data
=list(xi))
Error in mle2(LL, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.145, :
some named arguments in 'start' are not arguments to the specified log-likelih
ood function
> xi<-data.frame(x=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,63,67,67,67,67,72,75,79,82,82,83,84,84,84,85,85,85,85,85,86
,86)

+ )
> xi
x
1 0.1
2 0.2
3 1.0
4 1.0
5 1.0
6 1.0
7 1.0
8 2.0
9 3.0
10 6.0
11 7.0
12 11.0
13 12.0
14 18.0
15 18.0
16 18.0
17 18.0
18 18.0
19 21.0
20 32.0
21 36.0
22 40.0
23 45.0
24 46.0
25 47.0
26 50.0
27 55.0
28 60.0
29 63.0
30 63.0
31 67.0
32 67.0
33 67.0
34 67.0
35 72.0
36 75.0
37 79.0
38 82.0
39 82.0
40 83.0
41 84.0
42 84.0
43 84.0
44 85.0
45 85.0
46 85.0
47 85.0
48 85.0
49 86.0
50 86.0
> logLikFun<-function(theta){
+ lambda=theta[1]
+ beta=theta[2]
+ gamma=theta[3]
+ alpha=theta[4]
+ -(n*(log(theta[1])+log(theta[2])+log(theta[3])+(1-theta[2])*log(theta[4])+thet
a[1]*theta[4])+(theta[2]-1)*sum(log(xi))+(1/(theta[4]^theta[2]))*sum(xi^theta[2]

)-(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2]))+(theta[3]-1)*sum(1-(exp((
theta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2])))))))
+ }
> fit<-mle2(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.
05),data=xi)
Error in mle2(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.1
45, :
some named arguments in 'start' are not arguments to the specified log-likelih
ood function
> fit<-mle2(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.
05))
Error in mle2(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.1
45, :
some named arguments in 'start' are not arguments to the specified log-likelih
ood function
> fit<-mle2(logLikFun,start=list(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=
49.05),data=xi)
Error in mle2(logLikFun, start = list(lambda = 7.181e-05, beta = 3.148, :
some named arguments in 'start' are not arguments to the specified log-likelih
ood function
> fit<-mle2(logLikFun,start=c(0.00007181,3.148,0.145,49.05))
Error in mle2(logLikFun, start = c(7.181e-05, 3.148, 0.145, 49.05)) :
'start' must be a named vector or named list
> 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,5
5,60,63,63,67,67,67,67,72,75,79,82,82,83,84,84,84,85,85,85,85,85,86,86)
Error: unexpected ',' in "xi=c((0.1,"
> 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,63,67,67,67,67,72,75,79,82,82,83,84,84,84,85,85,85,85,85,86,86)
> n<-length(xi)
> logLikFun<-function(theta){
+ lambda=theta[1]
+ beta=theta[2]
+ gamma=theta[3]
+ alpha=theta[4]
+ -(n*(log(theta[1])+log(theta[2])+log(theta[3])+(1-theta[2])*log(theta[4])+thet
a[1]*theta[4])+(theta[2]-1)*sum(log(xi))+(1/(theta[4]^theta[2]))*sum(xi^theta[2]
)-(theta[1]*theta[4])*sum(exp((xi/theta[4])^theta[2]))+(theta[3]-1)*sum(1-(exp((
theta[1]*theta[4])*(1-(exp((xi/theta[4])^theta[2])))))))
+ }
> mle(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,aplha=49.05),me
thod="NR")
Error in mle(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.14
5, :
'start' must be a named list
> mle(logLikFun,start=c(lambda=0.00007181,beta=3.148,gamma=0.145,alpha=49.05),me
thod="NR")
Error in mle(logLikFun, start = c(lambda = 7.181e-05, beta = 3.148, gamma = 0.14
5, :
'start' must be a named list
> mle(logLikFun,start=list(lambda=0.00007181,beta=3.148,gamma=0.145,alpha=49.05)
,method="NR")
Error in mle(logLikFun, start = list(lambda = 7.181e-05, beta = 3.148, :
some named arguments in 'start' are not arguments to the supplied log-likeliho
od
> mle(logLikFun,start=c(0.00007181,3.148,0.145,49.05),method="NR")
Error in mle(logLikFun, start = c(7.181e-05, 3.148, 0.145, 49.05), method = "NR"
) :
'start' must be a named list
> mle(logLikFun,start=list(0.00007181,3.148,0.145,49.05),method="NR")
Error in mle(logLikFun, start = list(7.181e-05, 3.148, 0.145, 49.05), :

'start' must be a named list


> mle(logLikFun,start=list(theta[1]=0.00007181,theta[2]=3.148,theta[3]=0.145,the
ta[4]=49.05),method="NR")
Error: unexpected '=' in "mle(logLikFun,start=list(theta[1]="
> logLikFun<-function(theta[1],theta[2],theta[3],theta[4]){
Error: unexpected '[' in "logLikFun<-function(theta["
> logLikFun<-function(theta1,theta2,theta3,theta4){
+ -(n*(log(theta1)+log(theta2)+log(theta3)+(1-theta2)*log(theta4)+theta1*theta4)
+(theta2-1)*sum(log(xi))+(1/(theta4^theta2))*sum(xi^theta2)-(theta1*theta4)*sum(
exp((xi/theta4)^theta2))+(theta3-1)*sum(1-(exp((theta1*theta4)*(1-(exp((xi/theta
4)^theta2)))))))
+ }
> mle(logLikFun,start=list(theta1=0.00007181,theta2=3.148,theta3=0.145,theta4=49
.05),method="NR")
Error in match.arg(method) :
'arg' should be one of Nelder-Mead , BFGS , CG , L-BFGS-B , SANN , Brent
> mle(logLikFun,start=list(theta1=0.00007181,theta2=3.148,theta3=0.145,theta4=49
.05))
Error in optim(start, f, method = method, hessian = TRUE, ...) :
non-finite finite-difference value [1]
In addition: Warning message:
In log(theta1) : NaNs produced
> mle(logLikFun,start=list(theta1=0.00007181,theta2=3.148,theta3=0.145,theta4=49
.05),method="BFGS")
Error in optim(start, f, method = method, hessian = TRUE, ...) :
non-finite finite-difference value [1]
In addition: Warning message:
In log(theta1) : NaNs produced
> mle
Maximum Likelihood estimation
Newton-Raphson maximisation, 1 iterations
Return code 3: Last step could not find a value above the current.
Boundary of parameter space?
Consider switching to a more robust optimisation method temporarily.
Log-Likelihood: 516.6791 (4 free parameter(s))
Estimate(s): 7.181e-05 3.148 0.145 49.05
> optim(start=c(0.00007181,3.148,0.145,49.05),logLikFun,method="NR",hessian=TRUE
)
Error in match.arg(method) :
'arg' should be one of Nelder-Mead , BFGS , CG , L-BFGS-B , SANN , Brent
> optim(start=c(0.00007181,3.148,0.145,49.05),logLikFun,method="BFGS",hessian=TR
UE)
Error in optim(start = c(7.181e-05, 3.148, 0.145, 49.05), logLikFun, method = "B
FGS", :
cannot coerce type 'closure' to vector of type 'double'
> optim(start=list(0.00007181,3.148,0.145,49.05),logLikFun,method="BFGS",hessian
=TRUE)
Error in optim(start = list(7.181e-05, 3.148, 0.145, 49.05), logLikFun, :
cannot coerce type 'closure' to vector of type 'double'
>

Você também pode gostar