{"id":3449,"date":"2024-03-31T22:44:07","date_gmt":"2024-03-31T13:44:07","guid":{"rendered":"https:\/\/plaza.umin.ac.jp\/~OIO\/?p=3449"},"modified":"2024-03-31T22:58:39","modified_gmt":"2024-03-31T13:58:39","slug":"r-cmprsk-%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8","status":"publish","type":"post","link":"https:\/\/plaza.umin.ac.jp\/~OIO\/?p=3449","title":{"rendered":"R CMPRSK \u30d1\u30c3\u30b1\u30fc\u30b8"},"content":{"rendered":"<h1>CMPRSK\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306f<\/h1>\n<p><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"tooltip-target\" data-citationid=\"68b0bcc5-69d2-1585-f12a-c2483cce9aa2-3-group\" h=\"ID=SERP,5017.1\" target=\"_blank\" rel=\"noopener\"><strong>{cmprsk}<\/strong> \u306f\u3001\u7af6\u5408\u30ea\u30b9\u30af\u30a4\u30d9\u30f3\u30c8\u306e\u3042\u308b\u751f\u5b58\u6642\u9593\u5206\u6790\u3092\u5b9f\u65bd\u3059\u308b\u305f\u3081\u306eR\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3059<\/a><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"68b0bcc5-69d2-1585-f12a-c2483cce9aa2-3\" aria-label=\"1: {cmprsk}\" h=\"ID=SERP,5017.1\" rel=\"noopener\"><sup class=\"citation-sup\">1<\/sup><\/a>\u3002\u5177\u4f53\u7684\u306b\u306f\u3001\u6b21\u306e3\u3064\u306e\u6a5f\u80fd\u3092\u6301\u3063\u3066\u3044\u307e\u3059\uff1a<\/p>\n<ol>\n<li><strong>\u7fa4\u9593\u306e\u7d2f\u7a4d\u767a\u751f\u95a2\u6570 (Cumulative Incidence Function; CIF) \u306e\u540c\u7b49\u6027\u306e\u6bd4\u8f03\u691c\u5b9a (Gray\u2019s test)<\/strong>: \u7570\u306a\u308b\u7fa4\u306e\u9593\u3067CIF\u306e\u540c\u7b49\u6027\u3092\u6bd4\u8f03\u3057\u307e\u3059\u3002<\/li>\n<li><strong>\u63a8\u5b9a\u3055\u308c\u305fCIF\u3092\u8868\u3068\u3057\u3066\u51fa\u529b\u3059\u308b\u6a5f\u80fd<\/strong>: \u7fa4\u3054\u3068\u306b\u63a8\u5b9a\u3055\u308c\u305fCIF\u3092\u8868\u5f62\u5f0f\u3067\u8868\u793a\u3057\u307e\u3059\u3002<\/li>\n<li><strong>\u63a8\u5b9a\u3055\u308c\u305fCIF\u3092\u30b0\u30e9\u30d5\u3068\u3057\u3066\u51fa\u529b\u3059\u308b\u6a5f\u80fd<\/strong>: \u7fa4\u3054\u3068\u306b\u63a8\u5b9a\u3055\u308c\u305fCIF\u3092\u30b0\u30e9\u30d5\u3067\u8996\u899a\u5316\u3057\u307e\u3059\u3002<\/li>\n<\/ol>\n<p>\u3053\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u3001Luca Scrucca\u6c0f\u306b\u3088\u308b{cmprsk}\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u57fa\u3065\u304f\u30e9\u30c3\u30d1\u30fc\u95a2\u6570\u3067\u3042\u308a\u3001\u8a73\u7d30\u306a\u89e3\u8aac\u306f\u672c\u4eba\u306e<a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"ac-anchor\" target=\"_blank\" is=\"cib-link\" appearance=\"system-link\" h=\"ID=SERP,5017.1\" rel=\"noopener\">\u30b5\u30a4\u30c8<\/a><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"tooltip-target\" data-citationid=\"68b0bcc5-69d2-1585-f12a-c2483cce9aa2-14-group\" h=\"ID=SERP,5017.1\">\u3067\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059<\/a><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"68b0bcc5-69d2-1585-f12a-c2483cce9aa2-14\" aria-label=\"1: \u30b5\u30a4\u30c8\" h=\"ID=SERP,5017.1\" rel=\"noopener\"><sup class=\"citation-sup\">1<\/sup><\/a>\u3002<\/p>\n<p>\u4f7f\u7528\u6cd5\u3068\u4e3b\u306a\u5f15\u6570\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\uff1a<\/p>\n<ul>\n<li><code>ftime<\/code>: \u751f\u5b58\u671f\u9593 (failure time variable)<\/li>\n<li><code>fstatus<\/code>: \u767a\u751f\u3057\u305f\u30a4\u30d9\u30f3\u30c8\u3092\u793a\u3059\u30b3\u30fc\u30c9 (variable with distinct codes for different causes of failure and also a distinct code for censored observations)<\/li>\n<li><code>group<\/code>: \u6bd4\u8f03\u3059\u308b\u7fa4\u3092\u6307\u5b9a\u3059\u308b\u30b3\u30fc\u30c9 (estimates will be calculated within groups given by distinct values of this variable)<\/li>\n<li><code>t<\/code>: CIF\u3092\u8a55\u4fa1\u3059\u308b\u6642\u70b9\u3092\u6307\u5b9a\u3059\u308b\u30d9\u30af\u30c8\u30eb (a vector of time points where the cumulative incidence function should be evaluated)<\/li>\n<li><code>strata<\/code>: \u5c64\u5225\u5316\u3057\u3066\u691c\u5b9a\u3092\u5b9f\u65bd\u3057\u305f\u3044\u5834\u5408\u306b\u6307\u5b9a\u3059\u308b\u3001\u5c64\u3092\u793a\u3059\u5909\u6570 (stratification variable)<\/li>\n<li>\u305d\u306e\u4ed6\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u5f15\u6570: <code>rho<\/code>, <code>cencode<\/code>, <code>subset<\/code>, <code>na.action<\/code>, <code>level<\/code>, <code>xlab<\/code>, <code>ylab<\/code>, <code>col<\/code>, <code>lty<\/code>, <code>lwd<\/code>, <code>digits<\/code> \u306a\u3069<\/li>\n<\/ul>\n<p><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"tooltip-target\" data-citationid=\"68b0bcc5-69d2-1585-f12a-c2483cce9aa2-45-group\" h=\"ID=SERP,5017.1\" target=\"_blank\" rel=\"noopener\">\u3053\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u3063\u3066\u3001\u7af6\u5408\u30ea\u30b9\u30af\u30a4\u30d9\u30f3\u30c8\u306e\u3042\u308b\u751f\u5b58\u6642\u9593\u30c7\u30fc\u30bf\u3092\u52b9\u679c\u7684\u306b\u5206\u6790\u3067\u304d\u307e\u3059<\/a><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"68b0bcc5-69d2-1585-f12a-c2483cce9aa2-41\" aria-label=\"1: \" h=\"ID=SERP,5017.1\" rel=\"noopener\"><sup class=\"citation-sup\"><\/sup><\/a><\/p>\n<h2>\u30b9\u30af\u30ea\u30d7\u30c8<\/h2>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">library(cmprsk)\r\n\r\n# Fits the \u2019proportional subdistribution hazards\u2019 regression model described in Fine and Gray (1999).\r\n# This model directly assesses the effect of covariates on the subdistribution of a particular type of\r\n# failure in a competing risks setting. The method implemented here is described in the paper as the\r\n# weighted estimating equation.\r\n# While the use of model formulas is not supported, the model.matrix function can be used to gener-\r\n#   ate suitable matrices of covariates from factors, eg model.matrix(~factor1+factor2)[,-1] will\r\n# generate the variables for the factor coding of the factors factor1 and factor2. The final [,-1]\r\n# removes the constant term from the output of model.matrix.\r\n# The basic model assumes the subdistribution with covariates z is a constant shift on the complemen-\r\n#   tary log log scale from a baseline subdistribution function. This can be generalized by including\r\n# interactions of z with functions of time to allow the magnitude of the shift to change with follow-up\r\n# time, through the cov2 and tfs arguments. For example, if z is a vector of covariate values, and uft is\r\n# a vector containing the unique failure times for failures of the type of interest (sorted in ascending\r\n#                                                                                    order), then the coefficients a, b and c in the quadratic (in time) model az + bzt + zt2 can be fit by\r\n# specifying cov1=z, cov2=cbind(z,z), tf=function(uft) cbind(uft,uft*uft).\r\n# This function uses an estimate of the survivor function of the censoring distribution to reweight\r\n# contributions to the risk sets for failures from competing causes. In a generalization of the method-\r\n#   ology in the paper, the censoring distribution can be estimated separately within strata defined by\r\n# the cengroup argument. If the censoring distribution is different within groups defined by covari-\r\n#   ates in the model, then validity of the method requires using separate estimates of the censoring\r\n# distribution within those groups.\r\n# The residuals returned are analogous to the Schoenfeld residuals in ordinary survival models. Plot-\r\n#   ting the jth column of res against the vector of unique failure times checks for lack of fit over time\r\n# in the corresponding covariate (column of cov1).\r\n# If variance=FALSE, then some of the functionality in summary.crr and print.crr will be lost.\r\n# This option can be useful in situations where crr is called repeatedly for point estimates, but standard\r\n# errors are not required, such as in some approaches to stepwise model selection.\r\n\r\n# simulated data to test\r\nset.seed(10)\r\nftime &lt;- rexp(200)\r\nfstatus &lt;- sample(0:2,200,replace=TRUE)\r\ncov &lt;- matrix(runif(600),nrow=200)\r\ndimnames(cov)[[2]] &lt;- c('x1','x2','x3')\r\nprint(z &lt;- crr(ftime,fstatus,cov))\r\nsummary(z)\r\nz.p &lt;- predict(z,rbind(c(.1,.5,.8),c(.1,.5,.2)))\r\nplot(z.p,lty=1,color=2:3)\r\ncrr(ftime,fstatus,cov,failcode=2)\r\n# quadratic in time for first cov\r\ncrr(ftime,fstatus,cov,cbind(cov[,1],cov[,1]),function(Uft) cbind(Uft,Uft^2))\r\n#additional examples in test.R\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u4e0b\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u6a5f\u80fd\u3068\u305d\u308c\u305e\u308c\u306e\u90e8\u5206\u306e\u8aac\u660e\u3092\u63d0\u4f9b\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li><strong>\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u8aad\u307f\u8fbc\u307f<\/strong>:\n<ul>\n<li><code>library(cmprsk)<\/code>: {cmprsk}\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u30b7\u30df\u30e5\u30ec\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306e\u4f5c\u6210<\/strong>:\n<ul>\n<li><code>set.seed(10)<\/code>: \u4e71\u6570\u751f\u6210\u306e\u30b7\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<li><code>ftime &lt;- rexp(200)<\/code>: 200\u500b\u306e\u6307\u6570\u5206\u5e03\u304b\u3089\u306a\u308b\u751f\u5b58\u6642\u9593\u30c7\u30fc\u30bf\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/li>\n<li><code>fstatus &lt;- sample(0:2,200,replace=TRUE)<\/code>: 200\u500b\u306e\u30e9\u30f3\u30c0\u30e0\u306a\u30a4\u30d9\u30f3\u30c8\u30b3\u30fc\u30c9\uff080, 1, 2\uff09\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/li>\n<li><code>cov &lt;- matrix(runif(600),nrow=200)<\/code>: 200\u884c3\u5217\u306e\u4e71\u6570\u884c\u5217\u3092\u751f\u6210\u3057\u307e\u3059\u3002<\/li>\n<li><code>dimnames(cov)[[2]] &lt;- c('x1','x2','x3')<\/code>: \u5217\u540d\u3092 \u2018x1\u2019, \u2018x2\u2019, \u2018x3\u2019 \u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>crr\u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u7af6\u5408\u30ea\u30b9\u30af\u30a4\u30d9\u30f3\u30c8\u306e\u3042\u308b\u751f\u5b58\u6642\u9593\u30c7\u30fc\u30bf\u3092\u5206\u6790<\/strong>:\n<ul>\n<li><code>z &lt;- crr(ftime,fstatus,cov)<\/code>: \u7fa4\u9593\u306e\u7d2f\u7a4d\u767a\u751f\u95a2\u6570\uff08CIF\uff09\u306e\u540c\u7b49\u6027\u3092\u6bd4\u8f03\u3057\u3001\u63a8\u5b9a\u3055\u308c\u305fCIF\u3092\u8868\u3068\u3057\u3066\u51fa\u529b\u3057\u307e\u3059\u3002<\/li>\n<li><code>summary(z)<\/code>: \u5206\u6790\u7d50\u679c\u306e\u30b5\u30de\u30ea\u30fc\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/li>\n<li><code>z.p &lt;- predict(z,rbind(c(.1,.5,.8),c(.1,.5,.2)))<\/code>: \u63a8\u5b9a\u3055\u308c\u305fCIF\u3092\u6307\u5b9a\u3057\u305f\u6642\u70b9\u3067\u8a08\u7b97\u3057\u3001\u7d50\u679c\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/li>\n<li><code>plot(z.p,lty=1,color=2:3)<\/code>: \u63a8\u5b9a\u3055\u308c\u305fCIF\u3092\u30b0\u30e9\u30d5\u3067\u8868\u793a\u3057\u307e\u3059\u3002<\/li>\n<li><code>crr(ftime,fstatus,cov,failcode=2)<\/code>: \u7279\u5b9a\u306e\u5931\u6557\u30b3\u30fc\u30c9\u3092\u6301\u3064\u30c7\u30fc\u30bf\u3092\u7528\u3044\u3066\u518d\u5ea6\u5206\u6790\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li>\n<li><code>crr(ftime,fstatus,cov,cbind(cov[,1],cov[,1]),function(Uft) cbind(Uft,Uft^2))<\/code>: \u6700\u521d\u306e\u5171\u5909\u91cf\u306b\u5bfe\u3057\u3066\u6642\u9593\u306e2\u6b21\u9805\u3092\u8003\u616e\u3057\u305f\u5206\u6790\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u8ffd\u52a0\u306e\u4f8b<\/strong>:\n<ul>\n<li><code>test.R<\/code>\u30d5\u30a1\u30a4\u30eb\u306b\u3055\u3089\u306a\u308b\u4f8b\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"tooltip-target\" data-citationid=\"42e455be-acd5-c14c-b718-08fca8be921f-50-group\" h=\"ID=SERP,5017.1\" target=\"_blank\" rel=\"noopener\">\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u3001\u7af6\u5408\u30ea\u30b9\u30af\u30a4\u30d9\u30f3\u30c8\u306e\u3042\u308b\u751f\u5b58\u6642\u9593\u30c7\u30fc\u30bf\u306e\u89e3\u6790\u306b\u5f79\u7acb\u3061\u307e\u3059\u3002\u8a73\u7d30\u306a\u4f7f\u3044\u65b9\u3084\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8abf\u6574\u306b\u3064\u3044\u3066\u306f\u3001{cmprsk}\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3084\u89e3\u8aac\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 <\/a><a href=\"https:\/\/clover.fcg.world\/2017\/03\/27\/8207\/\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"42e455be-acd5-c14c-b718-08fca8be921f-46\" aria-label=\"1: \" h=\"ID=SERP,5017.1\" rel=\"noopener\"><sup class=\"citation-sup\">1<\/sup><\/a><a href=\"https:\/\/rbasics.org\/guides\/how-to-use-the-cmprsk-package-in-r\/\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"42e455be-acd5-c14c-b718-08fca8be921f-48\" aria-label=\"2: \" h=\"ID=SERP,5017.1\" rel=\"noopener\"><sup class=\"citation-sup\">2<\/sup><\/a><a href=\"https:\/\/www.rdocumentation.org\/packages\/cmprsk\/versions\/2.2-11\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"42e455be-acd5-c14c-b718-08fca8be921f-50\" aria-label=\"3: \" h=\"ID=SERP,5017.1\" rel=\"noopener\"><sup class=\"citation-sup\">3<\/sup><\/a>\u3002<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># \u5b9f\u884c\u7d50\u679c\r\n&gt; print(z &lt;- crr(ftime,fstatus,cov))\r\nconvergence:  TRUE \r\ncoefficients:\r\n      x1       x2       x3 \r\n 0.26680 -0.05568  0.28050 \r\nstandard errors:\r\n[1] 0.4211 0.3812 0.3810\r\ntwo-sided p-values:\r\n  x1   x2   x3 \r\n0.53 0.88 0.46 \r\n&gt; summary(z)\r\nCompeting Risks Regression\r\n\r\nCall:\r\ncrr(ftime = ftime, fstatus = fstatus, cov1 = cov)\r\n\r\n      coef exp(coef) se(coef)      z p-value\r\nx1  0.2668     1.306    0.421  0.633    0.53\r\nx2 -0.0557     0.946    0.381 -0.146    0.88\r\nx3  0.2805     1.324    0.381  0.736    0.46\r\n\r\n   exp(coef) exp(-coef)  2.5% 97.5%\r\nx1     1.306      0.766 0.572  2.98\r\nx2     0.946      1.057 0.448  2.00\r\nx3     1.324      0.755 0.627  2.79\r\n\r\nNum. cases = 200\r\nPseudo Log-likelihood = -320 \r\nPseudo likelihood ratio test = 1.02  on 3 df,\r\n&gt; z.p &lt;- predict(z,rbind(c(.1,.5,.8),c(.1,.5,.2)))\r\n&gt; plot(z.p,lty=1,color=2:3)\r\n&gt; crr(ftime,fstatus,cov,failcode=2)\r\nconvergence:  TRUE \r\ncoefficients:\r\n      x1       x2       x3 \r\n-0.31390 -0.03488 -0.52500 \r\nstandard errors:\r\n[1] 0.4517 0.4475 0.4675\r\ntwo-sided p-values:\r\n  x1   x2   x3 \r\n0.49 0.94 0.26 \r\n&gt; # quadratic in time for first cov\r\n&gt; crr(ftime,fstatus,cov,cbind(cov[,1],cov[,1]),function(Uft) cbind(Uft,Uft^2))\r\nconvergence:  TRUE \r\ncoefficients:\r\n                            x1                             x2                             x3 \r\n                       2.16500                       -0.06664                        0.27490 \r\ncbind(cov[, 1], cov[, 1])1*Uft cbind(cov[, 1], cov[, 1])2*tf2 \r\n                      -3.25200                        0.81900 \r\nstandard errors:\r\n[1] 0.9464 0.3797 0.3854 1.2590 0.2925\r\ntwo-sided p-values:\r\n                            x1                             x2                             x3 \r\n                        0.0220                         0.8600                         0.4800 \r\ncbind(cov[, 1], cov[, 1])1*Uft cbind(cov[, 1], cov[, 1])2*tf2 \r\n                        0.0098                         0.0051<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10.jpeg\" alt=\"\" width=\"958\" height=\"555\" class=\"aligncenter size-full wp-image-3452\" srcset=\"https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10.jpeg 958w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10-300x174.jpeg 300w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10-700x406.jpeg 700w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10-150x87.jpeg 150w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10-768x445.jpeg 768w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10-500x290.jpeg 500w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot10-800x463.jpeg 800w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/><\/p>\n<p>\u6b21\u306b\u3001R\u306e <code>cmprsk<\/code> \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u4f7f\u7528\u3057\u3066\u3001\u7af6\u5408\u30ea\u30b9\u30af\uff08competing risks\uff09\u306e\u7d2f\u7a4d\u767a\u751f\u7387\u3092\u6bd4\u8f03\u3059\u308b\u305f\u3081\u306e\u89e3\u6790\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">############################\r\nset.seed(2)\r\nss &lt;- rexp(100)\r\ngg &lt;- factor(sample(1:3,100,replace=TRUE),1:3,c('a','b','c'))\r\ncc &lt;- sample(0:2,100,replace=TRUE)\r\nstrt &lt;- sample(1:2,100,replace=TRUE)\r\nprint(xx &lt;- cuminc(ss,cc,gg,strt))\r\nplot(xx,lty=1,color=1:6)\r\n# see also test.R, test.out<\/pre>\n<div class=\"ac-textBlock\">\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001\u6b21\u306e\u624b\u9806\u3092\u5b9f\u884c\u3057\u3066\u3044\u307e\u3059\uff1a<\/p>\n<ol>\n<li>\u30c7\u30fc\u30bf\u306e\u751f\u6210:\n<ul>\n<li><code>set.seed(2)<\/code> \u3067\u4e71\u6570\u306e\u30b7\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<li><code>rexp(100)<\/code> \u3067\u6307\u6570\u5206\u5e03\u306b\u5f93\u3046\u30e9\u30f3\u30c0\u30e0\u306a\u30a4\u30d9\u30f3\u30c8\u6642\u9593\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<li><code>sample(1:3, 100, replace=TRUE)<\/code> \u3067\u30e9\u30f3\u30c0\u30e0\u306a\u30a4\u30d9\u30f3\u30c8\u306e\u72b6\u614b\uff083\u3064\u306e\u30b0\u30eb\u30fc\u30d7 \u2018a\u2019, \u2018b\u2019, \u2018c\u2019\uff09\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<li><code>sample(0:2, 100, replace=TRUE)<\/code> \u3067\u30e9\u30f3\u30c0\u30e0\u306a\u691c\u95b2\u72b6\u614b\uff080, 1, 2\uff09\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<li><code>sample(1:2, 100, replace=TRUE)<\/code> \u3067\u30e9\u30f3\u30c0\u30e0\u306a\u958b\u59cb\u6642\u70b9\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li><code>cuminc<\/code> \u95a2\u6570\u306e\u5b9f\u884c:\n<ul>\n<li><code>cuminc(ss, cc, gg, strt)<\/code> \u3067\u7af6\u5408\u30ea\u30b9\u30af\u306e\u7d2f\u7a4d\u767a\u751f\u7387\u3092\u8a08\u7b97\u3057\u3066\u3044\u307e\u3059\u3002<code>ss<\/code> \u306f\u30a4\u30d9\u30f3\u30c8\u6642\u9593\u3001<code>cc<\/code> \u306f\u30a4\u30d9\u30f3\u30c8\u306e\u72b6\u614b\u3001<code>gg<\/code> \u306f\u30b0\u30eb\u30fc\u30d7\u3001<code>strt<\/code> \u306f\u958b\u59cb\u6642\u70b9\u3067\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u7d50\u679c\u306e\u8868\u793a:\n<ul>\n<li><code>print(xx)<\/code> \u3067\u8a08\u7b97\u3055\u308c\u305f\u7d2f\u7a4d\u767a\u751f\u7387\u3092\u8868\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u30b0\u30e9\u30d5\u306e\u63cf\u753b:\n<ul>\n<li><code>plot(xx, lty=1, color=1:6)<\/code> \u3067\u7d2f\u7a4d\u767a\u751f\u7387\u306e\u30b0\u30e9\u30d5\u3092\u63cf\u753b\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>############################<br \/>\nset.seed(2)<br \/>\nss &lt;- rexp(100)<br \/>\ngg &lt;- factor(sample(1:3,100,replace=TRUE),1:3,c(&#8216;a&#8217;,&#8217;b&#8217;,&#8217;c&#8217;))<br \/>\ncc &lt;- sample(0:2,100,replace=TRUE)<br \/>\nstrt &lt;- sample(1:2,100,replace=TRUE)<br \/>\nprint(xx &lt;- cuminc(ss,cc,gg,strt))<br \/>\nplot(xx,lty=1,color=1:6)<br \/>\n# see also test.R, test.out<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">############################\r\nset.seed(2)\r\nss &lt;- rexp(100)\r\ngg &lt;- factor(sample(1:3,100,replace=TRUE),1:3,c('a','b','c'))\r\ncc &lt;- sample(0:2,100,replace=TRUE)\r\nstrt &lt;- sample(1:2,100,replace=TRUE)\r\nprint(xx &lt;- cuminc(ss,cc,gg,strt))\r\nplot(xx,lty=1,color=1:6)\r\n# see also test.R, test.out<\/pre>\n<p><a href=\"https:\/\/cran.r-project.org\/web\/\/packages\/cmprsk\/cmprsk.pdf\" class=\"tooltip-target\" data-citationid=\"51658361-94ce-4f0e-3b52-89ea33b0d4b4-41-group\" h=\"ID=SERP,5028.1\" target=\"_blank\" rel=\"noopener\">\u3053\u306e\u30b3\u30fc\u30c9\u306f\u3001\u7af6\u5408\u30ea\u30b9\u30af\u306e\u89e3\u6790\u306b\u304a\u3044\u3066\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u7d2f\u7a4d\u767a\u751f\u7387\u3092\u6bd4\u8f03\u3059\u308b\u305f\u3081\u306e\u6709\u7528\u306a\u624b\u6cd5\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<\/a><a href=\"https:\/\/cran.r-project.org\/web\/\/packages\/cmprsk\/cmprsk.pdf\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"51658361-94ce-4f0e-3b52-89ea33b0d4b4-39\" aria-label=\"1: \" h=\"ID=SERP,5028.1\" rel=\"noopener\"><sup class=\"citation-sup\">1<\/sup><\/a><a href=\"https:\/\/www.rdocumentation.org\/packages\/cmprsk\/versions\/2.2-11\/topics\/cuminc\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"51658361-94ce-4f0e-3b52-89ea33b0d4b4-41\" aria-label=\"2: \" h=\"ID=SERP,5028.1\" rel=\"noopener\"><sup class=\"citation-sup\">2<\/sup><\/a><\/p>\n<p><a href=\"https:\/\/cran.r-project.org\/web\/\/packages\/cmprsk\/cmprsk.pdf\" class=\"tooltip-target\" data-citationid=\"51658361-94ce-4f0e-3b52-89ea33b0d4b4-45-group\" h=\"ID=SERP,5028.1\">\u8a73\u7d30\u306b\u3064\u3044\u3066\u306f\u3001\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u3054\u53c2\u7167\u304f\u3060\u3055\u3044\uff1a<\/a><a href=\"https:\/\/cran.r-project.org\/web\/\/packages\/cmprsk\/cmprsk.pdf\" class=\"ac-anchor\" target=\"_blank\" is=\"cib-link\" appearance=\"system-link\" h=\"ID=SERP,5028.1\" rel=\"noopener\">cmprsk \u30d1\u30c3\u30b1\u30fc\u30b8<\/a><a href=\"https:\/\/cran.r-project.org\/web\/\/packages\/cmprsk\/cmprsk.pdf\" class=\"ac-anchor sup-target\" target=\"_blank\" data-citationid=\"51658361-94ce-4f0e-3b52-89ea33b0d4b4-45\" aria-label=\"1: cmprsk \u30d1\u30c3\u30b1\u30fc\u30b8\" h=\"ID=SERP,5028.1\" rel=\"noopener\"><sup class=\"citation-sup\">1<\/sup><\/a>\u3002<\/p>\n<\/div>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&gt; print(xx &lt;- cuminc(ss,cc,gg,strt))\r\nTests:\r\n      stat        pv df\r\n1 1.598854 0.4495865  2\r\n2 3.390543 0.1835493  2\r\nEstimates and Variances:\r\n$est\r\n             1         2         3         4\r\na 1 0.27262599 0.3216446 0.3216446 0.3216446\r\nb 1 0.08877315 0.3423257 0.3423257 0.3423257\r\nc 1 0.23368736 0.4312495 0.4879272 0.4879272\r\na 2 0.38424403 0.5607109 0.5607109 0.5607109\r\nb 2 0.31463271 0.4786961 0.5234407 0.5234407\r\nc 2 0.20127996 0.3420399 0.3420399 0.3420399\r\n\r\n$var\r\n              1           2           3           4\r\na 1 0.008596053 0.009950848 0.009950848 0.009950848\r\nb 1 0.002491270 0.009675072 0.009675072 0.009675072\r\nc 1 0.006341967 0.011566190 0.012617195 0.012617195\r\na 2 0.010293273 0.022358101 0.022358101 0.022358101\r\nb 2 0.007220502 0.010014466 0.010588994 0.010588994\r\nc 2 0.005699657 0.010260038 0.010260038 0.010260038\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11.jpeg\" alt=\"\" width=\"958\" height=\"555\" class=\"aligncenter size-full wp-image-3456\" srcset=\"https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11.jpeg 958w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-300x174.jpeg 300w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-700x406.jpeg 700w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-150x87.jpeg 150w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-768x445.jpeg 768w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-500x290.jpeg 500w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-800x463.jpeg 800w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/> <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1.jpeg\" alt=\"\" width=\"958\" height=\"555\" class=\"aligncenter size-full wp-image-3457\" srcset=\"https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1.jpeg 958w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1-300x174.jpeg 300w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1-700x406.jpeg 700w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1-150x87.jpeg 150w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1-768x445.jpeg 768w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1-500x290.jpeg 500w, https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/Rplot11-1-800x463.jpeg 800w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CMPRSK\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306f {cmprsk} \u306f\u3001\u7af6\u5408\u30ea\u30b9\u30af\u30a4\u30d9\u30f3\u30c8\u306e\u3042\u308b\u751f\u5b58\u6642\u9593\u5206\u6790\u3092\u5b9f\u65bd\u3059\u308b\u305f\u3081\u306eR\u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u30591\u3002\u5177\u4f53\u7684\u306b\u306f\u3001\u6b21\u306e3\u3064\u306e\u6a5f\u80fd\u3092\u6301\u3063\u3066\u3044\u307e\u3059\uff1a \u7fa4\u9593\u306e\u7d2f\u7a4d\u767a\u751f\u95a2\u6570 (Cumulative Incid&#8230;<\/p>\n","protected":false},"author":1,"featured_media":3450,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-3449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-miscellaneous"],"jetpack_featured_media_url":"https:\/\/plaza.umin.ac.jp\/~OIO\/wp-content\/uploads\/2024\/03\/cat3.jpg","jetpack_shortlink":"https:\/\/wp.me\/p9b6zl-TD","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=\/wp\/v2\/posts\/3449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3449"}],"version-history":[{"count":0,"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=\/wp\/v2\/posts\/3449\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=\/wp\/v2\/media\/3450"}],"wp:attachment":[{"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/plaza.umin.ac.jp\/~OIO\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}