I'm attempting to find the root of a non-linear equation using mata. Running Stata 15.1 on MacOS Mojave 10.14.6. Here is my code:
mata
maxu = 2.63506
u3 = 836.8054
u4 = 117.3982
u2 = 4.283902
w = 60.069
function myfunc(x, maxu, u3, u4, u2, w) return(maxu - ln(u3+u4+u2*exp(.0175134(w-x))))
rc = mm_root(x=., &myfunc(), 0, 1, 0 , 1000, maxu, u3, u4, u2, w)
x
end
This is the error message I'm getting:
: function myfunc(x, maxu, u3, u4, u2, w) return(maxu - ln(u3+u4+u2*exp(.0175134(w-x))))
invalid expression
r(3000);
Any suggestions? Thanks.
Related Posts with Problem with function definition for mm_root
combining variablesHi all, I have a relatively rudimentary question. I have a dataset with the same variable listed in…
How to create a plot showing the results of an OLS regressionDear all, I ran a panel regression taking the form of y = x1 +x12 + other control variable using …
Calculating 5-year compound annual growth rate (CAGR) with missing valuesHi All, I'm trying to calculate the 5-year compound annual growth rate, which is "(endvalue/beginni…
Lasso error message "error in postselection b"Hi everyone, I encountered this error when I was running the Lasso, "error in postselection b". Co…
Generating a variable for user pre and post policy changeHI, So I have panel data for 5 years (4,5,6,7,8) and I am evaluating a policy change that happened …
Subscribe to:
Post Comments (Atom)
0 Response to Problem with function definition for mm_root
Post a Comment