C r e a t e a PSF model f o r p r e diction
>>> a = P s f ( da ta= t r ai n , c y cl e =12 )
```
The model can be printed using the model\_print() method as shown in Listing 4.

```
Listing 4. Command to print the model.
```

```
>>> a . model_prin t ( )
Original time−s eries :
0 40.6
1 40.8
2 44.4
3 46.7
4 54.1
5 58.5
6 57.7
7 56.4
8 54.3
9 50.5
10 42.9
\dots
219 46.6
220 52.4
221 59.0
222 59.6
223 60.4
224 57.0
225 50.7
226 47.8
227 39.2
Length : 228 , dtype : floa t64
k= 2
w = 12
cycle = 12
dmin = 3 1. 3
dmax = 66.5
type = <class 'PSF_Py . psf . Psf '>
```
Then, Listing 5 shows how the actual prediction was performed using this PSF model.


where b contains the predicted values.

The model and predictions can be plotted using the psf\_plot() function (shown in Listing 6) as shown in Figure 3.

>>> p s f \_ pl o t ( a , b )

A similar procedure was carried out to perform the prediction in R using the PSF library. Several error metrics was calculated for the predicted values and testing set. The performance of Python and R are compared in Table 2 and Figure 4.

**Figure 3.** Result of psf\_plot() for the "nottem" dataset.

**Table 2.** Comparison of forecast methods with different error metrics for the "nottem" dataset.


#### *4.2. Example 2: CO2 Dataset*

This example demonstrates the use of the DPSF algorithm. The dataset consisted of atmospheric concentrations of CO2 expressed in parts per million (ppm) and reported in the preliminary 1997 SIO manometric mole fraction scale [46]. The values for February, March, and April of 1964 were missing and were obtained by interpolating linearly between the values for January and May of 1964. Table 3 contains the statistical characteristics of the time series.

**Table 3.** Statistical characteristics of the "CO2" dataset.


The time series data were divided into training and testing datasets. The training set contained the time series data, excluding the last 12 values. The testing dataset contained the last 12 values. A Dpsf model was created using the training dataset, and the future 12 values were forecasted as shown in Figure 5. The corresponding commands are shown in Listing 7. These predictions were then compared with the testing dataset. The comparisons are provided in Table 4 and Figure 6.

**Figure 5.** Result of dpsf\_plot() for the "CO2" dataset.

```
Listing 7. Commands to create and use Dpsf model.
```

```