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 |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Mata and do files |

Date |
Thu, 11 Aug 2011 01:12:52 +0100 |

Not a problem; in any case I was evidently not giving enough detail to be completely clear. Nick On Thu, Aug 11, 2011 at 1:09 AM, Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com> wrote: > Ah, I see. Sorry about the mix-up then. > > T > > On Wed, Aug 10, 2011 at 5:06 PM, Nick Cox <njcoxstata@gmail.com> wrote: >> Quite so, and I didn't say otherwise. I am replying to Alex's question >> addressed to me of why I recommended that Alex use -tokens()-, which >> is explicit below. >> >> I am pointing out that doing without -tokens()- does not work with >> 10.1, but without experiment I can not be absolutely sure that >> -st_view()- is not more indulgent in 11 or 12. >> >> Nick >> >> On Thu, Aug 11, 2011 at 12:57 AM, Tirthankar Chakravarty >> <tirthankar.chakravarty@gmail.com> wrote: >>> Nick, >>> >>> That does not appear to be the code I sent to the list in my (Wed, Aug >>> 10, 2011 at 2:22 PM) posting. Here it is again: >>> >>> /******************************/ >>> sysuse auto, clear >>> capture mata mata drop theta() >>> mata >>> // mata set matastrict on >>> mata set matastrict off >>> >>> // define theta() function >>> real scalar theta() >>> { >>> st_view(a = ., ., tokens("price length weight")) >>> a_cov = variance(a) >>> a_eigen = symeigensystem(a_cov, X = ., L = .) >>> return(L[1]/sum(L)) >>> } >>> theta() >>> end >>> /******************************/ >>> >>> T >>> >>> On Wed, Aug 10, 2011 at 4:36 PM, Nick Cox <njcoxstata@gmail.com> wrote: >>>> I have 12, but it's at my workplace, and I'm not. >>>> >>>> . sysuse auto >>>> (1978 Automobile Data) >>>> >>>> . mata >>>> ------------------------------------------------- mata (type end to exit) ----- >>>> : st_view(a = ., ., "price length weight") >>>> variable price length weight not found >>>> st_view(): 3500 invalid Stata variable name >>>> <istmt>: - function returned error >>>> r(3500); >>>> >>>> : end >>>> ------------------------------------------------------------------------------- >>>> >>>> . about >>>> >>>> Stata/SE 10.1 for Windows >>>> Born 10 Jun 2010 >>>> >>>> >>>> On Thu, Aug 11, 2011 at 12:30 AM, Tirthankar Chakravarty >>>> <tirthankar.chakravarty@gmail.com> wrote: >>>>> Nick, >>>>> >>>>> I don't have 12 either. That code was from a fully-updated 11.2. >>>>> >>>>> However, I have just checked with my 10.1 and it seems to go through >>>>> without problems. >>>>> >>>>> T >>>>> >>>>> On Wed, Aug 10, 2011 at 3:57 PM, Nick Cox <njcoxstata@gmail.com> wrote: >>>>>> It didn't work for me in Stata 10.1. (My machine with Stata 12 is a mile away.) >>>>>> >>>>>> Nick >>>>>> >>>>>> On Wed, Aug 10, 2011 at 11:46 PM, Alex Olssen <alex.olssen@gmail.com> wrote: >>>>>>> Thanks for the help! >>>>>>> >>>>>>> Tirthankar your solution works perfectly - the code works >>>>>>> interactively and from a do file. >>>>>>> >>>>>>> One question though, could you explain to me why I need to turn matastrict off? >>>>>>> >>>>>>> Nick, you said "price length weight" is not an acceptable argument for >>>>>>> -st_view()- however typing the following interactively in a new Stata >>>>>>> session suggests otherwise. >>>>>>> >>>>>>> sysuse auto, clear >>>>>>> mata >>>>>>> st_view(a=., ., "price length weight") >>>>>>> a >>>>>>> >>>>>>> Am I missing something? >>>>>>> >>>>>>> Cheers, >>>>>>> Alex >>>>>>> >>>>>>> On 11 August 2011 09:23, Nick Cox <njcoxstata@gmail.com> wrote: >>>>>>>> "price length weight" is not an acceptable argument for -st_view()-. >>>>>>>> You need to tokenize it. >>>>>>>> >>>>>>>> I imagine that the do-file approach requires you to leave Mata with an >>>>>>>> -end- statement. >>>>>>>> >>>>>>>> Nick >>>>>>>> >>>>>>>> On Wed, Aug 10, 2011 at 10:14 PM, Alex Olssen <alex.olssen@gmail.com> wrote: >>>>>>>>> Dear Nick, >>>>>>>>> >>>>>>>>> You are absolutely correct - it was Statalist. >>>>>>>>> >>>>>>>>> I am not sure what you mean by "try tokens("price length weight")." >>>>>>>>> >>>>>>>>> I looked at the help file and then tried the following, which again >>>>>>>>> works interactively but not from a do file... >>>>>>>>> >>>>>>>>> sysuse auto, clear >>>>>>>>> mata >>>>>>>>> real scalar theta() >>>>>>>>> { >>>>>>>>> st_view(a = ., ., tokens("price length weight")) >>>>>>>>> a_cov = variance(a) >>>>>>>>> a_eigen = symeigensystem(a_cov, X = ., L = .) >>>>>>>>> return(L[1]/sum(L)) >>>>>>>>> } >>>>>>>>> theta() >>>>>>>>> >>>>>>>>> Any ideas? >>>>>>>>> >>>>>>>>> On 10 August 2011 23:54, Nick Cox <njcoxstata@gmail.com> wrote: >>>>>>>>>> It's not Stata that bounces your emails; it's Statalist! >>>>>>>>>> >>>>>>>>>> Try >>>>>>>>>> >>>>>>>>>> tokens("price length weight") >>>>>>>>>> >>>>>>>>>> Nick >>>>>>>>>> >>>>>>>>>> On Wed, Aug 10, 2011 at 12:39 PM, Alex Olssen <alex.olssen@gmail.com> wrote: >>>>>>>>>>> Hi everyone, >>>>>>>>>>> >>>>>>>>>>> Apologies to anybody who gets this message twice - I just got an email >>>>>>>>>>> from Stata telling me my first message was bounced. I checked the >>>>>>>>>>> archive and it doesn't appear to have arrived correctly. In any >>>>>>>>>>> case... >>>>>>>>>>> >>>>>>>>>>> I am trying to learn some Mata and am having difficult running Mata >>>>>>>>>>> code from a do file. >>>>>>>>>>> >>>>>>>>>>> For example I can use the following code interactively, but if I try >>>>>>>>>>> run it from the do-file editor I get error r(3000). I have looked >>>>>>>>>>> around for an answer in [M] and the Statalist archives to no avail. >>>>>>>>>>> >>>>>>>>>>> sysuse auto, clear >>>>>>>>>>> mata >>>>>>>>>>> real scalar theta() >>>>>>>>>>> { >>>>>>>>>>> st_view(a = ., ., "price length weight") >>>>>>>>>>> a_cov = variance(a) >>>>>>>>>>> a_eigen = symeigensystem(a_cov, X = ., L = .) >>>>>>>>>>> return(L[1]/sum(L)) >>>>>>>>>>> } >>>>>>>>>>> theta() >>>>>>>>>>> >>>>>>>>>>> Any help would be greatly appreciated. >> >> * >> * 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/ >> > > > > -- > Tirthankar Chakravarty > tchakravarty@ucsd.edu > tirthankar.chakravarty@gmail.com > > * > * 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/

**References**:**st: Mata and do files***From:*Alex Olssen <alex.olssen@gmail.com>

**Re: st: Mata and do files***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Mata and do files***From:*Alex Olssen <alex.olssen@gmail.com>

**Re: st: Mata and do files***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Mata and do files***From:*Alex Olssen <alex.olssen@gmail.com>

**Re: st: Mata and do files***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Mata and do files***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

**Re: st: Mata and do files***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Mata and do files***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

**Re: st: Mata and do files***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Mata and do files***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

- Prev by Date:
**Re: st: Mata and do files** - Next by Date:
**Re: Re: Re: st: pick maximum,minimum, mode and median among scalars** - Previous by thread:
**Re: st: Mata and do files** - Next by thread:
**RE: st: Mata and do files** - Index(es):