Hello everyone,
I have been trying to run a machine learning model using the code r_ml_stata on stata 18. Please see the following codes
clear all
cd "F:\SUST_Project\Mosk 2023\Data\Output"
global learner "nearestneighbor"
sysuse "MLDATA.dta", clear
global y " DEPRES"
global x " SSS L_STRESS W_STRESS AGE"
splitsample , generate (vsplit, replace) split (0.80 0.20)show rseed (1010)
ssc install r_ml_stata
search r_ml_stata
preserve
keep if vsplit==1
drop vsplit
save data_train, replace
restore
preserve
keep if vsplit==2
drop $y
drop vsplit
save data_test, replace
restore
preserve
keep if vsplit==2
keep $y
gen index=_n-1
save test_y, replace
restore
use data_train, clear
r_ml_stata $y $x , mlmodel ($learner) inprediction ("in_pred") ///
cross_validatin ("CV") out_sample ("data_test") ///
outprediction ("out_pred") seed(10) save_graph_cv ("graph_cv")
all the codes work really fine. However, the last command with r_ml_stata doesn't run on STATA19 software as it shows the unrecognized r_ml_stata code working. I am not sure what mistakes I have made. Your valuable suggestions would help me a lot. Thank you a lot.
I have been trying to run a machine learning model using the code r_ml_stata on stata 18. Please see the following codes
clear all
cd "F:\SUST_Project\Mosk 2023\Data\Output"
global learner "nearestneighbor"
sysuse "MLDATA.dta", clear
global y " DEPRES"
global x " SSS L_STRESS W_STRESS AGE"
splitsample , generate (vsplit, replace) split (0.80 0.20)show rseed (1010)
ssc install r_ml_stata
search r_ml_stata
preserve
keep if vsplit==1
drop vsplit
save data_train, replace
restore
preserve
keep if vsplit==2
drop $y
drop vsplit
save data_test, replace
restore
preserve
keep if vsplit==2
keep $y
gen index=_n-1
save test_y, replace
restore
use data_train, clear
r_ml_stata $y $x , mlmodel ($learner) inprediction ("in_pred") ///
cross_validatin ("CV") out_sample ("data_test") ///
outprediction ("out_pred") seed(10) save_graph_cv ("graph_cv")
all the codes work really fine. However, the last command with r_ml_stata doesn't run on STATA19 software as it shows the unrecognized r_ml_stata code working. I am not sure what mistakes I have made. Your valuable suggestions would help me a lot. Thank you a lot.
Comment