This example shows how to specify a continuous-time trend model discussed in Harvey (1989, chap. 9, sec. 9.2.1). This model is not one of the predefined trend models in the SSM procedure. The system matrices that govern the two-dimensional state of this model are
where denotes the difference between the successive time points, and the parameters and are called the level variance and the slope variance, respectively. The initial condition is fully diffuse. The trend component corresponds to the first element of this state vector. The second element of the state vector corresponds to the slope of this trend component. This model reduces to the polynomial spline model of order 2 if the level variance . See the section Polynomial Spline Trend.
The following statements specify a trend-plus-noise model to model the growth of cows in the previous example (Example 27.3). The only cows that are considered are the ones that received iron and are infected.
proc ssm data=cows; where iron=1 and infection=1; id tpoint; parms var1 var2 / lower=(1.e-8 1.e-8); array tMat{2,2}; tMat[1,1] = 1; tMat[2,2] = 1; tMat[1,2] = _ID_DELTA_; array covMat{2,2}; covMat[1,1] = var1*_ID_DELTA_ + var2*_ID_DELTA_**3/3; covMat[1,2] = var2*_ID_DELTA_**2/2; covMat[2,1] = covMat[1,2] ; covMat[2,2] = var2*_ID_DELTA_; state harveyLL(2) T(g)=(tMat) cov(g)=(covMat) a1(2); component trend = harveyLL[1]; component slope = harveyLL[2]; irregular wn; model weight = trend wn; forecast out=for; run;
The program is easy to follow. The PARMS statement declares var1 and var2 as positive parameters, which correspond to and , respectively. The programming statements define arrays tMat and covMat, which later become the matrices and , respectively. Note that the element tMat[2,1] is left unassigned, since it is a structural zero of (see the section Sparse Transition Matrix Specification for more information). Recall that the predefined variable _ID_DELTA_ contains the value of , which is needed for defining the elements of and (see the section ID Statement). The STATE statement defines the trend state vector, harveyLL, and the COMPONENT statement defines the trend component, trend, by selecting the first element of harveyLL. An additional COMPONENT statement defines the slope component, slope, as the second element of harveyLL. The slope component (which represents the cow’s growth rate) is not part of the observation equation; it is specified so that its estimate is output to for (the OUT= data set specified in the FORECAST statement). The observation noise is defined by the IRREGULAR statement, and the MODEL statement defines the trend-plus-noise model.
The estimates of var1 and var2 are shown in Output 27.4.1. It shows that the estimate of the level variance is nearly zero, implying that the fitted trend model is identical to the polynomial spline trend of order 2.
Maximum Likelihood Estimates of the Parameters Specified in the PARMS Statement |
||
---|---|---|
Parameter | Estimate | Approx Std Error |
var1 | 1E-8 | 0.0008486 |
var2 | 0.00001236 | . |
Maximum Likelihood Estimates of the Unknown System Parameters (Parameters Not Specified in the PARMS Statement) | ||||
---|---|---|---|---|
Component | Type | Parameter | Estimate | Approx Std Error |
wn | Irregular | Variance | 0.00954 | 0.0009094 |
proc sgplot data=for; title "Model Fit: Two-Parameter Polynomial Spline of Order 2"; series x=tpoint y=smoothed_trend; scatter x=tpoint y=weight; run;
proc sgplot data=for; title "Smoothed Estimate of Growth-Rate"; series x=tpoint y=smoothed_slope; run;
Note: This procedure is experimental.