SimCDA.m

Revision 1 - 5/31/07 at 3:45 pm by e2holmes

Back to revision history for SimCDA.m
This file is part of the project Teaching code for State-space models
figure(4)
clf

mu = input('input mu: ');
s2 = input('input process error (not 0): ');
s2np = input('input non-process error (not 0): ');
len = input('Number of years to project forward: ');

for(i=1:9)
   subplot(3,3,i)
   a=100*cumprod(exp(normrnd(mu,sqrt(s2),len,1)));
   plot(a,'LineWidth',2);
   hold on;
   b = a.*exp(normrnd(0,sqrt(s2np),len,1));
   plot(b,'-r');
   hold off
   box('off')
end
subplot(3,3,2)
title('Nine realizations of your CDA (blue = real; red = observed)');

break

%Gompertz below

%Dennis BBS ests
len=20;
for(i=1:9)
   subplot(3,3,i)
   a=zeros(1,len);
   a(1)=18;
   for(j=2:len)
      a(j)=a(j-1)*exp(+0.12+(0.94-1)*log(a(j-1))+normrnd(0,sqrt(.06)));
   end
   plot(a,'LineWidth',2);
   box('off')
end

Sculpin 0.2 | xhtml | problems or comments? | report bugs