I need my R scripts to always produce the same results for the same input. However, I've noticed that the function logspline from the package logspline produces different output on windows OS and ubuntu OS. Both uses logspline package 2.1.16, though.
Here's the code:
x <- c(0.3453205379,0.3497529927,0.3460179029,0.3433414591,0.3565925053,0.3318019585,0.3322091870,0.3314076990,0.3413768315,0.3305650805,0.3342775671,0.3362692445,0.3321054345,0.5982416984,0.5509602046,0.6600000000,0.3339818725,0.3307459063,0.3314632807,0.3356930476,0.3300000000,0.3324504116,0.3470739551,0.3441385006,0.3316070520,0.3399635743,0.3316989471,0.3308044524,0.3536822479,0.3315414656)
fnc <- logspline(x)
plot.logspline(fnc)
and here's the result on windows - fitted with 7 knots:
and here the result on ubuntu - fitted with 5 knots:

Could someone explain me the reason of the difference, please? And is there a way to force the function to produce consistent results in any environment?
Output logspline(x, error.action=0) on windows:
knots A(1)/D(2) loglik AIC minimum penalty maximum penalty
4 2 40.53 -70.85 113.83 Inf
5 2 97.44 -181.28 5.48 113.83
6 2 99.48 -181.96 NA NA
7 2 102.92 -185.44 -0.13 5.48
8 1 102.86 -181.90 NA NA
the present optimal number of knots is 7
penalty(AIC) was the default: BIC=log(samplesize): log( 30 )= 3.4
Output logspline(x, error.action=0) on linux:
knots A(1)/D(2) loglik AIC minimum penalty maximum penalty
4 2 87.33 -164.46 8.38 Inf
5 2 91.52 -169.44 2.07 8.38
6 1 91.95 -166.88 NA NA
7 1 93.60 -166.78 0.00 2.07
8 1 93.60 -163.38 NA NA
the present optimal number of knots is 5
penalty(AIC) was the default: BIC=log(samplesize): log( 30 )= 3.4
Output sessionInfo() on windows:
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] logspline_2.1.16
loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0
Output sessionInfo() on linux:
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8
[5] LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 LC_PAPER=C.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] logspline_2.1.16
loaded via a namespace (and not attached):
[1] compiler_4.1.0 tools_4.1.0

