[R] SE for parameters estimated by optim() - problem with constraints
Tomasz Berezowski
tojatomek at gmail.com
Tue Nov 22 14:58:10 CET 2011
Dear all,
I have a problem with calculation of SE of parameters with a fisher
matrix. the fisher matrix is calculated from the hessian matrix which
is an output from optim(). However, can I calculate it this way if the
optimisation criterion was to minimise RMSE? Maybe it works only with
a log-likelihood optimisation?
The more important problem is that I need to put constarints on my
parameters, that: all parameters are between 0 and 1 and their sum =
1. I use following transformation:
nSpec = length(pars)
pars = exp(pars) / (1 + sum(exp(pars[1:nSspec])))
pars[nSspec] = 1 - sum(pars[1:(nSspec-1)])
where, pars is a vector of parameters supplied by optim()
In this case I am calculating SE for untransformed parameters which is
obviously not what I need. What sould I do to calculate SE for
transformed parameters?
My full optimization function:
opt = function(pars)
{
pars=exp(pars)/(1+sum(exp(pars[1:nSspec])))
pars[nSspec]=1-sum(pars[1:(nSspec-1)])
for(i in 1:nSspec) est = est + pars[i] * selSpec[,i]
sum(abs(est-spec))
}
where:
nSspec is a number of parameters
spec is the vector to which I want to fit the vector est
selSpec is a constant matrix with nSspec columns and length(spec) rows
I hope you can help me. Best regards,
Tomasz
More information about the R-help
mailing list