Skip to main content
Log in

Estimating variances in time series kriging using convex optimization and empirical BLUPs

  • Regular Article
  • Published:
Statistical Papers Aims and scope Submit manuscript

Abstract

We revisit and update estimating variances, fundamental quantities in a time series forecasting approach called kriging, in time series models known as FDSLRMs, whose observations can be described by a linear mixed model (LMM). As a result of applying the convex optimization, we resolved two open problems in FDSLRM research: (1) theoretical existence and equivalence between two standard estimation methods—least squares estimators, non-negative (M)DOOLSE, and maximum likelihood estimators, (RE)MLE, (2) and a practical lack of free available computational implementation for FDSLRM. As for computing (RE)MLE in the case of n observed time series values, we also discovered a new algorithm of order \({\mathcal {O}}(n)\), which at the default precision is \(10^7\) times more accurate and \(n^2\) times faster than the best current Python(or R)-based computational packages, namely CVXPY, CVXR, nlme, sommer and mixed. The LMM framework led us to the proposal of a two-stage estimation method of variance components based on the empirical (plug-in) best linear unbiased predictions of unobservable random components in FDSLRM. The method, providing non-negative invariant estimators with a simple explicit analytic form and performance comparable with (RE)MLE in the Gaussian case, can be used for any absolutely continuous probability distribution of time series data. We illustrate our results via applications and simulations on three real data sets (electricity consumption, tourism and cyber security), which are easily available, reproducible, sharable and modifiable in the form of interactive Jupyter notebooks.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

Notes

  1. As it is common practice, we use subindices as an indication of size for identity matrix \(\mathbf{I }_{n}\), zero matrix \({\varvec{0}}_{l \times n}\) or zero vector \({\varvec{0}}_{l}\). Dimension of other matrices will be indicated directly in the text or by a matrix space in which they belong.

  2. To easily follow if any matrix (or vector) contains variance parameters, elements of vector \(\varvec{\upnu }\), we usually use vector \(\varvec{\upnu }\) as its subscript.

  3. More than ten years ago it was simply assumed that a potential user of FDSLRM will use one of the well-known commercial environments for scientific computing—MATLAB or Mathematica where he will directly apply formulas from the corresponding theory. But now analyses (see e.g. Frederickson (2019, Sect. Scientific Languages)) show that the situation is dramatically changing, favoring open, free technology like Jupyter notebooks or R.

  4. The matrix calculus using the Kronecker product, vec and vech operators or commutation and duplication matrices.

  5. As it is usual, for symmetric matrices \(\succ 0\) will mean positive definiteness.

  6. It is worth to mention that the speed of our Python procedures is not final. Our Jupyter notebooks have been written in standard Python in SciPy. We assume that the rewriting of the code, using special Python tools (Cython or Numba), speeds up our procedures (10–100 times faster) to run-times comparable with C or C++ codes.

References

  • Agrawal A, Verschueren R, Diamond S, Boyd S (2018) A rewriting system for convex optimization problems. J Control Decis 5(1):42–60

    MathSciNet  Google Scholar 

  • Amemiya T (1977) A note on a heteroscedastic model. J Econom 6(3):365–370

    MathSciNet  MATH  Google Scholar 

  • Anderson T (1970) Estimation of covariance matrices which are linear combinations or whose inverses are linear combinations of given matrices. In: Bose RC, Roy SN (eds) Essays in probability and statistics. University of North Carolina Press, Chapel Hill, pp 1–24

    Google Scholar 

  • Bates D, Mächler M, Bolker B, Walker S (2015) Fitting linear mixed-effects models using lme4. J Stat Softw 67(1):1–48

    Google Scholar 

  • Beezer RA, Bradshaw R, Grout J, Stein WA (2013) Sage. In: Hogben L (ed) Handbook of linear algebra, 2nd edn. Chapman and Hall/CRC, Boca Raton, pp 91–1–91–26

  • Bertsekas DP (2009) Convex optimization theory, 1st edn. Athena Scientific, Belmont

    MATH  Google Scholar 

  • Box GEP, Jenkins GM, Reinsel GC, Ljung GM (2015) Time series analysis: forecasting and control, 5th edn. Wiley, Hoboken

    MATH  Google Scholar 

  • Boyd S, Vandenberghe L (2009) Convex optimization, 7th edn. Cambridge University Press, Cambridge

    MATH  Google Scholar 

  • Boyd S, Vandenberghe L (2018) Introduction to applied linear algebra: vectors, matrices, and least squares. Cambridge University Press, Cambridge

    MATH  Google Scholar 

  • Brieulle L, De Feo L, Doliskani J, Flori JP, Schost É (2019) Computing isomorphisms and embeddings of finite fields. Math Comp 88(317):1391–1426

    MathSciNet  MATH  Google Scholar 

  • Brockwell PJ, Davis RA (1991) Time series: theory and methods. Springer, New York

    MATH  Google Scholar 

  • Brockwell PJ, Davis RA (2009) Time series: theory and methods. Springer, New York

    MATH  Google Scholar 

  • Brockwell PJ, Davis RA (2016) Introduction to time series and forecasting, 3rd edn. Springer, New York

    MATH  Google Scholar 

  • Christensen R (2011) Plane answers to complex questions: the theory of linear models, 4th edn. Springer, New York

    MATH  Google Scholar 

  • Cornuéjols G, Peña J, Tütüncü R (2018) Optimization methods in finance. Cambridge University Press, Cambridge

    MATH  Google Scholar 

  • Covarrubias-Pazaran G (2016) Genome-assisted prediction of quantitative traits using the R package sommer. PLoS ONE 11(6):e0156

    Google Scholar 

  • Demidenko E (2013) Mixed models: theory and applications with R, 2nd edn. Wiley, Hoboken

    MATH  Google Scholar 

  • Diamond S, Boyd S (2016) CVXPY: a python-embedded modeling language for convex optimization. J Mach Learn Res 17(83):1–5

    MathSciNet  MATH  Google Scholar 

  • Frederickson B (2019) Ranking Programming Languages by GitHub Users. https://www.benfrederickson.com/ranking-programming-languages-by-github-users/. Accessed 19 Feb 2020

  • Fu A, Narasimhan B, Diamond S, Miller J, Boyd S, Rosenfield PK (2019) CVXR: disciplined Convex Optimization. https://CRAN.R-project.org/package=CVXR. Accessed 19 Feb 2020

  • Gajdoš A (2019) MMEinR: R-version of Witkovský’s MATLAB mixed function. https://github.com/fdslrm/MMEinR

  • Gajdoš A, Hančová M, Hanč J (2017) Kriging methodology and its development in forecasting econometric time series. Statistika 97(1):59–73

    Google Scholar 

  • Gajdoš A, Hanč J, Hančová M (2019a) fdslrm. https://github.com/fdslrm. Accessed 19 Feb 2020

  • Gajdoš A, Hanč J, Hančová M (2019b) fdslrm: applications. https://github.com/fdslrm/applications. Accessed 19 Feb 2020

  • Gajdoš A, Hanč J, Hančová M (2019c) fdslrm: EBLUP-NE. https://github.com/fdslrm/EBLUP-NE. Accessed 19 Feb 2020

  • Gajdoš A, Hanč J, Hančová M (2019d) fdslrm: R package. https://github.com/fdslrm/R-package. Accessed 19 Feb 2020

  • Galántai A (2004) Projectors and projection methods. Springer, New York

    MATH  Google Scholar 

  • Galecki A, Burzykowski T (2013) Linear mixed-effects models using R: a step-by-step approach. Springer, New York

    MATH  Google Scholar 

  • Ghosh M (1996) On the nonexistence of nonnegative unbiased estimators of variance components. Indian J Stat Ser B (1960–2002) 58(3):360–362

    MathSciNet  MATH  Google Scholar 

  • Grant M, Boyd S (2018) CVX: matlab software for disciplined convex programming. http://cvxr.com/cvx/. Accessed 19 Feb 2020

  • Grant M, Boyd S, Ye Y (2006) Disciplined convex programming. In: Liberti L, Maculan N (eds) Global optimization: from theory to implementation. Springer, New York

    Google Scholar 

  • Hančová M (2007) Comparison of prediction quality of the best linear unbiased predictors in time series linear regression models. In: Proceedings of 15th European Young Statisticians Meeting, University of Extremadura, Castro Urdiales (Spain). https://github.com/fdslrm/EBLUP-NE. Accessed 19 Feb 2020

  • Hančová M (2008) Natural estimation of variances in a general finite discrete spectrum linear regression model. Metrika 67(3):265–276

    MathSciNet  MATH  Google Scholar 

  • Harville DA (1974) Bayesian inference for variance components using only error contrasts. Biometrika 61(2):383–385

    MathSciNet  MATH  Google Scholar 

  • Harville DA (1977) Maximum likelihood approaches to variancecomponent estimation and to related problems. J Am Stat Assoc 72(358):320–338

    MATH  Google Scholar 

  • Henderson CR, Kempthorne O, Searle SR, von Krosigk CM (1959) The Estimation of environmental and genetic trends from records subject to culling. Biometrics 15(2):192–218

    MATH  Google Scholar 

  • Hyndman RJ, Athanasopoulos G (2018) Forecasting: principles and practice, 2nd edn. Monash University, OTexts

    Google Scholar 

  • Jiang J (2007) Linear and generalized linear mixed models and their applications. Springer, New York

    MATH  Google Scholar 

  • Jones E, Oliphant T, Peterson P et al (2001) SciPy: Open source scientific tools for Python. http://www.scipy.org/. Accessed 19 Feb 2020

  • Kedem B, Fokianos K (2005) Regression models for time series analysis. Wiley, New York

    MATH  Google Scholar 

  • Kluyver T, Ragan-Kelley B, Perez F, Granger B, Bussonnier M, Frederic J, Kelley K, Hamrick J, Grout J, Corlay S, Ivanov P, Avila D, Abdalla S, Willing C (2016) Jupyter Notebooks-a publishing format for reproducible computational workflows. In: Loizides F, Schmidt B (eds) Positioning and power in academic publishing: players, agents and agendas. Proceedings of the 20th ELPUB. Ios Press, Amsterdam, pp 87–90

  • Koenker R, Mizera I (2014) Convex optimization in R. J Stat Softw 60(5):1–23

    MATH  Google Scholar 

  • Kreiss JP, Lahiri SN (2012) Bootstrap methods for time series. In: Rao TS, Rao SS, Rao CR (eds) Handbook of statistics, time series analysis: methods and applications, vol 30. Elsevier, Amsterdam, pp 3–26

    Google Scholar 

  • LaMotte LR (2007) A direct derivation of the REML likelihood function. Stat Pap 48(2):321–327

    MathSciNet  MATH  Google Scholar 

  • Lima A, Rossi L, Musolesi M (2014) Coding together at scale: GitHub as a collaborative social network. In: Adar E, Resnick P, Choudhury MD, Hogan B, Oh AH (eds) Proceedings of the 8th ICWSM, Ann Arbor, June 1-4, 2014. The AAAI Press, Palo Alto

  • McLeod AI, Yu H, Mahdi E (2012) Time series with R. In: Rao TS, Rao SS, Rao CR (eds) Time series analysis: methods and applications, vol 30. Elsevier, Amsterdam, pp 661–712

    Google Scholar 

  • Oliphant TE (2007) Python for scientific computing. Comput Sci Eng 9(3):10–20

    Google Scholar 

  • Percival DB, Walden AT (2009) Spectral analysis for physical applications: multitaper and conventional univariate techniques. Cambridge University Press, Cambridge

    MATH  Google Scholar 

  • Pinheiro J, Bates D (2009) Mixed-effects models in S and S-PLUS. Springer, New York

    MATH  Google Scholar 

  • Pinheiro JC, Bates D, DebRoy S, Sarkar D, EISPACK authors, Heiserkamp S, Van Willingen B, R-core (2018) nlme: linear and nonlinear mixed effects models. https://CRAN.R-project.org/package=nlme. Accessed 19 Feb 2020

  • Pourahmadi M (2001) Foundations of time series analysis and prediction theory. Wiley, New York

    MATH  Google Scholar 

  • Priestley M (2004) Spectral analysis and time series. Elsevier Academic Press, Amsterdam

    Google Scholar 

  • Project Jupyter, Bussonnier M, Forde J, Freeman J, Granger B, Head T, Holdgraf C, Kelley K, Nalvarte G, Osheroff A, Pacer M, Panda Y, Perez F, Ragan-Kelley B, Willing C (2018) Binder 2.0—reproducible, interactive, sharable environments for science at scale. Proceedings of the 17th Python in Science Conference, pp 113–120

  • Puntanen S, Styan GPH, Isotalo J (2013) Formulas useful for linear regression analysis and related matrix theory. SpringerBriefs in statistics. Springer, Berlin

    MATH  Google Scholar 

  • R Development Core Team (2019) R: a language and environment for statistical computing. http://www.r-project.org/. Accessed 19 Feb 2020

  • Rao CR, Kleffe J (1988) Estimation of variance components and applications. North-Holland, Amsterdam

    MATH  Google Scholar 

  • Rao JNK, Molina I (2015) Small area estimation, 2nd edn. Wiley, Hoboken

    MATH  Google Scholar 

  • SAS Institute Inc (2018) SAS/STAT 15.1 user’s guide: the MIXED procedure. SAS Institute Inc., Cary

    Google Scholar 

  • Searle SR, Khuri AI (2017) Matrix algebra useful for statistics, 2nd edn. Wiley, Hoboken

    MATH  Google Scholar 

  • Searle SR, Casella G, McCulloch CE (2009) Variance components. Wiley, Hoboken

    MATH  Google Scholar 

  • Shumway RH, Stoffer DS (2017) Time series analysis and its applications: with R examples, 4th edn. Springer, New York

    MATH  Google Scholar 

  • Singer JM, Rocha FMM, Nobre JS (2017) Graphical Tools for detecting departures from linear mixed model assumptions and some remedial measures. Int Stat Rev 85(2):290–324

    MathSciNet  Google Scholar 

  • Sokol P, Gajdoš A (2018) Prediction of attacks against honeynet based on time series modeling. In: Silhavy R, Silhavy P, Prokopova Z (eds) Applied computational intelligence and mathematical methods. Advances in intelligent systems and computing. Springer, New York, pp 360–371

    Google Scholar 

  • Stein WA et al (2019) Sage Mathematics Software—SageMath. http://www.sagemath.org. Accessed 19 Feb 2020

  • Stroup WW, Milliken GA, Claassen EA, Wolfinger RD (2018) SAS for mixed models: introduction and basic applications. SAS Institute, Cary

    Google Scholar 

  • Štulajter F (1991) Consistency of linear and quadratic least squares estimators in regression models with covariance stationary errors. Appl Math-Czech 36(2):149–155

    MathSciNet  MATH  Google Scholar 

  • Štulajter F (2002) Predictions in time series using regression models. Springer, New York

    MATH  Google Scholar 

  • Štulajter F (2003) The MSE of the BLUP in a finite discrete spectrum LRM. Tatra Mt Math Publ 26(1):125–131

    MathSciNet  MATH  Google Scholar 

  • Štulajter F, Witkovský V (2004) Estimation of variances in orthogonal finite discrete spectrum linear regression models. Metrika 60(2):105–118

    MathSciNet  MATH  Google Scholar 

  • Weiss CJ (2017) Scientific computing for chemists: an undergraduate course in simulations, data processing, and visualization. J Chem Educ 94(5):592–597

    Google Scholar 

  • Witkovský V (2012) Estimation, Testing, and prediction regions of the fixed and random effects by solving the Henderson’s mixed model equations. Meas Sci Rev 12(6):234–248

    Google Scholar 

  • WitkovskýV(2018) mixed—File Exchange—MATLAB Central. https://www.mathworks.com/matlabcentral/fileexchange/200. Accessed 19 Feb 2020

  • Wu WB, Xiao H (2012) Covariance matrix estimation in time series. In: Rao TS, Rao SS, Rao CR (eds) Handbook of statistics, time series analysis: methods and applications, vol 30. North-Holland, Elsevier, Amsterdam, pp 187–209

    Google Scholar 

  • Ża̧dło T (2009) On MSE of EBLUP. Stat Pap 50(1):101–118

    MathSciNet  MATH  Google Scholar 

  • Zhang F (2005) The Schur complement and its applications. Springer, New York

    MATH  Google Scholar 

  • Zimmermann P, Casamayou A, Cohen N, Connan G, Dumont T, Fousse L, Maltey F, Meulien M, Mezzarobba M, Pernet C, Thiéry NM, Bray E, Cremona J, Forets M, Ghitza A, Thomas H (2018) Computational mathematics with SageMath. SIAM, Philadelphia

    MATH  Google Scholar 

  • Zwiernik P, Uhler C, Richards D (2017) Maximum likelihood estimation for linear Gaussian covariance models. J R Stat Soc Series B Stat Methodol 79(4):1269–1292

    MathSciNet  MATH  Google Scholar 

Download references

Acknowledgements

We are very grateful especially to František Štulajter (Comenius University in Bratislava, SK) for his guidance during our early contact and study of FDSLRM concepts and to Viktor Witkovský (Slovak Academy of Science, SK) for his recommendations and deep insights dealing with the LMM methodology and its computational tools connected to FDSLRM. We would also like to thank Ivan Žezula and Daniel Klein (both from P. J. Šafárik University in Košice, SK) for a valuable feedback dealing with considered estimation methods. Concerning applied computational tools, we would also like to acknowledge involvement and recommendations of Giovanny Covarrubias-Pazaran (University of Wisconsin, US) in using sommer package, Steve Diamond and Stephen Boyd (Stanford University, US) in using CVXPY and CVXR. Finally, in connection with using SageMath, Jupyter and GitHub, our specials thanks go namely to William Stein (University of Washington, US; now CoCalc company), Harald Schilly (Universität Wien, AT), Erik Bray (Université Paris-Sud, FR), Luca de Feo (Université de Versailles Saint-Quentin-en-Yvelines, FR) and Charles J. Weiss (Augustana University, US). Finally, we very much appreciate the helpful and constructive comments of the referees which improved clarity and consistency of the paper substantially.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Martina Hančová.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This work was supported by the Slovak Research and Development Agency under the contract No. APVV-17-0568, the Scientific Grant Agency of the Slovak Republic (VEGA), VEGA Grant No.1/0311/18 and the Internal Research Grant System of Faculty of Science, P. J. Šafárik University in Košice (VVGS PF UPJŠ)—project VVGS-PF-2018-792.

Appendix

Appendix

1.1 A.1 Acronyms and abbreviations

See Table 6

Table 6 List of acronyms used in the paper

1.2 A.2 KKT algorithm for NN-(M)DOOLSE

If we consider \(\upnu _0 = 0\) which occurs if and only if \({\varvec{e}}= \sum \nolimits _{j=1}^{l}\alpha _j \varvec{v}_j\) in KKT conditions (3.8)–(3.10) then the optimal solution \(\tilde{\varvec{\upnu }}\) for NN-(M)DOOLSE is trivial: \(\upnu _{0} = 0, \upnu _{j} = \alpha _j^2, j =1, \ldots , l\). For \(\upnu _0 \ne 0\) implying \(\uplambda _0 =0\), \(\upnu _j\) and \(\uplambda _j\) cannot be simultaneous zero otherwise it would lead to contradiction between (3.8) and (3.9). Therefore, in the case \(\upnu _0 \ne 0\), the complementary slackness condition (3) \(\upnu _j\uplambda _j=0,\,\, j\in \{1, \ldots ,l\}\) can be rewritten in the form \(\,b_j \upnu _j (1-b_j) \uplambda _j = 0 \), where \(b_j\) is an auxiliary indicator, which is zero if \(\upnu _j = 0, \uplambda _j \ne 0 \) and one if \(\upnu _j \ne 0, \uplambda _j = 0 \).

Using vector \(\varvec{b}= (b_1, b_2, \ldots , b_l)' \in \{0,1\}^l\), the derived KKT conditions (2) in Proposition 2 can be described by a \((l+1) \times (l+1)\) matrix function \(\mathbf{K }(\varvec{b})= \{K_{ij}(\varvec{b})\}\) and a vector function \(\varvec{\upgamma }(\varvec{b}) = (\upgamma _0(\varvec{b}),\upgamma _1(\varvec{b}), \ldots , \upgamma _l(\varvec{b}))'\) as

$$\begin{aligned} \mathbf{K }(\varvec{b})\varvec{\upgamma }(\varvec{b}) = \varvec{q}, \end{aligned}$$

where

$$\begin{aligned} K_{ij}(\varvec{b}) =\left\{ \begin{array}{rl} 0, &{} \text { if } i=0, b_j = 0,\\ -1, &{} \text { if } i=j\ne 0, b_j = 0, \\ G_ {ij}, &{} \text { otherwise.} \end{array} \right. \quad \upgamma _j(\varvec{b}) = \left\{ \begin{array}{cl} \upnu _0, &{} \text { if } j = 0\\ b_j \upnu _j +(1-b_j) \uplambda _j, &{} \text { otherwise.} \end{array} \right. \end{aligned}$$

Applying the Banachiewicz formula, we can write for the inverse of \(\mathbf{K }(\varvec{b})\) the following analytic expression

$$\begin{aligned} \mathbf{K}(\varvec{b})^{-1} = \phi ^{-1} \begin{pmatrix} 1 &{} -\varvec{b}'\mathbf{G }_\mathbf{V }\mathbf{D }_{\varvec{b}}^{-1}\\ -\mathbf{D }_{\varvec{b}}^{-1}\mathbf{G }_\mathbf{V }\varvec{j}_{l} &{} \quad \phi \mathbf{D }_{\varvec{b}}^{-1}+\mathbf{D }_{\varvec{b}}^{-1}\mathbf{G }_\mathbf{V }\varvec{j}_{l} \varvec{b}'\mathbf{G }_\mathbf{V }\mathbf{D }_{\varvec{b}}^{-1}\end{pmatrix} \end{aligned}$$

where

$$\begin{aligned} \mathbf{D }_{\varvec{b}}= & {} \text {diag}\left\{ b_j \left\| \varvec{v}_j\right\| ^4+b_j-1\right\} , ~\mathbf{G }_\mathbf{V }= \text {diag}\left\{ \left\| \varvec{v}_j\right\| ^2\right\} , \\ \varvec{j}_{l}= & {} (1, 1, \ldots , 1)' \in \mathbb {R}^{l}, ~\phi = n^{*} -\varvec{b}'\mathbf{G }_\mathbf{V }\mathbf{D }_{\varvec{b}}^{-1}\mathbf{G }_\mathbf{V }\varvec{j}_{l}. \end{aligned}$$

Finally, Proposition 3 guarantees the existence of unique auxiliary vectors \({\tilde{\varvec{\upgamma }}}_{},{\tilde{\varvec{b}}}_{} \):

$$\begin{aligned} {\tilde{\varvec{\upgamma }}}_{}= & {} \{\varvec{\upgamma }; \varvec{\upgamma }=\mathbf{K }(\varvec{b})^{-1}\varvec{q}\ge 0, \varvec{b}\in \{0,1\}^l\} \\ {\tilde{\varvec{b}}}_{}= & {} \{\varvec{b}; {\tilde{\varvec{\upgamma }}}_{}=\mathbf{K }(\varvec{b})^{-1}\varvec{q}, \varvec{b}\in \{0,1\}^l\} \end{aligned}$$

Based on vectors \({\tilde{\varvec{\upgamma }}}_{},{\tilde{\varvec{b}}}_{} \), the NN-(M)DOOLSE \(\tilde{\varvec{\upnu }}= ({\tilde{\upnu }}_{0}, {\tilde{\upnu }}_{1}, \ldots , {\tilde{\upnu }}_{l})'\) of \(\varvec{\upnu }\) as a solution of KKT conditions has the final form

$$\begin{aligned} {\tilde{\upnu }}_{j} =\left\{ \begin{array}{rl} 0, &{} \text { if } j\ne 0, b_j = 0, \\ {\tilde{\upgamma }}_{j}, &{} \text { otherwise.} \end{array} \right. \end{aligned}$$

Thanks to Proposition 3, it is worth to mention that the given matrix system includes also solutions with \(\upnu _0 = 0\).

1.3 A.3 Modern computational technology for FDSLRM kriging

1.3.1 Our computational tools for FDSLRM

As for computational technology, our time series calculations are carried out using free open-source software based on the R statistical language and packages (R Development Core Team 2019; McLeod et al. 2012), the Scientific Python with the SciPy ecosystem (Jones et al. 2001; Oliphant 2007) and free Python-based mathematics software SageMath (Stein and others 2019; Beezer et al. 2013; Zimmermann et al 2018), an open source alternative to the popular commercial computer algebra systems Mathematica or Maple. The simultaneous use of R, SciPy and SageMath provides us valuable cross-checking of our computational results.

Detailed records of our computing with explaining narratives have the form of Jupyter notebooks stored in our free available GitHub repositories devoted to FDSLRM research, https://github.com/fdslrm; see especially a fdslrm repository EBLUP-NE dealing with this paper (Gajdoš et al. 2019c). All notebooks should be seen or studied as static HTML pages via Jupyter nbviewer (https://nbviewer.jupyter.org/, Kluyver et al. (2016)) or interactively as live HTML documents using Binder (https://mybinder.org/, Project Jupyter et al. (2018)) where the code is executable without any need to install or compile the software. To do that, it is only needed to choose and click appropriate links in the Software section of the README homepage in the mentioned repository EBLUP-NE. This easily reproducible way and presentation of our computing with real data were inspired by works (Brieulle et al. 2019; Weiss 2017).

We also started to develop our own R package for FDSLRM, so any potential user can install and use a fully functional version stored in our fdslrm repository R-package (Gajdoš et al. 2019d), which allows the FDLSRM modeling and predictions. Its applications on various real data sets illustrating every step of our three-stage FDSLRM-building approach—formulation (identification), estimation (fitting) and residual diagnostics (checking)—can be found in other fdslrm repository applications (Gajdoš et al. 2019b). All our results obtained from our own implementation were fully consistent with results of standard convex optimization and LMM computational tools which we applied to FDSLRM and are described in the following subsections.

1.3.2 Convex optimization tools for FDSLRM

In nonlinear optimization, there is a variety of highly efficient, fast and reliable open-source and commercial software packages (Cornuéjols et al 2018, chap. 20). Our theoretical consideration and results allow us to apply for estimating \(\varvec{\upnu }\) directly the latest, one of the most well-known convex optimization packages CVXPY and CVXR based on disciplined convex programming, written in Python (Diamond and Boyd 2016) and R (Fu et al. 2019).

CVXPY and its R version CVXR are relatively unknown in statistical community. CVXPY is not only a scientific Python library, but also a language with very simple, readable syntax not requiring any expertise in convex optimization and its computer implementation. CVXPY allows the user to specify the mathematical optimization problem naturally following normal mathematical notation as we can see in computing NN-DOOLSE (Fig. 1) where a code easily mimics the non-negative DOOLSE mathematical formulation (3.4) with \(\varvec{{\Sigma }}_{\varvec{\upnu }}= \sigma _0^2\mathbf{I }_n+\mathbf{V }\mathbf{D }_{\varvec{\upnu }}\mathbf{V }'=\upnu _0\mathbf{I }_n+\mathbf{V }\text {diag}\left\{ \upnu _j\right\} \mathbf{V }'\).

Fig. 1
figure 1

CVXPY code for computing DOOLSE in Jupyter environment

CVXPY implements not only convex optimization solvers using interior-point numerical methods which are extremely reliable and fast, but also verifies convexity of the given problem using rules of disciplined convex programming (Grant et al. 2006). CVXPY was inspired by MATLAB optimization package CVX (Grant and Boyd 2018) still used in many references, e.g. Cornuéjols et al. (2018). However, in CVXPY (CVXR) the user can easily combine convex optimization and simplicity of Python (R) language together with its high-level features such as object-oriented design or parallelism.

It is worth to mention that unlike our KKT algorithm, both CVXPY and CVXR are able to solve non-negative DOOLSE and MDOOLSE in a general FDSLRM without the orthogonality condition. In FDSLRM, interior-points numerical methods have complexity \(n^3\) for one iteration or \(\log (1/\varepsilon )\) times bigger for the complete computation with a precision \(\varepsilon \) of the required optimal solution (Boyd and Vandenberghe 2009).

1.3.3 LMM computational tools for FDSLRM

In our previous paper (Gajdoš et al. 2017), we stated that no current package in R is directly and effectively suitable for FDSLRM. Thanks to a detailed study of (Demidenko 2013; Galecki and Burzykowski 2013) we were successfully directed and instructed how to implement the FDSLRM variance structure into one of the best R packages for LMM known as nlme (Pinheiro and Bates 2009; Pinheiro et al 2018). After that, inspired by nlme, we found another R package called sommer, also suitable for FDSLRM fitting (Covarrubias-Pazaran 2016; Cornuéjols et al. 2018).

Simultaneously, thanks to online computing environment CoCalc for SageMath (Stein and others 2019) with the possibility to run computations and codes for free in many other programming languages and open softwares, we are also able to run and test MATLAB function mixed (Witkovský 2018, 2012) primarily intended for estimating variances in LMMs. On the basis of successful tests, we wrote its R version called MMEinR, which is also available in our GitHub Repository (Gajdoš 2019).

The mentioned LMM packages can also handle (RE)MLE in the general FDSLRM without orthogonality or full-rankness restriction. The packages use iterative methods based on EM algorithm or Henderson MME together with some version of the Newton-Raphson method whose complexity is generally at least \(n^3\).

We are fully aware that another efficient implementation for estimating variances in LMMs provides lme4 package (Bates et al. 2015) or SAS package PROC MIXED (Stroup et al. 2018; SAS Institute Inc. 2018). As for lme4, which is much faster than nlme, we found that the package does not allow implementing FDSLRM covariance structure using lme4 standard input procedure. As SAS laymans, we also tried a university edition of SAS, free from 2014, but we left it after running into initial problems with Windows installation process in a virtual machine environment and subsequently with a more sophisticated programming language than Python or R. Therefore our knowledge with SAS remained only at the theoretical level.

Finally, we point out that thanks to SageMath and our very fast KKT algorithm, we were able to compute (in real time) NN-(M)-DOOLSE in the toy example with infinite precision—as the exact closed-form (algebraic) numbers. To get an explicit idea, e.g. for our toy model, we got these results for NN-MDOOLSE \(\tilde{\varvec{\upnu }}\) identical with REMLE

$$\begin{aligned} \tilde{\varvec{\upnu }} = \begin{pmatrix} \tilde{\sigma }_0^2 \\ \tilde{\sigma }_1^2 \\ \tilde{\sigma }_2^2 \\ \tilde{\sigma }_3^2 \\ \sigma _4^2 \end{pmatrix} = \begin{pmatrix} -\frac{6569}{4080} \, \sqrt{3} \sqrt{2} - \frac{13207}{4080} \, \sqrt{3} - \frac{22533}{6800} \, \sqrt{2} + \frac{312727}{20400} \\ \frac{6569}{48960} \, \sqrt{3} \sqrt{2} + \frac{275509}{244800} \, \sqrt{3} + \frac{7511}{27200} \, \sqrt{2} + \frac{50461}{244800} \\ \frac{6569}{48960} \, \sqrt{3} \sqrt{2} + \frac{37687}{48960} \, \sqrt{3} + \frac{7511}{27200} \, \sqrt{2} - \frac{93427}{244800} \\ \frac{6569}{48960} \, \sqrt{3} \sqrt{2} + \frac{13207}{48960} \, \sqrt{3} + \frac{11081}{27200} \, \sqrt{2} - \frac{66779}{61200} \\ \frac{6569}{48960} \, \sqrt{3} \sqrt{2} + \frac{13207}{48960} \, \sqrt{3} + \frac{43637}{48960} \, \sqrt{2} - \frac{17377}{61200} \end{pmatrix} \approx \begin{pmatrix} 1.093 \\ 2.875 \\ 1.671 \\ 0.281 \\ 1.772 \end{pmatrix}. \end{aligned}$$

It means that we can compute real numerical errors in results for all used computational tools to explore their quality from the viewpoint of numerical precision.

A.4 The BLUP-NE method — proofs

Existence of inversions for \( \mathbf{U} _{\varvec{\upnu }}\),  \(\mathbf{H} _{\varvec{\upnu }}\)

To prove nonsingularity of \( \mathbf{U} _{\varvec{\upnu }}\), \(\mathbf{H} _{\varvec{\upnu }}\), it is sufficient to show that both matrices have non-zero determinants. Using idempotence of \(\mathbf{M} _\mathbf{F }\) and determinant expression (3.17), we can write for determinants of \( \mathbf{U} _{\varvec{\upnu }}\), \(\mathbf{H} _{\varvec{\upnu }}\)

$$\begin{aligned} \det \mathbf{H} _{\varvec{\upnu }}= & {} \det (\sigma _0^2 \mathbf{I }_l+\mathbf{V }'\mathbf{V }\mathbf{D }_{\varvec{\upnu }}) = (-\sigma _0^2)^{l-n}\det (\sigma _0^2 \mathbf{I }_l+\mathbf{V }\mathbf{D }_{\varvec{\upnu }}\mathbf{V }'), \\ \det \mathbf{U} _{\varvec{\upnu }}= & {} \det (\sigma _0^2 \mathbf{I }_l+\mathbf{V }'\mathbf{M} _\mathbf{F }\mathbf{M} _\mathbf{F }\mathbf{V }\mathbf{D }_{\varvec{\upnu }}) = (-\sigma _0^2)^{l-n}\det (\sigma _0^2 \mathbf{I }_l+\mathbf{M} _\mathbf{F }\mathbf{V }\mathbf{D }_{\varvec{\upnu }}\mathbf{V }'\mathbf{M} _\mathbf{F }). \end{aligned}$$

Now we can see that the sum of positive definite matrix \(\sigma _0^2\mathbf{I }_l\,\, (\sigma _0^2>0)\) and each of positive semidefinite matrices \(\mathbf{V }\mathbf{D }_{\varvec{\upnu }}\mathbf{V }', \,\,\mathbf{M} _\mathbf{F }\mathbf{V }\mathbf{D }_{\varvec{\upnu }}\mathbf{V }'\mathbf{M} _\mathbf{F }\) is a positive definite matrix, whose determinant is always positive.

Proof (Theorem 2)

Employing Lemma 1 and the well-known standard expressions for mean values and covariances of invariant quadratic estimators [see e.g. Christensen (2011), Puntanen et al. (2013)] \(E_{\varvec{\upnu }}\left\{ \varvec{X}'\mathbf{A }\varvec{X}\right\} =\text {tr}(\mathbf{A }\varvec{{\Sigma }}_{\varvec{\upnu }})\) and if \(\varvec{X}\sim {\mathcal {N}}_n(\mathbf{F }\varvec{\beta }, \varvec{{\Sigma }}_{\varvec{\upnu }})\) then \({Cov}_{\varvec{\upnu }}\left\{ \varvec{X}'\mathbf{A }\varvec{X}, \varvec{X}'\mathbf{B }\varvec{X}\right\} =2\,\text {tr}(\mathbf{A }\varvec{{\Sigma }}_{\varvec{\upnu }}\mathbf{B }\varvec{{\Sigma }}_{\varvec{\upnu }})\), we have

  1. (1)

    According to (3) of Lema 1\((\mathbf{T }_{\varvec{\upnu }}\varvec{{\Sigma }}_{\varvec{\upnu }}\mathbf{T }_{\varvec{\upnu }}')_{jj}= \mathbf{D }_{\varvec{\upnu }jj}-\sigma ^2(\mathbf{W} _{\varvec{\upnu }}^{-1})_{jj}= \sigma ^2_j-\sigma ^2(\mathbf{W} _{\varvec{\upnu }}^{-1})_{jj}\).

  2. (2)

    As a consequence of (1) \(D_{\varvec{\upnu }}\{\mathring{{\sigma }}_{j}^2\} =2(\sigma ^2_j-\sigma ^2(\mathbf{W} _{\varvec{\upnu }}^{-1})_{jj})^ 2\).

  3. (3)

    In a similar way as in (2)

    $$\begin{aligned} {Cov}_{\varvec{\upnu }}\left\{ \mathring{{\sigma }}_{i}^2,\mathring{{\sigma }}_{j}^2\right\}= & {} 2\text {tr}(\varvec{\tau }_{ i}\varvec{\tau }_{ i}'\varvec{{\Sigma }}_{\varvec{\upnu }}\varvec{\tau }_{ j}\varvec{\tau }_{ j}' \varvec{{\Sigma }}_{\varvec{\upnu }})= 2\text {tr}(\varvec{\tau }_{ i}'\varvec{{\Sigma }}_{\varvec{\upnu }}\varvec{\tau }_{ j}\varvec{\tau }_{ j}' \varvec{{\Sigma }}_{\varvec{\upnu }}\varvec{\tau }_{ i})= 2(\varvec{\tau }_{ i}'\varvec{{\Sigma }}_{\varvec{\upnu }}\varvec{\tau }_{ j})^2 \\= & {} 2(\mathbf{T }_{\varvec{\upnu }} \varvec{{\Sigma }}_{\varvec{\upnu }}\mathbf{T }_{\varvec{\upnu }}')^2_{ij}= 2(0-\sigma ^2 (\mathbf{W} _{\varvec{\upnu }}^{-1})_{ij})^2= 2(\sigma ^2 (\mathbf{W} _{\varvec{\upnu }}^{-1})_{ij})^2. \end{aligned}$$
  4. (4)

\(\square \)

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Hančová, M., Gajdoš, A., Hanč, J. et al. Estimating variances in time series kriging using convex optimization and empirical BLUPs. Stat Papers 62, 1899–1938 (2021). https://doi.org/10.1007/s00362-020-01165-5

Download citation

  • Received:

  • Revised:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00362-020-01165-5

Keywords

Mathematics Subject Classification

Navigation