I am attempting to run agreement analyses on pairs of variables and then stacking the results in a results matrix. I have created several user-defined programs to run primary analysis, then use the bootstrap to compute confidence intervals on these clusters data, then output to the matrix I called results. The problem is that when the user-defined program is run the second time the results matrix seems to be deleted from memory even though the user defined program doesn't do anything with that matrix. The user-defined programs are as follows:
This program computes and outputs Gwet's A1C agreement statistic which it returns:
This program computes sensitivity and specificity and then uses the clustered boostrap to compute the confidence intervals. It returns the sensitivity, specificity, A1C statistic, and the associated CI:
The following code runs the analysis on the first set of variables, creates the matrix results from what is returned from the function all_stats, then re-runs the analysis on the second pair of variables, stores the results in the matrix temp, then attempts to concatenate temp with results.
However, when the last line of code runs, I get the following error message:
I have confirmed that the results matrix exists after the first run of all_stats.
Any help would be greatly appreciated. I am running Stata/SE 14.2 on Windows 10 computer.
Best,
Colin
This program computes and outputs Gwet's A1C agreement statistic which it returns:
Code:
program define pabak, eclass args v1 v2 confirm variable `v1' confirm variable `v2' tempname z quietly kappaetc `v1' `v2', list matrix `z' = r(b) ereturn scalar v = `z'[1,5] end
Code:
program define all_stats, rclass args part res confirm variable `part' confirm variable `res' tempname sens spec outboot out_1 quietly diagt `res' `part' matrix `sens' = r(sens) matrix `spec' = r(spec) quietly bootstrap pbak = e(v), reps(1000) cluster(id): pabak `part' `res' matrix `outboot' = e(b), e(ci_bc)' matrix `out_1' = `sens', `spec',`outboot' return matrix v = `out_1' end
Code:
*Corn all_stats FV01_ HFAV_FV01_ matrix results = r(v) matrix rownames results = Corn *Peas all_stats FV02_ HFAV_FV02_ matrix temp = r(v) matrix rownames temp = Peas matrix results = results \ temp
Code:
results not found r(111);
Any help would be greatly appreciated. I am running Stata/SE 14.2 on Windows 10 computer.
Best,
Colin
Comment