# STATA mle function for Mcfadden MNL model

I am estimating the covariates for an aggregate market data set. I am aware of the pre-existing STATA packages out there like mlogit, clogit etc.., however they do not fit my case as I am working with aggregate and not individual level data. I have tried writing out a MLE function but it does not seem to be working

 program define mcfadden
args lnf Xb
quietly replace lnf' = Xb' - ln(1+sum(exp(Xb')))
end
`

My dependant variable is market shares and my independant are product characteristics like price and product attributes. So I am estimating the likelihood as given below

I need help on knowing what's wrong with my code.