{"id":107,"date":"2023-04-30T20:37:17","date_gmt":"2023-04-30T11:37:17","guid":{"rendered":"https:\/\/best-biostatistics.com\/toukei-er\/?p=107"},"modified":"2025-02-17T22:28:40","modified_gmt":"2025-02-17T13:28:40","slug":"how-to-draw-a-forest-plot-for-subgroup-analysis-results-in-r","status":"publish","type":"post","link":"https:\/\/best-biostatistics.com\/toukei-er\/entry\/how-to-draw-a-forest-plot-for-subgroup-analysis-results-in-r\/","title":{"rendered":"R \u3067\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3067\u66f8\u304f\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3067\u66f8\u304f\u65b9\u6cd5\u306f\u3044\u304f\u3064\u304b\u3042\u308b\u304c\u3001\u3053\u3053\u3067\u306f\u3001R \u30b9\u30af\u30ea\u30d7\u30c8\u4e2d\u5fc3\u306b\u66f8\u304f\u65b9\u6cd5\u3092\u89e3\u8aac\u3059\u308b<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">EZR \u306e\u6a5f\u80fd\u3092\u4f7f\u3046\u65b9\u6cd5<\/h2>\n\n\n\n<p>R \u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u65b9\u6cd5\u306e\u524d\u306b\u3001EZR \u306e\u30e1\u30cb\u30e5\u30fc\u3092\u3044\u308d\u3044\u308d\u99c6\u4f7f\u3057\u3066\u66f8\u304f\u65b9\u6cd5\u306e\u8a18\u4e8b\u3092\u3054\u7d39\u4ecb<\/p>\n\n\n<div class=\"swell-block-postLink\">\t\t\t<div class=\"p-blogCard -internal\" data-type=\"type1\" data-onclick=\"clickLink\">\n\t\t\t\t<div class=\"p-blogCard__inner\">\n\t\t\t\t\t<span class=\"p-blogCard__caption\">\u3042\u308f\u305b\u3066\u8aad\u307f\u305f\u3044<\/span>\n\t\t\t\t\t<div class=\"p-blogCard__thumb c-postThumb\"><figure class=\"c-postThumb__figure\"><img decoding=\"async\" src=\"https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2022\/09\/20220913212218-300x104.png\" alt=\"\" class=\"c-postThumb__img u-obf-cover\" width=\"320\" height=\"180\"><\/figure><\/div>\t\t\t\t\t<div class=\"p-blogCard__body\">\n\t\t\t\t\t\t<a class=\"p-blogCard__title\" href=\"https:\/\/best-biostatistics.com\/toukei-er\/entry\/how-to-draw-forest-plot-for-subgroup-analysis-in-ezr\/\">\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3067\u63cf\u304f\u65b9\u6cd5<\/a>\n\t\t\t\t\t\t<span class=\"p-blogCard__excerpt\">\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3067\u66f8\u304f\u65b9\u6cd5\u3002 \u30ed\u30b8\u30b9\u30c6\u30a3\u30c3\u30af\u56de\u5e30\u306e\u5834\u5408\u3067\u3001EZR \u3067\u884c\u3046\u65b9\u6cd5\u3002 Version 1.62\uff082023 \u5e74 11 \u6708 1 \u65e5\u516c\u958b\uff09\u304b\u3089\u3001EZR \u672c\u4f53\u306b\u7d44&#8230;<\/span>\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t<\/div>\n\n\n<p>EZR \u306b\u306a\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u3053\u3061\u3089\u306e\u307b\u3046\u304c\u3088\u3044\u304b\u3082\u3057\u308c\u306a\u3044<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">R \u30b9\u30af\u30ea\u30d7\u30c8\u3067\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u7d50\u679c\u3092\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3067\u66f8\u304f\u65b9\u6cd5<\/h2>\n\n\n\n<p>R \u30b9\u30af\u30ea\u30d7\u30c8\u3067\u66f8\u304f\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9f\u884c\u3059\u308b<\/p>\n\n\n\n<p>3 \u30b9\u30c6\u30c3\u30d7\u306b\u5206\u3051\u3066\u8aac\u660e\u3059\u308b<\/p>\n\n\n\n<p>\u3053\u3053\u3067\u306f\u3001<a href=\"https:\/\/amzn.to\/4gFbL9z\" data-type=\"link\" data-id=\"https:\/\/amzn.to\/4gFbL9z\">EZR \u516c\u5f0f\u30de\u30cb\u30e5\u30a2\u30eb<\/a>\u4ed8\u5c5e\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u6d3b\u7528\u3057\u3066\u3001Cox \u56de\u5e30\u306e\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u3092\u884c\u3046<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u7d50\u679c\u306e\u524d\u306b\u5168\u4f53\u89e3\u6790\u7d50\u679c\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u683c\u7d0d\u3059\u308b<\/h3>\n\n\n\n<p>\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u683c\u7d0d\u3057\u3066\u3044\u304f\u306e\u3060\u304c\u3001\u305d\u306e\u524d\u306b\u3001\u5168\u4f53\u89e3\u6790\u306e\u7d50\u679c\u306e\u5bfe\u6570\u30cf\u30b6\u30fc\u30c9\u6bd4 logHR \u3068\u6a19\u6e96\u8aa4\u5dee SE \u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u683c\u7d0d\u3059\u308b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span class=\"synComment\"># Forest plot of subgroup analysis<\/span>\n<span class=\"synComment\"># \u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306e\u89e3\u6790\u3092\u884c\u3044\u7d50\u679c\u3092 df \u306b\u683c\u7d0d\u3059\u308b<\/span>\nload(\"ElderlyAML_rev.RData\")\nlibrary(survival)\ndf &lt;- data.frame()\nres &lt;- coxph(Surv(Days,Survival)~Anthracyclines, data=ElderlyAML)\nlogHR &lt;- summary(res)$coef&#91;1]\nSE &lt;- summary(res)$coef&#91;3]\nGR &lt;- 'ALL'\nres1 &lt;- data.frame(GR, logHR, SE)\ndf &lt;- rbind(df,res1)\ndf<\/code><\/pre>\n\n\n\n<p>\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0 df \u306e\u5148\u982d\u884c\u306b ALL \u306e\u7d50\u679c\u3092\u683c\u7d0d\u3057\u305f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> df\n   GR      logHR        SE\n1 ALL -0.9215332 0.3455331<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u683c\u7d0d\u3059\u308b<\/h3>\n\n\n\n<p>\u6b21\u306b\u3001\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u683c\u7d0d\u3059\u308b<\/p>\n\n\n\n<p>variables \u306b\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u3092\u884c\u3046\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u30c7\u30fc\u30bf\u306e\u5909\u6570\u540d\u30d9\u30af\u30c8\u30eb\u3092\u683c\u7d0d\u3057\u3066\u3001\u4f7f\u7528\u3059\u308b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>variables &lt;- c('Sex.Dummy.F', 'PS2', 'LDH250', 'Cre15', 'CRP1', 'WBC30000', 'Age70', 'Plt2')\nfor (variable in variables){\n  res &lt;- coxph(Surv(Days,Survival) ~ Anthracyclines, data = ElderlyAML, subset = get(variable) == 0)\n  logHR &lt;- summary(res)$coef&#91;1]\n  SE &lt;- summary(res)$coef&#91;3]\n  GR &lt;- paste(variable, \"=0\", sep=\"\")\n  res1 &lt;- data.frame(GR, logHR, SE)\n  df &lt;- rbind(df, res1)\n  res &lt;- coxph(Surv(Days,Survival) ~ Anthracyclines, data = ElderlyAML, subset = get(variable) == 1)\n  logHR &lt;- summary(res)$coef&#91;1]\n  SE &lt;- summary(res)$coef&#91;3]\n  GR &lt;- paste(variable, \"=1\", sep=\"\")\n  res1 &lt;- data.frame(GR, logHR, SE)\n  df &lt;- rbind(df, res1)\n}\ndf<\/code><\/pre>\n\n\n\n<p>variables \u306e\u4e00\u3064\u4e00\u3064\u306e\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u30c7\u30fc\u30bf\u306e 0 \u306e\u3068\u304d\u306e\u7d50\u679c\u3068\u30011 \u306e\u3068\u304d\u306e\u7d50\u679c\u3092\u9806\u756a\u306b\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306b\u683c\u7d0d\u3057\u3066\u3044\u308b<\/p>\n\n\n\n<p>\u3067\u304d\u3042\u304c\u308a\u306f\u3001\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3067\u3042\u308b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>> df\n              GR      logHR        SE\n1            ALL -0.9215332 0.3455331\n2  Sex.Dummy.F=0 -0.8433599 0.4774421\n3  Sex.Dummy.F=1 -1.0185934 0.5133041\n4          PS2=0 -0.9211330 0.3780901\n5          PS2=1 -0.5377643 0.8248212\n6       LDH250=0 -1.7529075 0.8527541\n7       LDH250=1 -0.7791516 0.3971939\n8        Cre15=0 -0.8331148 0.3816948\n9        Cre15=1 -1.3697384 1.1391895\n10        CRP1=0 -1.0266389 0.5534791\n11        CRP1=1 -0.8795466 0.4542963\n12    WBC30000=0 -1.0448020 0.4100158\n13    WBC30000=1 -0.6614039 0.6758000\n14       Age70=0 -1.4822192 0.5713317\n15       Age70=1 -0.2119710 0.4554232\n16        Plt2=0 -1.0395092 0.3858093\n17        Plt2=1 -0.7244348 0.9243423<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30e1\u30bf\u30a2\u30ca\u30ea\u30b7\u30b9\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u95a2\u6570\u3092\u501f\u308a\u3066\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3092\u66f8\u304f<\/h3>\n\n\n\n<p>\u30e1\u30bf\u30a2\u30ca\u30ea\u30b7\u30b9\u30d1\u30c3\u30b1\u30fc\u30b8\u306e meta \u306b\u3042\u308b\u3001metagen \u95a2\u6570\u3068 forest \u95a2\u6570\u3092\u501f\u308a\u3066\u3001\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3092\u66f8\u304f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u30e1\u30bf\u30a2\u30ca\u30ea\u30b7\u30b9\u306e\u95a2\u6570\u3092\u501f\u308a\u3066\u3001\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3092\u66f8\u304f\n<span class=\"synPreProc\">library(<\/span>meta<span class=\"synSpecial\">)<\/span>\nmetagen.res <span class=\"synStatement\">&lt;-<\/span> <span class=\"synIdentifier\">metagen(<\/span>TE<span class=\"synStatement\">=<\/span>logHR<span class=\"synSpecial\">,<\/span> seTE<span class=\"synStatement\">=<\/span>SE<span class=\"synSpecial\">,<\/span> studlab<span class=\"synStatement\">=<\/span>GR<span class=\"synSpecial\">,<\/span> data<span class=\"synStatement\">=<\/span>df<span class=\"synSpecial\">,<\/span> sm<span class=\"synStatement\">='HR',<\/span> common<span class=\"synStatement\">=FALSE,<\/span> random<span class=\"synStatement\">=FALSE)<\/span>\n<span class=\"synIdentifier\">forest(<\/span>metagen.res<span class=\"synSpecial\">)<\/span><\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001\u30e1\u30bf\u30a2\u30ca\u30ea\u30b7\u30b9\u306e\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3068\u540c\u69d8\u306e\u30b0\u30e9\u30d5\u304c\u3001\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u7d50\u679c\u3068\u3057\u3066\u4e26\u3093\u3067\u66f8\u304b\u308c\u308b<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"674\" src=\"https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2023\/04\/forest_plot_for_subgroup-1024x674.png\" alt=\"\" class=\"wp-image-3513\" srcset=\"https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2023\/04\/forest_plot_for_subgroup-1024x674.png 1024w, https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2023\/04\/forest_plot_for_subgroup-300x197.png 300w, https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2023\/04\/forest_plot_for_subgroup-768x505.png 768w, https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2023\/04\/forest_plot_for_subgroup-1536x1011.png 1536w, https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2023\/04\/forest_plot_for_subgroup.png 1790w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div id=\"biost-1037310093\" class=\"biost- biost-entity-placement\"><p style=\"text-align: center;\"><span style=\"font-size: 20px;\"><strong><a href=\"https:\/\/best-biostatistics.com\/kmhl\">\uff1e\uff1e\u3082\u3046\u7d71\u8a08\u3067\u60a9\u3080\u306e\u306f\u7d42\u308f\u308a\u306b\u3057\u307e\u305b\u3093\u304b\uff1f\u00a0<\/a><\/strong><\/span><\/p>\r\n<a href=\"https:\/\/best-biostatistics.com\/kmhl\"><img class=\"aligncenter wp-image-2794 size-full\" src=\"https:\/\/best-biostatistics.com\/wp\/wp-content\/uploads\/2023\/11\/bn_r_03.png\" alt=\"\" width=\"500\" height=\"327\" \/><\/a>\r\n<p style=\"text-align: center;\"><span style=\"color: #ff0000; font-size: 20px;\"><strong><span class=\"marker2\">\u21911\u4e07\u4eba\u4ee5\u4e0a\u306e\u533b\u7642\u5f93\u4e8b\u8005\u304c\u8cfc\u8aad\u4e2d<\/span><\/strong><\/span><\/p><\/div><h2 class=\"wp-block-heading\"><span itemscope=\"\" itemtype=\"http:\/\/schema.org\/Photograph\"><\/span>\u307e\u3068\u3081<\/h2>\n\n\n\n<p>R \u3067\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u7d50\u679c\u3092\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3067\u66f8\u304f\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u305f<\/p>\n\n\n\n<p>R \u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001\u4e8c\u5024\u306e\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u30c7\u30fc\u30bf\u306b\u3088\u308b\u8907\u6570\u306e\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u3092\u3001for \u6587\u3067\u4e00\u6c17\u306b\u8a08\u7b97\u3057\u3066\u3001\u6700\u5f8c\u306b metagen \u3068 forest \u3067\u66f8\u304f\u3068\u3044\u3046\u6d41\u308c\u3067\u3042\u308b<\/p>\n\n\n\n<p>\u53c2\u8003\u306b\u306a\u308c\u3070<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30b5\u30d6\u30b0\u30eb\u30fc\u30d7\u89e3\u6790\u306e\u7d50\u679c\u3092\u30d5\u30a9\u30ec\u30b9\u30c8\u30d7\u30ed\u30c3\u30c8\u3067\u66f8\u304f\u65b9\u6cd5\u306f\u3044\u304f\u3064\u304b\u3042\u308b\u304c\u3001\u3053\u3053\u3067\u306f\u3001R \u30b9\u30af\u30ea\u30d7\u30c8\u4e2d\u5fc3\u306b\u66f8\u304f\u65b9\u6cd5\u3092\u89e3\u8aac\u3059\u308b<\/p>\n","protected":false},"author":2,"featured_media":3513,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,37,71,72],"tags":[],"class_list":["post-107","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r","category-37","category-71","category-72"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/best-biostatistics.com\/toukei-er\/wp-content\/uploads\/2023\/04\/forest_plot_for_subgroup.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":2,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":3514,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/posts\/107\/revisions\/3514"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/media\/3513"}],"wp:attachment":[{"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/best-biostatistics.com\/toukei-er\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}