Calculates the log likelihood and degrees of freedom for a fitted grpreg object.
Arguments
- object
A fitted
grpreg
orgrpsurv
object, as obtained fromgrpreg()
orgrpsurv()
- df.method
How should effective model parameters be calculated? One of:
"active"
, which counts the number of nonzero coefficients; or"default"
, which uses the calculateddf
returned bygrpreg
. Default is"default"
.- REML
Use restricted MLE for estimation of the scale parameter in a gaussian model? Default is FALSE.
- ...
For S3 method compatibility.
Value
Returns an object of class 'logLik', in this case consisting of a number (or vector of numbers) with two attributes: 'df' (the estimated degrees of freedom in the model) and 'nobs' (number of observations).
The 'print' method for 'logLik' objects is not intended to handle vectors; consequently, the value of the function does not necessarily display correctly. However, it works with 'AIC' and 'BIC' without any glitches and returns the expected vectorized output.
Examples
data(Birthwt)
X <- Birthwt$X
y <- Birthwt$bwt
group <- Birthwt$group
fit <- grpreg(X,y,group,penalty="cMCP")
logLik(fit) ## Display is glitchy for vectors
#> 'log Lik.' -207.9942, -205.8047, -204.2471, -202.6167, -200.1960, -197.4306, -194.3174, -191.4073, -188.4177, -185.6547, -183.3583, -181.5515, -179.8315, -178.4712, -177.4033, -176.4566, -175.7113, -175.0176, -174.3787, -173.8237, -173.3874, -173.0445, -172.7754, -172.5640, -172.3983, -172.2685, -172.1669, -172.0874, -172.0254, -171.9770, -171.9392, -171.9098, -171.8870, -171.8693, -171.8555, -171.8449, -171.8355, -171.8255, -171.8150, -171.8067, -171.8003, -171.7954, -171.7915, -171.7886, -171.7863, -171.7845, -171.7832, -171.7821, -171.7813, -171.7807, -171.7803, -171.7799, -171.7796, -171.7794, -171.7793, -171.7791, -171.7791, -171.7790, -171.7789, -171.7789, -171.7789, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788, -171.7788 (df= 2.000000 2.153895 2.280447 2.440723 2.716807 3.081085 3.529672 4.005194 4.582002 5.191650 5.756456 6.250947 6.809371 7.302987 7.737498 8.250717 8.705069 9.230792 9.80511410.39037110.90821011.36729411.77549612.13863512.46211712.75044513.00750313.23668113.44096113.62297813.78506913.92931914.05758914.17154614.27263214.36230014.55110014.87085515.35404915.75704316.08718916.36138716.59137016.78570516.95085517.09181017.21249417.31603517.40488917.48113417.54683817.60396717.65360717.69669117.73398417.76657317.79501717.81979017.84159517.86071417.87767917.89259817.90570817.91721417.92729517.93611217.94376717.95052417.95648517.96173717.96636017.97042517.96469917.96860017.97208917.97515217.97783917.98022117.98235217.98427217.98600017.98755517.98895217.99020817.99133517.99234717.99325317.99406417.99478917.99543617.99601417.99652817.99698517.99739117.99775117.99806817.99834817.99859417.99881017.998999)
AIC(fit)
#> [1] 419.9884 415.9171 413.0551 410.1149 405.8256 401.0234 395.6942 390.8250
#> [9] 385.9994 381.6926 378.2296 375.6049 373.2817 371.5483 370.2815 369.4147
#> [17] 368.8327 368.4968 368.3677 368.4282 368.5912 368.8236 369.1017 369.4053
#> [25] 369.7208 370.0378 370.3488 370.6482 370.9327 371.1999 371.4486 371.6783
#> [33] 371.8892 372.0816 372.2563 372.4144 372.7731 373.3927 374.3380 375.1275
#> [41] 375.7750 376.3135 376.7658 377.1486 377.4743 377.7527 377.9913 378.1963
#> [49] 378.3725 378.5237 378.6542 378.7677 378.8665 378.9522 379.0265 379.0914
#> [57] 379.1481 379.1975 379.2410 379.2792 379.3131 379.3429 379.3690 379.3920
#> [65] 379.4122 379.4298 379.4451 379.4586 379.4705 379.4810 379.4903 379.4984
#> [73] 379.4869 379.4947 379.5017 379.5078 379.5132 379.5180 379.5222 379.5261
#> [81] 379.5295 379.5326 379.5354 379.5379 379.5402 379.5422 379.5440 379.5457
#> [89] 379.5471 379.5484 379.5496 379.5506 379.5515 379.5523 379.5530 379.5537
#> [97] 379.5542 379.5547 379.5551 379.5555
BIC(fit)
#> [1] 426.4719 422.8995 420.4477 418.0271 414.6328 411.0115 407.1365 403.8089
#> [9] 400.8531 398.5227 396.8905 395.8689 395.3560 395.2227 395.3646 396.1615
#> [17] 397.0523 398.4207 400.1534 402.1112 403.9529 405.6735 407.2749 408.7556
#> [25] 410.1198 411.3716 412.5158 413.5582 414.5049 415.3621 416.1363 416.8336
#> [33] 417.4603 418.0222 418.5246 418.9733 419.9441 421.6002 424.1120 426.2079
#> [41] 427.9256 429.3530 430.5508 431.5636 432.4247 433.1600 433.7899 434.3306
#> [49] 434.7947 435.1931 435.5366 435.8354 436.0950 436.3204 436.5156 436.6862
#> [57] 436.8351 436.9648 437.0790 437.1791 437.2680 437.3461 437.4148 437.4751
#> [65] 437.5279 437.5741 437.6142 437.6497 437.6809 437.7084 437.7326 437.7540
#> [73] 437.7240 437.7444 437.7627 437.7787 437.7928 437.8053 437.8165 437.8265
#> [81] 437.8356 437.8437 437.8511 437.8576 437.8636 437.8689 437.8736 437.8779
#> [89] 437.8817 437.8850 437.8881 437.8908 437.8932 437.8953 437.8972 437.8988
#> [97] 437.9003 437.9016 437.9027 437.9037