Dear all,
I am having problems with a function embedded in a customized program. Below is the said function:
real rowvector rs_max2(real matrix X)
{
real scalar j
real rowvector xres
real colvector v
/*designate vector xres to temporarily store the results:*/
xres = J(1, cols(X), .)
/*get the index for the maximum:*/
for(j=1; j<=cols(X); j++){
maxindex(X[.,j], 3, v=., .)
xres[1, j] = X[v[2],j]
}
return(xres)
}
I wrote this function to get the second smallest value for each column of a matrix X. It is part of an .ado program, which is very long. I believe the error occurs within this function because the error message I got is:
'real' found where almost anything else expected
(229 lines skipped)
, and the 229 lines from the bottom of the entire program is the line: " real scalar j" or " real rowvector xres"
I have scrutinized this function multiple times, but could not find an error. Could you please help me check which part of it is mistaken? Thank you very much in advance.
Related Posts with trouble shooting a mata function
Create a variable that has only one value per categoryI have data on automobile collisions in a particular region and, among other things, have data on th…
Calculate the rolling standard deviation for only even yearsDear all, We are stuck with a problem regarding the calculation of rolling averages only for even f…
Event study/ DID/ Individual FE/ Time&County FEHi, I am new to Stata and in need of an advice on how to translate my model specification into code…
Monthly labor force status stored as a string variableHello, I am working with a data set which storing monthly labour force status during the survey ref…
Is my Xtdpdgmm syntax correct?xtdpd L(0/2).n L(0/1).(w k ys) year yr1980-yr1984, dgmmiv(n w k ys) div(year yr1980-yr1984) twostep …
Subscribe to:
Post Comments (Atom)
0 Response to trouble shooting a mata function
Post a Comment