Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Sergiy Radyakin <serjradyakin@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: error 506 (matrix not positive definite) when bootstrapping eigenvalue after one-way manova |
Date | Tue, 14 Jun 2011 19:59:32 -0400 |
Hello Carlo, below is a somewhat more compact code that still exhibits the same problem as you have. Note: 1) the use of the version statement 2) sysuse is used here instead of use not to bother about the path 3) no magic numbers in the code, constants are determined from data 4) _manova is called internally by manova. The error 506 is related to matrix not being positive definite. You may want to read the formulas in the Stata documentation (PDF or printed, not help) for manova to figure out exactly why this is a requirement. Best, Sergiy Radyakin //---------------------------------------------------------------------------------------- version 9 clear sysuse auto // THIS WORKS _manova price mpg=i.foreign [], // TRANSFORM VARIABLES sum price if foreign local foreign_price=r(mean) sum price if foreign==0, meanonly replace price=price-r(mean)+`foreign_price' if foreign==0 sum price if foreign==1, meanonly replace price=price-r(mean)+`foreign_price' if foreign==1 sum mpg if foreign local foreign_mpg=r(mean) sum mpg if foreign==0, meanonly replace mpg= mpg-r(mean)+`foreign_mpg' if foreign==0 sum mpg if foreign==1, meanonly replace mpg= mpg-r(mean)+`foreign_mpg' if foreign==1 // TRY AGAIN, THIS DOES NOT WORK _manova price mpg=i.foreign [], //---------------------------------------------------------------------------------------- END -------------- On Tue, Jun 14, 2011 at 11:55 AM, Carlo Lazzaro <carlo.lazzaro@tin.it> wrote: > Dear Sergiy, > thanks a lot for your reply and pointing out my mistake in copying and > pasting the code. Now it seems to work properly (apart from error 506) > Kindest Regards, > Carlo > ------------------------code begins-------------------------------- > use "C:\Programmi\Stata9\ado\base\a\auto.dta" > manova price mpg=foreign > mat c =e(eigvals_m)' > svmat double c, name(eigen_m) > scalar sctr=trace(c) > by foreign, sort: sum price > sum price if foreign==0, meanonly > replace price=price-r(mean)+6384.682 if foreign==0 > sum price if foreign==1, meanonly > replace price=price-r(mean)+6384.682 if foreign==1 > by foreign, sort: sum mpg > sum mpg if foreign==0, meanonly > replace mpg= mpg-r(mean)+24.77273 if foreign==0 > sum mpg if foreign==1, meanonly > replace mpg= mpg-r(mean)+24.77273 if foreign==1 > bootstrap trace(c), reps(10000) nodots strata(foreign) bca seed(12345): > manova price mpg=foreign > -------------------------code ends------------------------------------ > -----Messaggio originale----- > Da: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Sergiy Radyakin > Inviato: martedì 14 giugno 2011 16.51 > A: statalist@hsphsun2.harvard.edu > Oggetto: Re: st: error 506 (matrix not positive definite) when bootstrapping > eigenvalue after one-way manova > > Hello Carlo, > > the code you posted breaks down sooner with the message: > . svmat double c, name(eigen_m) > matrix c not found > r(111); > > > What is in matrix C? > > Best, Sergiy Radyakin > > > On Tue, Jun 14, 2011 at 9:19 AM, Carlo Lazzaro <carlo.lazzaro@tin.it> wrote: >> Dear Statalisters, >> before bootstrapping eigenvalue after one-way manova using auto.dta and >> Stata 9.2/SE, I imposed the equality of the means in price and mpg for > both >> foreign and domestic cars. >> When I invoked bootstrap, error message r(506) related to model term > foreign >> appeared. >> Can anybody please give me some hint about the reason of this drawback and >> how to work it around? >> Thanks a lot for your kindness and for your time. >> Kindest Regards, >> Carlo >> ------------code begins----------------------- >> use "C:\Programmi\Stata9\ado\base\a\auto.dta" >> manova price mpg=foreign >> svmat double c, name(eigen_m) >> scalar sctr=trace(c) >> by foreign, sort: sum price >> sum price if foreign==0, meanonly >> replace price=price-r(mean)+6384.682 if foreign==0 >> sum price if foreign==1, meanonly >> replace price=price-r(mean)+6384.682 if foreign==1 >> by foreign, sort: sum mpg >> sum mpg if foreign==0, meanonly >> replace mpg= mpg-r(mean)+24.77273 if foreign==0 >> sum mpg if foreign==1, meanonly >> replace mpg= mpg-r(mean)+24.77273 if foreign==1 >> bootstrap trace(c), reps(10000) nodots strata(foreign) bca seed(12345) : >> manova price mpg=foreign >> failure for model term foreign >> an error occurred when bootstrap executed manova >> r(506); >> ------------code ends----------------------- >> >> >> * >> * 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/ > > > > * > * 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/