Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Alan Marshall <A.D.Marshall@leeds.ac.uk> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
st: ml - could not calculate numerical derivatives missing values encountered |

Date |
Thu, 15 Dec 2011 13:16:29 +0000 |

Dear Statalist, I having problems fitting a model to predict rates of specific types of disability for single years of age (0,1,2,......88) using maximum likelihood estimation in stata. I would be very grateful for any advice that can be offered. I am using a technique from the demography literature, known as relational models, to estimate age specific rates of disability (which are unreliable due to small samples) using age specific rates of limiting long term illness (which are reliable). The model I am fitting involves two parameters α and β that adjust the level and shape of the curve of age specific limiting long term illness rates to represent the curve of age specific disability rates. I have fitted the model using weighted least squares regession but have been advised that a maximum likelihood model is more appropriate. I have worked out the log-likelihood function as below. Dx is the number of people with a disability at age x, Nx is the total population at age x and Lx is the logit of the rate of limiting long term illness at age x. I’m fairly confident in this function because if I experiment in Excel with different values of α and β the log likelihood function does appear to be maximised by values of α and β that are very close to the Weighted Least Squares solutions. Log Likelihood=(2*α*Dx) + (β*Yx*Dx )- (Nx*ln(1+exp(2*(α+βLx))) (Note this likelihood is summed over all ages x) I am fitting this model in stata as below: *line 1 program define Brass *line 2 args lnf a b *line 3 Quietly replace `lnf'=2*`a'*${dx_Dis}1+`b'*${Yxl}1*${dx_Dis}1-(${Nx_Dis}1*ln(1+(exp(2*(`a'+`b'*${Yxl}1))))) *line 4 end *Line 5 ml model lf Brass (D_OBS_RT=Yxl Nx_Dis dx_Dis) (D_OBS_RT=Yxl Nx_Dis dx_Dis) *Line 6 ml maximize Line 3 defines the log likelihood function to be maximised. Yxl are the log odds of the LLTI rates dx_Dis is the age specific number of people with a disability, Nx_Dis is the age-specific number of people at each age Line 5 - I have included two brackets which as I need to estimate two parameters α and β. In each case I think I am predicting the rate of disability (D_OBS_RT) given three variables of dx_Dis (age specific number of people with a disability), Yxl (log odds of limiting long term illness) and Nx_Dis (age specific total population). The error that is returned from this is: "could not calculate numerical derivatives missing values encountered" Any advice is gratefully received. Best wishes Alan Marshall * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: ml - could not calculate numerical derivatives missing values encountered***From:*Stas Kolenikov <skolenik@gmail.com>

**Re: st: ml - could not calculate numerical derivatives missing values encountered***From:*Maarten Buis <maartenlbuis@gmail.com>

- Prev by Date:
**Re: st: How to solve the matrix equation AX = B for X without using Mata** - Next by Date:
**Re: st: How to solve the matrix equation AX = B for X without using Mata** - Previous by thread:
**st: How to solve the matrix equation AX = B for X without using Mata** - Next by thread:
**Re: st: ml - could not calculate numerical derivatives missing values encountered** - Index(es):