I am using Stata's gmm command using a custom moment-evaulator program. The program is quite complicated, and involves sorting the data multiple times (to use various egen commands). This is causing the gmm command to fail with an 'initial values not feasible' error.
I'm using Stata 18.5, MP—Parallel Edition.
This much simpler working example illustrates the problem:
That code returns an "initial values not feasible r(1400);" error, which makes no sense.
Removing the `if _n == 1` clause or the `sort j` command resolves the issue -- but for my actual program I can't just avoid the equivalent lines.
Any help would be appreciated.
I'm using Stata 18.5, MP—Parallel Edition.
This much simpler working example illustrates the problem:
Code:
set seed 1 clear all set obs 1000 generate mean_zero = rnormal() generate f = floor(runiform()*20) generate j = _n cap program drop moments program moments syntax varlist [if], at(name) local mu = `at'[1,1] tempvar r bys f: generate `r' = mean_zero - `mu' if _n == 1 sort j replace `varlist' = `r' `if' end matrix start = [1] gmm moments, nequations(1) parameters(mean) from(start)
Removing the `if _n == 1` clause or the `sort j` command resolves the issue -- but for my actual program I can't just avoid the equivalent lines.
Any help would be appreciated.
Comment