Hi, | From: Timur Elzhov <[EMAIL PROTECTED]> | Date: Mon, 10 Feb 2003 19:06:18 +0300 | | Dear R experts! | | I try to minimize a function with external C fitting function. | I get the hessian matrix. Here it is: | | [,1] [,2] [,3] [,4] | [1,] 1.8816631 0 0.8859803 0 | [2,] 0.0000000 0 0.0000000 0 | [3,] 0.8859803 0 0.4859983 0 | [4,] 0.0000000 0 0.0000000 0
First, are you sure that your fitting (minimisation?) routine handles the problem correctly? Not all of the optimising routines are able to deal with constant parameters. | Second and fourth rows/columns have zero values only. That's OK, | because that ones related to parameters were not included in fitting | expression (but *were* passed to minimization function as arguments), | so dF/dp == 0 for them. It of course doesn't make sense to calculate | the standard errors for the mentioned "fitting-independent" | parameters, but I want to do that for others! I read in R-intro, that | I have to calculate the inverse of hessian at first. | solve(hessian) logs: | | Error in solve.default(hessian) : singular matrix `a' in solve The matrix is definitely singular. In the example above, you have in fact fitted a 2-parameter model and made a hessian which includes 2 extra rows and columns (of course, it depends on your fitting algorithm, but I guess it handles the problem in this way). Then you have to exclude those rows and columns when you invert the hessian. I use to do so: ind <- c(1, 3) # indices you need varcov <- matrix(0, 4, 4) varcovar[ind,ind] <- solve(hessian[ind,ind]) I.e. invert only parameter-depending part of the hessian and put it into the corresponding elements in the full varcovar matrix (if you need that). Be sure how your fitting algorithm handles constant parameters! Best wishes, Ott | So, the question is: | How can I calculate the errors of remaining parameters (without | removing "fitting-independent" parameters from arguments)? | | Thanks! | | | -- | WBR, | Timur ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
