Hi,
The problem I have is that the standard errors for the estimates doesn't
make any sense. Here is the background:
The values in vector a are seen as the true values and I want to estimate them
using mle. I make 100 "disturbed" vectors from a by adding noise,
N(0,sigma^2). For every disturbed vector I sort them in decreasing order. Say
that the observed order is: y[1]>y[4]>y[5]>y[3]>y[2] We want to
calculate the probability to observe this order and we do so by:
P(Y[1]-Y[4]>0|a)*P(Y[4]-Y[5]>0|a)*P(Y[5]-Y[3]>0|a)*P(Y[3]-Y[2]>0|a)
(we ignore the dependency), where Y[1]-Y[4] ~ N(a[1]-a[4],2*std^2) and so on.
Usually when you use mle you use density function, but here we use pnorm. The
problem I have after running the code below is that the standard errors are all
the same (and way too large) for the estimates. What can I have done wrong?
R-code
#library(stats4)n <- 100x <- mat.or.vec(n,5)y <- mat.or.vec(n,5)a <-
c(100,100.5,100.75,100.7,100.25) std <- sd(a)Var <- std^2for(i in
1:n){ y[i,] <- a+rnorm(5,mean=0,sd=std) x[i,] <- sort(y[i,],decreasing =
TRUE,index.return=TRUE)$ix }
matris <- mat.or.vec(n,4)sigma <- sqrt(2*Var)fit <-
function(f1,f2,f3,f4,f5,x){ for(i in 1:n){ for(j in 1:4){ P <- if(x[i,j]
== 1) {f1} else if(x[i,j] == 2) {f2} else if(x[i,j] == 3) {f3} else if(x[i,j] ==
4) {f4} else {f5} Q <- if(x[i,j+1] == 1) {f1} else if(x[i,(j+1)] == 2) {f2}
else if(x[i,(j+1)] == 3) {f3} else if(x[i,(j+1)] == 4) {f4} else {f5} mu <-
P-Q matris[i,j] <- pnorm(0,mean=mu,sd=sigma,lower.tail=FALSE,log.p=TRUE)
} } -sum(matris)}mle.results <-
mle(fit,start=list(f1=a[1],f2=a[2],f3=a[3],f4=a[4],f5=a[5]),fixed=list(x=x))summary(mle.results)
Best regardsAlex
[[alternative HTML version deleted]]