Well, I'm not making much progress. The .ado file works manually, but I
don't think Stata can find it when the foreign command is executed.
Actually, gretl doesn't like the foreign language=stata in Windows at all.
So, I don't think the problem is with gretl_export.
In fact, this generates the error (Windows) "The System cannot find file
specified."
<>
foreign language=stata
end foreign
</>
It's possible that Stata is being confused by the forward slashes in the
adopath +? This is the only statement that appears in the gretltmp.do.
Stata normally looks for backslashes under windows. But I'm just
guessing. Anyone else with Windows using Stata?
Lee
On Thu, Apr 11, 2013 at 3:14 PM, Lee Adkins <lee.adkins(a)okstate.edu> wrote:
Excellent. I'll give it a go. Stata is horrendous to program I
think.
Or maybe I'm just not much of a programmer! Same result, though....
Thanks,
Lee
On Thu, Apr 11, 2013 at 3:10 PM, Allin Cottrell <cottrell(a)wfu.edu> wrote:
> On Thu, 11 Apr 2013, Lee Adkins wrote:
>
> > I can't seem to make this work. Here is the example from
> > the User's Guide
> >
> > <hansl>
> > function matrix stata_reorder (matrix se)
> > scalar n = rows(se)
> > return se[n] | se[1:n-1]
> > end function
> >
> > open data4-1
> > ols 1 0 2 3 --cluster=bedrms
> > matrix se = $stderr
> >
> > foreign language=stata --send-data
> > regress price sqft bedrms, vce(cluster bedrms)
> > matrix vcv = e(V)
> > gretl_export vcv "vcv.mat"
> > end foreign
> >
> > matrix stata_vcv = mread("(a)dotdir/vcv.mat")
> > stata_se = stata_reorder(sqrt(diag(stata_vcv)))
> > matrix check = se - stata_se
> > print check
> > <\hansl>
> >
> > There is something fishy about gretl_export. I can't seem to get a
> matrix
> > written to the dotdir directory (or anywhere else). The data are
> created
> > and loaded into Stata, the regression runs in the background, but
> vcv.mat
> > is nowhere to be found. I'm using version Stata 12 on Windows.
>
> It works OK with Stata 12 on Linux. I don't have Stata for
> Windows so I'm not in a position to test. But the
> "gretl_export" command is implemented by gretl_export.ado
> (which is written into dotdir). It looks like this:
>
> <stata>
> program define gretl_export
> version 8.2
> local matrix `1'
> local fname `2'
> tempname myfile
> file open `myfile' using "`fname'", write text replace
> local nrows = rowsof(`matrix')
> local ncols = colsof(`matrix')
> file write `myfile' %8.0g (`nrows') %8.0g (`ncols') _n
> forvalues r=1/`nrows' {
> forvalues c=1/`ncols' {
> file write `myfile' %15.0e (`matrix'[`r',`c']) _n
> }
> }
> file close `myfile'
> end
> </stata>
>
> Perhaps you can experiment by running something like this
> manually.
>
> Note that there's no dotdir path in this function (sorry,
> "program"!), but the writing to dotdir is (or should be)
> achieved by gretl doing chdir() into dotdir before running the
> stata commands under "foreign" -- this being the only way we
> can control where stata writes its .log output.
>
> Allin
>
>
> _______________________________________________
> Gretl-devel mailing list
> Gretl-devel(a)lists.wfu.edu
>
http://lists.wfu.edu/mailman/listinfo/gretl-devel
>
--
Lee Adkins
Professor of Economics
lee.adkins(a)okstate.edu
learneconometrics.com
--
Lee Adkins
Professor of Economics
lee.adkins(a)okstate.edu
learneconometrics.com