[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: flip a matrix around
As it happens the ability to 'flip a matrix around' horizontally or
vertically is the subject of a forthcoming Stata Tip. As Danielle is
using Stata 9.x a Mata solution should work fine for her.
capture program drop get_dfglsResults
program get_dfglsResults, rclass
local optlag = r(maiclag)
local T = r[`optlag', 5]
local df = r(N) - `optlag'
return scalar p = ttail(`df', `T')
matrix function flipud(matrix X)
return(rows(X)>1 ? X[rows(X)..1,.] : X)
Kit Baum, Boston College Economics
An Introduction to Modern Econometrics Using Stata:
On Aug 3, 2006, at 2:33 AM, Danielle wrote:
The problem is that the results of dfgls for each lag are listed in
reverse order (i.e., results for lag m are listed first and results
for lag 1 are listed last). So, the line "local T = r[`optlag', 5]"
does not grab the right row. Can I flip the matrix r around so (or
re-sort the rows) so that the first row corresponds to the results
for lag 1 and the row m corresponds to results for lag m? Or is
there perhaps a better way to approach this?
* For searches and help try: