remove variable linear trend based on covariate
Usage
rm_lineartrend(formula, data, method = c("cpp", "r"))
Examples
gzma = sf::read_sf(system.file('extdata/gzma.gpkg',package = 'sdsfun'))
rm_lineartrend(PS_Score ~ ., gzma)
#> [1] 0.708424646 -1.609213853 1.389752789 1.693524199 1.327675963
#> [6] 1.552796232 1.899480900 -0.650465423 -0.150480934 1.207015152
#> [11] 1.590458131 -0.300747679 1.143676294 1.457378099 0.606484742
#> [16] 1.080892928 0.290475256 0.851942083 1.067253575 1.682518084
#> [21] 0.137597711 0.806861604 -0.382599378 -1.933709170 0.861349335
#> [26] 0.627829873 -0.395623890 -0.738657687 -0.679936281 1.578903157
#> [31] -1.151803933 2.234107137 0.965888325 0.801133421 1.260946335
#> [36] 0.584697508 1.452096690 1.113403340 0.930704599 0.569299373
#> [41] 0.192976485 0.094368097 0.805529409 1.722632299 1.010261352
#> [46] 1.433806182 0.636670605 0.679991093 0.791008927 0.486903877
#> [51] -0.672956723 1.234880768 1.068841885 -1.611547072 -2.923649428
#> [56] 2.710999016 -2.727100878 -2.465795534 -2.420953865 -1.699626340
#> [61] 0.099917867 -2.620506144 -0.959386254 -2.114950450 -1.701304099
#> [66] -2.710909466 3.000369819 -2.063893641 -1.115021871 -3.280581061
#> [71] -0.109847308 1.353662758 0.008388022 -0.931649680 1.019333454
#> [76] 3.201800582 0.200651409 1.470887804 1.387311480 1.189574771
#> [81] 2.023171387 -1.887476207 1.837215556 0.046758454 -1.084568068
#> [86] -0.932912947 1.072475344 1.192060715 1.757123807 -0.253721067
#> [91] -0.051510901 -0.819077316 0.917087617 1.037676625 0.853722585
#> [96] -2.519645620 -3.249272906 -0.884320640 -3.099347554 -0.903303600
#> [101] -0.477738008 0.133769176 -0.111569828 -2.570393960 0.555851538
#> [106] 0.904301525 -1.008869009 -2.122700858 0.427963148 -2.497669111
#> [111] -2.938632840 0.757894144 -2.047276844 -0.726676936 -3.279405691
#> [116] 0.094510726 -1.269057176 1.971147342
rm_lineartrend(PS_Score ~ ., gzma, method = "r")
#> [1] 0.708424646 -1.609213853 1.389752789 1.693524199 1.327675963
#> [6] 1.552796232 1.899480900 -0.650465423 -0.150480934 1.207015152
#> [11] 1.590458131 -0.300747679 1.143676294 1.457378099 0.606484742
#> [16] 1.080892928 0.290475256 0.851942083 1.067253575 1.682518084
#> [21] 0.137597711 0.806861604 -0.382599378 -1.933709170 0.861349335
#> [26] 0.627829873 -0.395623890 -0.738657687 -0.679936281 1.578903157
#> [31] -1.151803933 2.234107137 0.965888325 0.801133421 1.260946335
#> [36] 0.584697508 1.452096690 1.113403340 0.930704599 0.569299373
#> [41] 0.192976485 0.094368097 0.805529409 1.722632299 1.010261352
#> [46] 1.433806182 0.636670605 0.679991093 0.791008927 0.486903877
#> [51] -0.672956723 1.234880768 1.068841885 -1.611547072 -2.923649428
#> [56] 2.710999016 -2.727100878 -2.465795534 -2.420953865 -1.699626340
#> [61] 0.099917867 -2.620506144 -0.959386254 -2.114950450 -1.701304099
#> [66] -2.710909466 3.000369819 -2.063893641 -1.115021871 -3.280581061
#> [71] -0.109847308 1.353662758 0.008388022 -0.931649680 1.019333454
#> [76] 3.201800582 0.200651409 1.470887804 1.387311480 1.189574771
#> [81] 2.023171387 -1.887476207 1.837215556 0.046758454 -1.084568068
#> [86] -0.932912947 1.072475344 1.192060715 1.757123807 -0.253721067
#> [91] -0.051510901 -0.819077316 0.917087617 1.037676625 0.853722585
#> [96] -2.519645620 -3.249272906 -0.884320640 -3.099347554 -0.903303600
#> [101] -0.477738008 0.133769176 -0.111569828 -2.570393960 0.555851538
#> [106] 0.904301525 -1.008869009 -2.122700858 0.427963148 -2.497669111
#> [111] -2.938632840 0.757894144 -2.047276844 -0.726676936 -3.279405691
#> [116] 0.094510726 -1.269057176 1.971147342