Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Observation-by-observation calculation

From   "Julian Fennema" <>
Subject   st: Observation-by-observation calculation
Date   Tue, 19 Nov 2002 17:48:35 -0000

Dear all,

This question links to earlier ones regarding the writing of user-
defined function for Stata, which is not allowed. Please alert me if I 
am barking up the totally wrong tree here in trying to solve my 

The question with which I am dealing is to write a d1 routine for -ml- 
estimation. Part of the likelihood function uses the bivariate normal, 
which I have calculated using numerical approximation, as I have 
done the derivative with respect to the four argument (here x, y, 
rho, sigma). 

The gradient vector returned by d1debug for my procedure is 
disturbingly different from the numerical gradient calculated by the 
program, although I am sure of my own derivative calculations. I 
believe that this is because I had missed the fact that the derivative 
was being calculated for the components of the `b' vector for the 
whole sample (as in the r-class subroutine calculating the derivative 
was only run once each iteration), and not observation-by-

Therefore I need to calculate the derivative for each observation to 
allow -mlvecsum- to aggregate up to a score function. This requires 
an observation-by-observation calculation of the derivative, later 
summed. How can I acheive this?

With thanks for any thoughts and advice,

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index