Colleagues - I am trying to write a rather complex maximum likelihood program. One of the complexities is that I want to create a program that can accept user-written routines to calculate likelihood values from different types of data. The program uses several functions I have written. First there is a main function that reads in what kind of data will be used. It then calls OPTIM. which uses a function called "A" for simplicity. "A" then calls "B" which returns life tables. "A" then calls "C" which uses the life tables to calculate the log-likelihood. This set up allows for telling "A" to call other user-define functions (e.g., "C1", "C2", etc.) to calculate the likelihood from other types of data. Having the life tables generated in a different subroutine makes this function available for producing useful output based on the parameter estimates. The program flow should go like this: the main program to OPTIM to A to B to A to C to A then back to OPTIM which should continue this chain repeatedly to test new values of the parameters. The program successfully gets through the initial calculation of the log likelihood and gets to the end of A where it prints out the correct value. It doesn't print a second estimate of the log likelihood based on a new set of parameters. The program ends at this point. The output looks like this (with my annotations at the far right): [1] "call LL" trace: optim(param.est, LogLikelihood(param.est, nMx, N.genes, N.RR, N.pop, N.lt, N.ages, N.alleles, N.types, N.a, a.base, a.assign, R, sigma, genotype.frq, lx.base, lx, popXlt, N.Data, data.pop, female, data.lt, years, age.1st, age.2nd, pop, deaths)) [1] "Start LL" (i.e., start A) [1] "start lt" (i.e., start B) [1] "Start LL_Basic" (i.e., start C) [1] -9536.731 [1] "end LL" (i.e., end A) Error in function (par) : could not find function "fn" Any suggestions would be greatly appreciated. Doug -- Douglas Ewbank, Ph.D. Research Professor Population Studies Center University of Pennsylvania Tel: 215-898-7999 Cell: 215-284-3376 Fax: 215-898-2124