Generates prediction for linear regression. Note that one can either input a 'linearr' object or a matrix of beta coefficients.

# S3 method for linearr
predict(object, X, y = NULL, ...)

Arguments

object

'linearr' object or matrix of betas

X

matrix or data frame of (new) observations

y

optional, matrix or vector of response values

...

additional arguments

Value

predictions and loss metrics

Examples

library(dplyr) X = dplyr::select(iris, -c(Species, Sepal.Length)) y = dplyr::select(iris, Sepal.Length) fitted = linearr(X, y, lam = 0.1) predict(fitted, X)
#> $fitted.values #> [,1] #> [1,] 5.015416 #> [2,] 4.689997 #> [3,] 4.749251 #> [4,] 4.825994 #> [5,] 5.080499 #> [6,] 5.377194 #> [7,] 4.894684 #> [8,] 5.021245 #> [9,] 4.624913 #> [10,] 4.881642 #> [11,] 5.216496 #> [12,] 5.092158 #> [13,] 4.745645 #> [14,] 4.532906 #> [15,] 5.199008 #> [16,] 5.560786 #> [17,] 5.093541 #> [18,] 4.959767 #> [19,] 5.367758 #> [20,] 5.225932 #> [21,] 5.163072 #> [22,] 5.105200 #> [23,] 4.796847 #> [24,] 4.931043 #> [25,] 5.304898 #> [26,] 4.831824 #> [27,] 4.980862 #> [28,] 5.086329 #> [29,] 4.950332 #> [30,] 4.961991 #> [31,] 4.896907 #> [32,] 4.909949 #> [33,] 5.532480 #> [34,] 5.471002 #> [35,] 4.825994 #> [36,] 4.678338 #> [37,] 4.944503 #> [38,] 5.136148 #> [39,] 4.619084 #> [40,] 5.021245 #> [41,] 4.888854 #> [42,] 4.107850 #> [43,] 4.749251 #> [44,] 4.934649 #> [45,] 5.453936 #> [46,] 4.634349 #> [47,] 5.352493 #> [48,] 4.820165 #> [49,] 5.216496 #> [50,] 4.885248 #> [51,] 6.492521 #> [52,] 6.295046 #> [53,] 6.513615 #> [54,] 5.466023 #> [55,] 6.105625 #> [56,] 6.146008 #> [57,] 6.446308 #> [58,] 5.201659 #> [59,] 6.282005 #> [60,] 5.599797 #> [61,] 5.083151 #> [62,] 5.952139 #> [63,] 5.567884 #> [64,] 6.297270 #> [65,] 5.572873 #> [66,] 6.214698 #> [67,] 6.164879 #> [68,] 5.964216 #> [69,] 5.644209 #> [70,] 5.636574 #> [71,] 6.340841 #> [72,] 5.791442 #> [73,] 6.123113 #> [74,] 6.343483 #> [75,] 6.069265 #> [76,] 6.149614 #> [77,] 6.303099 #> [78,] 6.408148 #> [79,] 6.099795 #> [80,] 5.473653 #> [81,] 5.500577 #> [82,] 5.485312 #> [83,] 5.711093 #> [84,] 6.339459 #> [85,] 6.164879 #> [86,] 6.369565 #> [87,] 6.371789 #> [88,] 5.749676 #> [89,] 5.992523 #> [90,] 5.596191 #> [91,] 6.000576 #> [92,] 6.291440 #> [93,] 5.716923 #> [94,] 5.136576 #> [95,] 5.868185 #> [96,] 6.119084 #> [97,] 5.998352 #> [98,] 6.069265 #> [99,] 4.998355 #> [100,] 5.862355 #> [101,] 6.867345 #> [102,] 6.172514 #> [103,] 6.823774 #> [104,] 6.712895 #> [105,] 6.697212 #> [106,] 7.320166 #> [107,] 5.728164 #> [108,] 7.209288 #> [109,] 6.594387 #> [110,] 7.133510 #> [111,] 6.442284 #> [112,] 6.314340 #> [113,] 6.540121 #> [114,] 5.915785 #> [115,] 5.959356 #> [116,] 6.417166 #> [117,] 6.707066 #> [118,] 7.856101 #> [119,] 7.161275 #> [120,] 5.998775 #> [121,] 6.700818 #> [122,] 6.040123 #> [123,] 7.316560 #> [124,] 6.086336 #> [125,] 6.877199 #> [126,] 7.191799 #> [127,] 6.080506 #> [128,] 6.281587 #> [129,] 6.480867 #> [130,] 7.031102 #> [131,] 6.946729 #> [132,] 7.754658 #> [133,] 6.425219 #> [134,] 6.460191 #> [135,] 6.740237 #> [136,] 6.854304 #> [137,] 6.704424 #> [138,] 6.772150 #> [139,] 6.210674 #> [140,] 6.534292 #> [141,] 6.509173 #> [142,] 6.210256 #> [143,] 6.172514 #> [144,] 6.842645 #> [145,] 6.654606 #> [146,] 6.216085 #> [147,] 5.971433 #> [148,] 6.383030 #> [149,] 6.618246 #> [150,] 6.423413 #> #> $RSS #> NULL #> #> $MSE #> NULL #>