I got a recursive equation to solve, the equation is equation A13 shown in the picture. It is actually much easier than it seems, cause the v and h are constants.
And we can take the p(h/1+nh)/p(h/1+(n+1)h) as a whole, noted as a(n). Then we can simplify the equation as follows (I'm going to show the matlab code),
h = 0.374 ;
v = 4 ;
c1 = @(n) ( (1+(n+2)*h)./(1+(n+3)*h) ).^(2/(v-2 ));
c2 = @(n) v/2*( (1+(n+2)*h)./(1+n*h) ).^(v-2 );
a(1) = (1+h)/(1+2*h) ;
for n = 1:100
a(n+1) = c1(n) *(c2(n)*a(n)^2 - a(n)^v)^(1/(v-2 ));
end
A=prod(a)
The A is the final value I need to get here. It is the product of all the 101 values of a(n).
But since my data is panel data, matlab cannot deal with panel data so well. I need to translate the code into stata. Could you help me please? Thank you!
Array
Related Posts with recursive equation solution
changing from days to months on x axis- kaplan meier survival analysisHello, I have searched but not found the answer to this. I am doing survival analysis on Kaplan Meie…
Looping too many variablesI did the following for too many variables: Variable 1: Code: bysort year Industry: egen Industry_…
Mixed model with marginsHey all I have an mixed model equation that i want to graph with margins. There are two groups, two…
Testing for validity in IV PoissonDear Statalisters, Is there a way one can test for the validity of instruments to be included in IV…
Sign of coefficients change after first-differencingGood evening, I'm working with a dynamic panel data model. I first ran a fixed-effects regression (…
Subscribe to:
Post Comments (Atom)
0 Response to recursive equation solution
Post a Comment