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
tempfileI often execute - in separate instances of Stata - multiple simultaneous do-files. Many of my do-fil…
Omitted Interactions in Negative Binomial Panel RegressionHello, I ran into some trouble when introducing interaction effects in my model. To quickly explain…
Combine two variables into a dummy variableHey dear STATA Users, I am meant to create a dummy variable. That's literally a set of dummy variab…
I don't understand why the results show different significance?Hi, Statalisters: I am not so much good in posting on the forum, please excuse me for not adhering t…
Trajectory analysis - keep registry_HbA1c if date_of_HbA1c_test > 1 year after baseline_HbA1c for each ID_numberDear Stata experts, I am really stuck. In my data set, I have variables for the participant's ID nu…
Subscribe to:
Post Comments (Atom)
0 Response to trouble shooting a mata function
Post a Comment