Assigning string variable to matrix element
Posted: Tue Feb 24, 2015 9:07 am
Hi,
Is it possible to assign a string variable to an element in a matrix?
The code fragment that I have written is below. I would like the output to be a 7xN matrix (N=2 in the fragment below) where the top row contains the names of the variables in the group (i.e., EURUSD and USDJPY) and the rows of the matrix contain statistics obtained from the regression (i.e., bhat) for each variable.
As it is written now, the code returns the error: Syntax error in "XRATES_RESULTS(1,1)="
Thank you.
group xrates_g EURUSD USDJPY
scalar N = xrates_g.@count
matrix(7,N) xrates_results
for !i=1 to N
%x=xrates_g.@seriesname(!i)
genr dl{%x}=100*(log({%x})-log({%x}(-1)))
equation {%x}eq.ls(cov="hac") dl{%x} c dussw2
alpha sername=%x
xrates_results(1,!i) = 'sername'
xrates_results(2,!i) = c(2)
next
Is it possible to assign a string variable to an element in a matrix?
The code fragment that I have written is below. I would like the output to be a 7xN matrix (N=2 in the fragment below) where the top row contains the names of the variables in the group (i.e., EURUSD and USDJPY) and the rows of the matrix contain statistics obtained from the regression (i.e., bhat) for each variable.
As it is written now, the code returns the error: Syntax error in "XRATES_RESULTS(1,1)="
Thank you.
group xrates_g EURUSD USDJPY
scalar N = xrates_g.@count
matrix(7,N) xrates_results
for !i=1 to N
%x=xrates_g.@seriesname(!i)
genr dl{%x}=100*(log({%x})-log({%x}(-1)))
equation {%x}eq.ls(cov="hac") dl{%x} c dussw2
alpha sername=%x
xrates_results(1,!i) = 'sername'
xrates_results(2,!i) = c(2)
next