[R] Standard error

Christopher Kelvin chris_kelvin2001 at yahoo.com
Sun Apr 22 11:22:25 CEST 2012


Hello,
I have tried obtaining the value of standard error from the code below but i get different values when i compare it with the 
standard error obtained from the hessian matrix. Can somebody help me out?
Thank you

n=100;rr=1000
p1=1.2;b=1.5
sq11=sq21=0
for (i in 1:rr){
t<-rweibull(n,shape=p1,scale=b)
meantrue<-gamma(1+(1/p1))*b
meantrue
d<-meantrue/0.40
cen<- runif(n,min=0,max=d)
s<-ifelse(t<=cen,1,0)
q<-c(t,cen)

z<-function(data, p){ 
beta<-p[1]
eta<-p[2]
log1<-(n*sum(s)*log(p[1])-n*sum(s)*(p[1])*log(p[2])+sum(s)*(p[1]-1)*sum(log(t))-n*sum((t/(p[2]))^(p[1])))
return(-log1)
}

start <- c(1,1)
zz<-optim(start,fn=z,data=q,hessian=T)
zz
m1<-zz$par[2]
p<-zz$par[1]

sq11<-sq11+(1/rr*(sum((q-m1)^2)))
sq21<-sq21+(1/rr*(sum((q-Lm1)^2)))

}

se11<-sqrt(sq11)/(rr-1)
se11
se21<-sqrt(sq21)/(rr-1)
se21

f<-solve(zz$hessian)
se<-sqrt(diag(f))
se


Chris Guure
Researcher
Institute for Mathematical Research
UPM




More information about the R-help mailing list