Skip to contents

SCEM uses the residual sum of squares for each group to give a sense of the error in estimation. It is defined by:

\[RSS(S_q) = \sum_{k \in S_q} \sum_{i = 1}^{n_k} ||y_{k,i} - \hat{\mu}_{S_q} \left(\frac{i}{n_k}\right) - \hat{c}_{k}||^2\]

(See Chazin et al. 2019, Supplemental Materials 1).

The trend function for each individual time series is estimated non-parametrically by the local linear estimate (as discussed in Fan and Gijbels (1996)). Then, the common trend function for the group is estimated by taking the average over the group. Next, the shift functions are estimated as the differences from the individual trend functions and finally, the residual sum of squares are calculated using the original values, the common trend functions and the shifts.

Usage

calculateRSS(paths, S, bandwidth)

Arguments

paths

A list of data frames, where each frame contains the data for one individual. Every data frame should have two columns with names 'distance' and 'oxygen'.

S

A vector of integers showing which individuals are considered in the group.

bandwidth

Denotes the order of the bandwidth that should be used in the estimation process. bandwidth = k will mean that the bandwidth is n^k.

Value

A vector of length equal to the group-size, so that each element is the RSS for the corresponding individual in the group.

Examples

armenia_split = split(armenia,f = armenia$ID)
band = -0.33
p = length(armenia_split)
calculateRSS(armenia_split,1:p,band)
#>  [1]  87.009179 147.666300  37.260325  99.540946   2.031422 100.162004
#>  [7]  42.652780  39.822151  41.234838  53.428182  27.614369  74.332299
#> [13]  75.476085  37.818161 100.357094  41.575878  39.279025  47.961391
#> [19]  50.839123  58.065549  17.968856  91.033941  57.148805  85.469361