UseRs,
I used the optim function
valor.optim <- optim(c(1,1,1),logexp1,method
="BFGS",control=list(fnscale=-1),hessian=T);
and I want to calculate the derivates,
psi1<-valor.optim$par[1]
psi2<-valor.optim$par[2]
psi3<-valor.optim$par[3]
a0=exp(psi1);
a1=exp(psi2)/(20+exp(psi2)+exp(psi3));
a2=exp(psi3)/(20+exp(psi2)+exp(psi3))
deriv.psi1<-numericDeriv(a0,c("psi1","psi2","psi3"));
deriv.psi2<-numericDeriv(a1,c("psi1","psi2","psi3"));
deriv.psi3<-numericDeriv(a2,c("psi1","psi2","psi3"));
but I found,
>
deriv.psi1<-numericDeriv(a0,c("psi1","psi2","psi3"));
> deriv.psi1
[1] 0.038384
attr(,"gradient")
[,1] [,2] [,3]
[1,] 0 0 0
>
deriv.psi2<-numericDeriv(a1,c("psi1","psi2","psi3"));
> deriv.psi2
[1] 0.05754
attr(,"gradient")
[,1] [,2] [,3]
[1,] 0 0 0
deriv.psi3<-numericDeriv(a2,c("psi1","psi2","psi3"));> deriv.psi3
[1] 0.93315
attr(,"gradient")
[,1] [,2] [,3]
[1,] 0 0 0
The derivates are zero. Why?