*
* GCONTOUR.RPF
* RATS Version 8, Introduction, Example from Section 4.13.
*
* Create a series which is mean 0 through entry 50, and mean 10 from 51
* through the end of the sample. We use a SEED to ensure that the graph
* can be reproduced
*
seed 95035
all 100
set x = %if(t>50,10,0)+%ran(1.0)
*
* The sum of squared residuals for a break between B and B+1 and a
* post-break mean of mu (pre-break mean assumed to be zero) is
*
* sum (all t) of x^2 - 2*mu*sum (t>B) of x + (T-B)*mu^2
*
* This generates a contour plot of the concentrated log likelihood,
* assuming Normal residuals, and fixed, but unknown, variance.
*
* Set up the grids for breaks (1,...,100) and mus (.2,.4,...,20)
*
compute breaks=%seqa(1.0,1.0,100)
compute mus =%seqa( .2, .2,100)
*
* This generates as "over" the sum of x for elements above t.
*
acc x / ax
set over = ax(100)-ax(t)
*
* Compute the sum of squares
*
compute x2=%normsqr(x)
*
* Generate the log likelihood for all the combinations of mus and breaks.
*
dec rect f(100,100)
ewise f(i,j)=-50.0*log((x2-2*mus(i)*over(fix(breaks(j)))+(100-breaks(j))*mus(i)^2)/100.0)
*
* Do the contour graph with a grid line across the actual break (50)
*
gcontour(x=mus,y=breaks,f=f,vgrid=||1||)


雷达卡
京公网安备 11010802022788号







