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
Number of different values of a given variable for every combination of other two variablesI have a hospital record dataset with variables such as hospitalisation id (n_aih), year of hospital…
Identify string as part of another stringDear statalist users, I have the following (stylized) data: Code: * Example generated by -dataex…
Question: Need help separating a variableHi Everyone, I have been having trouble separating the following SubjectCourse variable. The below …
Marginsplot for categorical IV and categorical DV?I am trying to figure out how to visually show marginal effects of categorical IVs on categorical DV…
modelling stated preferences for discrete choices with case sensitive variablesHi, I'm trying to model a discrete choice (4 options available to each respondent in each scenario …
Subscribe to:
Post Comments (Atom)
0 Response to trouble shooting a mata function
Post a Comment