Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

[no subject]



On Sat, Jul 3, 2010 at 8:44 AM, Austin Nichols <[email protected]> wrote:
> Michael Ralph M. Abrigo <[email protected]> :
>
> I have not read through this, but you should put the dimensions of
> every matrix in as a comment, and also print out the matrices once,
> and then maybe you will see where the error is.
>
> On Sat, Jul 3, 2010 at 2:08 AM, Michael Ralph M. Abrigo
> <[email protected]> wrote:
>> Good day statalisters!
>> I am practically new in programming, especially in Mata. I'm trying to
>> implement Lambert, Brown and Florax's (2010) poisson spatial lag model
>> ("A two-step estimator for a spatial lag model for counts: Theory,
>> small sample performance and an application", Urban and Regional
>> Economics) in Stata using full-information ML (instead of the two-step
>> LIML). However, I got stuck because of a conformability error which I
>> cannot trace (I was able to generate the matrices interactively using
>> ad hoc values). I was hoping I can do the FIML first before I venture
>> to their two-step estimator.
>> Any hint will be greatly appreciated.
>> Below is my code and the error messages.
>> Cheers,
>> Michael
>> drop _all
>> ** (1) Set version; Open file
>> version 11.0
>> webuse "dollhill3.dta", clear
>> ** (2) Generate constant; Local variables
>> gen cons = 1
>> local y deaths
>> local xlist smokes pyears cons
>> ** (3) Generate weight matrix
>> sort pyears
>> gen xcoor = _n
>> gen ycoor = _n
>> spwmatrix gecon xcoor ycoor, wname(W) wtype(bin) ///
>>    dband(0 1000) rowstand mata replace
>> ** (4) Optimize using Mata
>> mata
>>   void spmlpoisson (
>>     real scalar todo,
>> real rowvector rho_b,
>> real colvector lndensity,
>> real matrix g,
>> real matrix H)
>> {
>>       external y, X, W, I
>>  transmorphic A_inv
>>  real colvector Xb_sar, mu_sar
>>  real rowvector b
>>  real scalar rho
>>       rho_b = rho, b
>> A_inv = cholinv(I - rho * W)
>> Xb_sar = A_inv * X * b'
>>         mu_sar = exp(Xb_sar)
>> lndensity = (y :* Xb_sar) - mu_sar - lnfactorial(y)
>> }
>>   st_view(y = ., ., "`y'")
>>   st_view(X = ., ., tokens("`xlist'"))
>>   fh = fopen("W", "r")
>>     W = fgetmatrix(fh)
>>    fclose(fh)
>>   I = I(cols(W))
>>   S = optimize_init()
>>   optimize_init_evaluator(S, &spmlpoisson())
>>   optimize_init_which(S, "max")
>>   optimize_init_evaluatortype(S, "d0")
>>   optimize_init_params(S, J(1, cols(X) + 1, 0))
>>   rho_b = optimize(S)
>>                        *:  3200  conformability error
>>            spmlpoisson():     -  function returned error
>>       opt__calluser0_d():     -  function returned error
>>       opt__d0_calluser():     -  function returned error
>>     deriv__call1user_d():     -  function returned error
>>  _deriv__compute_value():     -  function returned error
>>                 _deriv():     -  function returned error
>>        opt__eval_nr_d0():     -  function returned error
>>              opt__eval():     -  function returned error
>> opt__looputil_iter0_common():     -  function returned error
>> opt__looputil_iter0_nr():     -  function returned error
>>           opt__loop_nr():     -  function returned error
>>               optimize():     -  function returned error
>>                  <istmt>:     -  function returned error
>> r(3200);
>>
>>
>> end
>
> *
> *   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/
>



-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index