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

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

From |
Misha Spisok <misha.spisok@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: mata conformability error, but matrices are conformable |

Date |
Sat, 8 May 2010 15:09:14 -0700 |

Thank you, Professor Buis! This works (of course), but I have a further question about forcing a `noconstant' in the regression (I think I'll need e(b) to exclude a constant if my sketch continues as imagined). I have tried a number of things, but I cannot get it to work the way I'd like it to work. For example (same code with one change at regression -poisson-, though I have the same problem with -regress-), program calcp, rclass version 10.1 syntax varlist [if] [in] marksample touse gettoken lhs rhs : varlist poisson `lhs' `rhs' if `touse', noconstant /* CHANGED: to try to force it to omit a constant */ mata: makexb("`rhs'", "`touse'") end mata: void makexb(string scalar rhs, string scalar touse) { real matrix X real rowvector b real colvector Xb real scalar idx X = st_data(., tokens(rhs), touse) X = X, J(rows(X), 1, 1) b = st_matrix("e(b)") Xb = X*b' idx = st_addvar("float", "Xb") st_store(., idx, touse, Xb) } end I also tried changing the -syntax- line by including a non-optional noconstant option: , noconstant. When I try the above code, I get no constant (as desired), but I get this error: *: 3200 conformability error makexb(): - function returned error <istmt>: - function returned error r(3200); If I make the following changes: syntax varlist [if] [in] [,noCONStant] poisson `lhs' `rhs' if `touse', `noconstant' then I get a constant _and_ the same error. If, instead, I make the following changes: syntax varlist [if] [in] , noCONStant poisson `lhs' `rhs' if `touse', `noconstant' I, again, get a constant _and_ the same error. Example for error: sysuse auto, clear local xlist mpg-length calcp price `xlist', noconstant Thank you again. Yours, Misha On Sat, May 8, 2010 at 1:59 AM, Maarten buis <maartenbuis@yahoo.co.uk> wrote: > --- On Sat, 8/5/10, Misha Spisok wrote: >> > I am getting the following error due to some code I >> > have written (given below with complete, but short, >> > working example to reproduce the error): > > --- On Sat, 8/5/10, Maarten buis wrote: >> The changed code below works: > > My earlier code, as well as the original code, > ignored the selection of observations stored in `touse', > so the Mata function can be better written as: > > *------------------ begin code --------------------- > mata: > void makexb(string scalar rhs, string scalar touse) > { > real matrix X > real rowvector b > real colvector Xb > real scalar idx > > X = st_data(., tokens(rhs), touse) > X = X, J(rows(X), 1, 1) > b = st_matrix("e(b)") > Xb = X*b' > idx = st_addvar("float", "Xb") > st_store(., idx, touse, Xb) > } > end > *--------------- end code ----------------- > > Hope this helps, > Maarten > > -------------------------- > Maarten L. Buis > Institut fuer Soziologie > Universitaet Tuebingen > Wilhelmstrasse 36 > 72074 Tuebingen > Germany > > http://www.maartenbuis.nl > -------------------------- > > > > > * > * 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/ > * * 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: mata conformability error, but matrices are conformable***From:*Maarten buis <maartenbuis@yahoo.co.uk>

**References**:**Re: st: mata conformability error, but matrices are conformable***From:*Maarten buis <maartenbuis@yahoo.co.uk>

**Re: st: mata conformability error, but matrices are conformable***From:*Maarten buis <maartenbuis@yahoo.co.uk>

- Prev by Date:
**st: RE: Delete missing** - Next by Date:
**Re: st: gradient in -ml- producing type mismatch?** - Previous by thread:
**Re: st: mata conformability error, but matrices are conformable** - Next by thread:
**Re: st: mata conformability error, but matrices are conformable** - Index(es):