Dear colleagues:
I run the following program. However, following error appeared.
. mata: wx("distance_smat", "y_m", "hage_0", 2);
wx(): 3301 subscript invalid
<istmt>: - function returned error
I assume that there is a problem when I pass the real scalar "2" to the argument of void function wx.
It would be great if somebody suggested the way to correct the error.
Thanks in advance.
Kazuto
I run the following program. However, following error appeared.
. mata: wx("distance_smat", "y_m", "hage_0", 2);
wx(): 3301 subscript invalid
<istmt>: - function returned error
I assume that there is a problem when I pass the real scalar "2" to the argument of void function wx.
It would be great if somebody suggested the way to correct the error.
Thanks in advance.
Kazuto
Code:
#delimit;
/*** mata session ***/
mata;
void wx(string scalar A, string scalar B, string scalar C, real scalar d_km){;
/* Obtain and put Stata matrices */
distance_mat = st_matrix(A);
x_mat = st_matrix(B);
if_mat = st_matrix(C);
nob = rows(distance_mat);
dstm1 = J(nob, nob, 0);
dstm2 = J(nob, nob, 0);
dstm1_invdist= J(nob, nob, 0);
for (i=1; i<=nob; i++) {;
k= i+1;
for (j=k; j<=nob; j++) {;
if (distance_mat[i,j]<d_km) {;
dstm1[i,j] = 1;
dstm1_invdist = 1/distance_mat[i,j];
};
};
};
/* save */
st_matrix("w1_x", w1_x);
st_matrix("w_invdist_x", w_invdist_x);
st_matrix("nb_ratio", nb_ratio);
};
end;
/**** stata part ***/
matrix distance_smat = distance_mat+distance_mat';
mkmat lease_rate_kanri, matrix(y_m);
mkmat hage_0 , matrix(hage_0_v);
mata: wx("distance_smat", "y_m", "hage_0", 2);

Comment