Hello everyone,
I am new to using Mata within Stata and have the following problem. I am trying to run multiple spline regressions using a loop and (probably) need both stata and mata commands for that. However, I have a problem using a scalar sca_a1 in the
My complete loop over matrix X looks as follows:
t is the time variable in years in the original stata dataset.
Google told me that the problem is probably that the stata() command still uses the scalars within Mata. So maybe there is a way to directly use i in the stata() command?
Any help how I could implement this? I somewhere saw a post by Nick Cox saying that it is probably best not to pass locals and scalars between mata and stata, but how do I code it then? My ultimate goal is to save the F-statistics of the regressions and choose the date with the maximum F-stat as the break year.
Thank you very much!
P.S.: I crosslisted on https://stackoverflow.com/questions/...calar-in-stata
I am new to using Mata within Stata and have the following problem. I am trying to run multiple spline regressions using a loop and (probably) need both stata and mata commands for that. However, I have a problem using a scalar sca_a1 in the
Code:
stata("mkspline t1 `=scalar(`sca_a1')' t2=t")
Code:
for (i=1; i<=50; i++) { if (X[i,3]==1 & X[i+1,3]==1) { st_numscalar("sca_a1", i) stata("mkspline t1 `=scalar(`sca_a1')' t2=t") ... stata("drop t1 t2") } } end
Google told me that the problem is probably that the stata() command still uses the scalars within Mata. So maybe there is a way to directly use i in the stata() command?
Any help how I could implement this? I somewhere saw a post by Nick Cox saying that it is probably best not to pass locals and scalars between mata and stata, but how do I code it then? My ultimate goal is to save the F-statistics of the regressions and choose the date with the maximum F-stat as the break year.
Thank you very much!
P.S.: I crosslisted on https://stackoverflow.com/questions/...calar-in-stata
Comment