Is there a way to do it in a loop, something like this:

Code:

forvalues i = 1/"nuber of observations"- 52 { newey PBQ1 var24 SizeTLS momLS in i/i+51, lag(2) }

]]>

I am writing an estimation command and would like to modify the error message that is issued by optimize() when the numerical derivative could not be calculated. In specific, I would like to add a recommendation for the user how to solve the error.

I've tried to solve my problem by using _optimize(), which is supposed return nonzero values in case of error and not to abort. If there is an error, I could print the error text and a recommendation for the user. However, _optimize() aborts when it "could not calculate numerical derivatives -- discontinuous region with missing values encountered".

A minimal working example is:

Code:

mata: mata clear void myFunction(real scalar todo, real scalar p, score, g, H) { score = 2 } S = optimize_init() optimize_init_params(S, 0) optimize_init_evaluator(S, &myFunction()) _optimize(S) if (ec = optimize_result_errorcode(S)) { errprintf("{p}\n") errprintf("%s\n", optimize_result_errortext(S)) errprintf("\n Print some recommendation") errprintf("{p_end}\n") exit(optimize_result_returncode(S)) /*NOTREACHED*/ } result = optimize_result_params(S) printf("Result is: %5.2f", result) end

I'm using Stata 14 with Windows 7.

Thank you very much for your help!

Christoph

]]>

Thanks

Masoud ]]>

My stata board appears as below:

network meta i

Warning: network is disconnected, so network meta models will be wrong

(Use force option to override - at your own risk)

r(498);

. network meta i, force

Warning: network is disconnected, so network meta models will be wrong

Warning: inconsistency model requested, but there is no source of inconsistency

variable des_AE already defined

Your kind suggestions to fix this command would be highly appreciated.

Yours sincerely,

Ajaree

]]>

I am a recent user of stata, trying to do some catchy analysis.

I have done FTD33 pathogen testing in virology lab on 219 patients for which I was aiming to create a matrix for monodetection and codetection of pathogens but not sure how to do this. Could you please help me out. Appreciate it.

Kind regards,

Rezanur]]>

I'm using a loop to get rid of autocorrelated residuals, but I run in a syntax error with the following code:

PHP Code:

```
regress variable1_variable2
```

drop resid

predict double resid, res

local xtwelfthpv = 0

local xlags = 0

while `xtwelfthpv' < 0.05 {

quietly regress D.resid L.resid L(0/`xlags')D.resid, nocons

quietly actest, lags(12) robust

mata {

b = st_matrix("r(results)")

m = b[.,4]

st_numscalar("twelfthpv", m[12])

m[12]

}

local xtwelfthpv = `twelfpv'

local xlags = `xlags' + 1

}

di `xtwelfthpv'

di `xlags'

PHP Code:

```
st_numscalar("twelfthpv", m[12])
```

Can anybody tell me, where my syntax error lies? Thanks a lot!

]]>

In mata (Stata 14.2), when I index a string scalar, I get the following:

. mata: s = "hello"; s[1]

hello

. mata: s = "hello"; s[2]

<istmt>: 3301 subscript invalid

r(3301);

hello

. mata: s = "hello"; s[2]

<istmt>: 3301 subscript invalid

r(3301);

if 2 is invalid subscript as per the error message above, what is the range of valid subscripts in this case?

How do I get the byte at a specific index (other than using substr)?

Thanks,

/salah]]>

I'm trying to simulate on stata a progressive taxation on household income based on the italian taxation.

The main available variable in my microdata dataset is the gross family income for every observation of the 19000 sample .

From the income I need to apply the follow tax scheme:

€0 — €15,000 | 23% |

€15,000 — €28,000 | 27% |

€28,000 — €55,000 | 38% |

€55,000 — €75,000 | 41% |

over €75,000 | 43% |

Kind regards,

Fabio.

]]>