LeeExcellent. 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,
On Thu, Apr 11, 2013 at 3:10 PM, Allin Cottrell <cottrell@wfu.edu> wrote:It works OK with Stata 12 on Linux. I don't have Stata forOn 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("@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.
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@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel