Skip to contents

This function performs the nonlinear least squares (NLS) regression method for the cosine model. It fits the NLS method as required, and then computes different quantities for the birth seasonality estimates corresponding to different individuals.

Usage

makeFits(
  paths,
  amplitude = NULL,
  intercept = NULL,
  method = c("OLS", "initial")
)

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'.

amplitude

Initial value for the amplitude parameter for the method="initial" method.

intercept

Initial value for the intercept parameter for the method="initial" method.

method

A character string giving the initialization for the nonlinear least squares regression. This must be either method="initial" or method="OLS". Default is method="OLS" method. method="initial" performs the nonlinear least squares (NLS) regression method for the cosine model without initializing parameter selections. It begins with the given initial values for amplitude and intercept. method="OLS" uses the least squares estimates (see Chazin et al. 2019) as the initial parameter selection.

Value

A data frame containing the following components:

amplitude

estimated amplitude

intercept

estimated intercept

x0

delay of the data

X

period of the data

birth

birth seasonality estimate

predictedMin

predicted minimum for the oxygen isotope variable

predictedMax

predicted maximum for the oxygen isotope variable

observedMin

observed minimum for the oxygen isotope variable

observedMax

observed minimum for the oxygen isotope variable

MSE

mean squared error corresponding to the model fit for every individual

Pearson

Pearson's R^2 corresponding to the model fit for every individual

Examples

armenia_split = split(armenia,f = armenia$ID)
amp = seq(1,10,by=0.5)
int = seq(-25,0,by=0.5)
makeFits(armenia_split,amp[1],int[1],method = "initial")
#> Warning: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
#> Warning: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
#> Warning: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
#> Warning: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
#>       amplitude    intercept          x0         X      birth predictedMin
#> 1  1.828067e+00    -7.647116  87.7122853 145.64583 0.60222997    -9.475183
#> 2  3.929605e+03 -3915.251530   6.8978771  15.00554 0.45968859 -7844.856043
#> 3  3.324663e+00    -6.738144   9.0470441  22.62968 0.39978671   -10.062807
#> 4  1.465846e+00    -8.480712 182.0684115 252.28524 0.72167682    -9.946558
#> 5  6.991007e-01    -4.026564   9.9913089  32.96119 0.30312347    -4.725665
#> 6  4.179477e+00    -5.118462  19.5194126  33.51153 0.58246853    -9.297939
#> 7  1.586247e+00    -9.522778   3.4181413  11.58800 0.29497240   -11.109025
#> 8  3.336780e+00    -6.145026  10.4120192  33.13019 0.31427588    -9.481806
#> 9  3.430782e+00    -6.294009   9.1120997  29.38081 0.31013778    -9.724791
#> 10 3.462499e+00    -6.380318  17.7009496  33.13923 0.53413876    -9.842817
#> 11 3.799398e+00    -6.302005  12.6856187  33.51431 0.37851351   -10.101403
#> 12 4.937785e+00    -7.423759  12.3397881  35.36799 0.34889703   -12.361544
#> 13 3.373132e+00    -5.604018  16.5363565  22.30952 0.74122408    -8.977150
#> 14 4.680810e+00    -6.338310   8.8111856  25.27965 0.34854862   -11.019120
#> 15 4.322568e+00    -8.183360   0.8511126  30.41352 0.02798468   -12.505928
#> 16 3.119539e+00    -6.700140   3.8342338  35.44646 0.10816971    -9.819679
#> 17 3.366478e+00    -6.120014  10.1234903  33.96789 0.29803119    -9.486492
#> 18 3.648866e+00    -5.760416  11.1946164  30.09531 0.37197209    -9.409282
#> 19 4.747568e+00    -7.322763  11.9597359  34.02145 0.35153513   -12.070332
#> 20 4.027442e+00    -7.389552  11.1089044  32.89129 0.33774607   -11.416994
#> 21 3.222195e+00    -6.548946   9.7099414  29.49495 0.32920690    -9.771141
#> 22 1.995807e-02    -4.397857  31.0259955  33.80817 0.91770703    -4.417815
#> 23 4.009349e+00    -5.498994  12.1927893  30.00243 0.40639335    -9.508344
#> 24 4.152821e+00    -5.817953  31.2650834  40.13792 0.77894133    -9.970773
#>    predictedMax observedMin observedMax          MSE    Pearson
#> 1    -5.8190496       -9.28       -2.48 1.529106e+01  0.9686448
#> 2    14.3529834      -11.34       -0.09 2.018789e+07  0.0510901
#> 3    -3.4134813       -9.52       -2.42 2.470694e-01  0.9752471
#> 4    -7.0148657      -10.18       -0.69 2.017519e+01  0.9046926
#> 5    -3.3274637       -4.65       -2.90 2.070901e-01  0.7365597
#> 6    -0.9389847      -10.07       -0.47 6.031176e-01  0.9716171
#> 7    -7.9365314      -12.30       -6.22 2.114833e+00  0.6120182
#> 8    -2.8082454       -9.37       -1.90 4.773146e-01  0.9559358
#> 9    -2.8632274       -9.69       -3.15 9.364418e-02  0.9924722
#> 10   -2.9178197       -9.36       -2.36 2.164370e-01  0.9775559
#> 11   -2.5026068       -7.88       -2.47 7.582879e-02  0.9897773
#> 12   -2.4859740      -11.52       -2.73 8.274287e-02  0.9954652
#> 13   -2.2308865       -9.66       -2.88 5.889335e-01  0.9545514
#> 14   -1.6575007       -8.04       -1.92 1.976594e-01  0.9833570
#> 15   -3.8607926      -12.33       -3.89 1.933057e-01  0.9889660
#> 16   -3.5806005       -9.58       -3.19 1.238112e-01  0.9879239
#> 17   -2.7535360       -9.41       -2.89 1.258966e-01  0.9893759
#> 18   -2.1115501       -9.51       -2.22 1.582954e-01  0.9882583
#> 19   -2.5751949      -10.29       -2.56 2.697012e-01  0.9795975
#> 20   -3.3621106      -11.45       -3.59 1.056773e-01  0.9933704
#> 21   -3.3267502       -8.41       -3.51 3.810623e-02  0.9933530
#> 22   -4.3778990       -9.40       -1.41 9.161076e+00 -0.9222432
#> 23   -1.4896450       -8.81       -1.52 3.215473e-01  0.9790757
#> 24   -1.6651319      -10.14       -2.93 1.787485e-01  0.9841492
makeFits(armenia_split, method = "OLS")
#> Warning: step factor 0.000488281 reduced below 'minFactor' of 0.000976562
#>    amplitude intercept         x0         X      birth predictedMin
#> 1  5.2652999 -4.248525 33.2708787  37.91834 0.87743494    -9.513825
#> 2  5.9191441 -5.714313  0.7847780  35.38069 0.02218097   -11.633457
#> 3  3.3246622 -6.738144  9.0470374  22.62969 0.39978616   -10.062806
#> 4  4.7367622 -5.509659  3.2810551  37.95713 0.08644107   -10.246421
#> 5  0.6991006 -4.026565  9.9913043  32.96120 0.30312317    -4.725665
#> 6  4.1794786 -5.118464 19.5194191  33.51158 0.58246789    -9.297942
#> 7  0.2239310 -9.845523 14.1013203 147.79461 0.09541160   -10.069454
#> 8  3.3367784 -6.145026 10.4120108  33.13023 0.31427522    -9.481804
#> 9  3.4307832 -6.294008  9.1121024  29.38078 0.31013816    -9.724792
#> 10 3.4624988 -6.380318 17.7009474  33.13923 0.53413879    -9.842817
#> 11 3.7993881 -6.301994 12.6856177  33.51424 0.37851427   -10.101382
#> 12 4.9377792 -7.423751 12.3397890  35.36795 0.34889751   -12.361530
#> 13 3.3731318 -5.604018 16.5363477  22.30952 0.74122376    -8.977150
#> 14 4.6807709 -6.338268  8.8111826  25.27949 0.34855069   -11.019039
#> 15 4.3225697 -8.183357  0.8511008  30.41354 0.02798427   -12.505927
#> 16 3.1195383 -6.700140  3.8342427  35.44646 0.10816997    -9.819679
#> 17 3.3664785 -6.120014 10.1234946  33.96788 0.29803139    -9.486493
#> 18 3.6488657 -5.760415 11.1946144  30.09531 0.37197210    -9.409281
#> 19 4.7475693 -7.322764 11.9597362  34.02146 0.35153509   -12.070334
#> 20 4.0274413 -7.389551 11.1089040  32.89129 0.33774612   -11.416993
#> 21 3.2221893 -6.548938  9.7099434  29.49489 0.32920766    -9.771127
#> 22 3.9674723 -5.180679 15.7330178  26.45066 0.59480626    -9.148151
#> 23 4.0093494 -5.498993 12.1927933  30.00242 0.40639365    -9.508343
#> 24 4.1528322 -5.817939 31.2651352  40.13802 0.77894057    -9.970771
#>    predictedMax observedMin observedMax        MSE   Pearson
#> 1     1.0167750       -9.28       -2.48 0.13712714 0.9897939
#> 2     0.2048312      -11.34       -0.09 0.10486315 0.9969164
#> 3    -3.4134819       -9.52       -2.42 0.24706940 0.9752471
#> 4    -0.7728966      -10.18       -0.69 0.17725811 0.9925065
#> 5    -3.3274640       -4.65       -2.90 0.20709011 0.7365597
#> 6    -0.9389852      -10.07       -0.47 0.60311759 0.9716171
#> 7    -9.6215924      -12.30       -6.22 3.35496827 0.7266062
#> 8    -2.8082472       -9.37       -1.90 0.47731459 0.9559358
#> 9    -2.8632250       -9.69       -3.15 0.09364418 0.9924722
#> 10   -2.9178194       -9.36       -2.36 0.21643700 0.9775559
#> 11   -2.5026056       -7.88       -2.47 0.07582879 0.9897773
#> 12   -2.4859720      -11.52       -2.73 0.08274287 0.9954652
#> 13   -2.2308865       -9.66       -2.88 0.58893347 0.9545514
#> 14   -1.6574970       -8.04       -1.92 0.19765941 0.9833570
#> 15   -3.8607871      -12.33       -3.89 0.19330565 0.9889660
#> 16   -3.5806022       -9.58       -3.19 0.12381115 0.9879239
#> 17   -2.7535356       -9.41       -2.89 0.12589665 0.9893759
#> 18   -2.1115497       -9.51       -2.22 0.15829539 0.9882583
#> 19   -2.5751950      -10.29       -2.56 0.26970116 0.9795975
#> 20   -3.3621102      -11.45       -3.59 0.10567727 0.9933704
#> 21   -3.3267489       -8.41       -3.51 0.03810623 0.9933530
#> 22   -1.2132066       -9.40       -1.41 0.10895676 0.9938152
#> 23   -1.4896439       -8.81       -1.52 0.32154728 0.9790757
#> 24   -1.6651064      -10.14       -2.93 0.17874849 0.9841492