0

「pimp your forest plot」を使用して、素敵なグラフを作成しています。http://www.r-bloggers.com/pimping-your-forest-plot/

このチュートリアルでは、2 か国のデータを組み合わせてサブグループの効果を確認しながら、適切なフォレスト プロットを作成する方法について説明します。スウェーデンはひし形など、各国はグラフ上で独自の特徴的な形をしています。そのため、各国のサブグループ効果を簡単に見つけることができます。

ただし、3 つの dfs (3 つの国) をマージしようとすると問題が発生します。各サブグループで国ごとに個別の形状を保持する代わりに (2 つの国を結合する場合のグラフを参照)、3 つの国をまとめると、性別の形状はすべて円形になり、年齢の形状はすべて正方形になります。代わりに、各国の性別/年齢の影響を表す丸、ひし形、四角があるはずです。

ここで私が間違っていることを誰かが知っていますか? 私は自分の手順をたどり、一度に1つのdfを追加して、少なくとも自分が間違っていることを確認できるようにしました:しかし、それは私には来ていません.

ここにある「pimp your forest plot」からいくつかの dfs をコピーしました。これらのグラフのすべての功績は Max Gordon にあります。ここでの例のために、「finland」という偽の 3 番目の df を作成しました。

sweden1
             coef       lower       upper
    Males vs Female          0.04088551  0.03483956  0.04693145
    85 vs 65 years          -0.05515741 -0.06508088 -0.04523394
    Charlsons Medium vs Low -0.03833060 -0.04727946 -0.02938173

denmark1
                               coef        lower       upper
Males vs Female          0.03462842  0.003494374 0.065762462
85 vs 65 years          -0.03682791 -0.083367305 0.009711488
Charlsons Medium vs Low -0.04335537 -0.090336663 0.003625929

 finland1
                          coef  lower  upper
Males vs Female          0.061  0.043  0.087
85 vs 65 years          -0.080 -0.120 -0.020
Charlsons Medium vs Low -0.050 -0.075 -0.025

2 つの国で森林プロットを作成するには: 参照されている Web サイトの Max Gordon のコードを使用します。

library(forestplot)
forestplot(mean=cbind(sweden1[,"coef"], denmark1[,"coef"]), 
            lower=cbind(sweden1[,"lower"], denmark1[,"lower"]), 
            upper=cbind(sweden1[,"upper"], denmark1[,"upper"]), 
            labeltext=rownames(Sweden),
            legend=c("Sweden", "Denmark"), 
            legend.pos=list(x=0.8,y=.4),
            legend.gp = gpar(col="#AAAAAA"), 
            legend.r=unit(.1, "snpc"),
            clip=c(-.2, .2), 
            xticks=c(-.2, -.1, .0, .1, .2),
            boxsize=0.3,
            col=fpColors(box=c("blue", "darkred")),
            # Set the different functions
            confintNormalFn=c("fpDrawDiamondCI", "fpDrawCircleCI"),
            xlab="EQ-5D index",
            new_page=TRUE)

このコードを使用してフィンランドを追加しましたが、形状がグループに忠実ではないことがわかります。

forestplot(mean=cbind(sweden1[,"coef"], denmark1[,"coef"],finland1[,"coef"]), 
            lower=cbind(sweden1[,"lower"], denmark1[,"lower"],finland1[,"lower"]), 
            upper=cbind(sweden1[,"upper"], denmark1[,"upper"],finland1[,"upper"]), 
            labeltext=rownames(sweden1),
            legend=c("Sweden", "Denmark", "finland1"), 
            # Added the clip argument as some of 
            # the Danish CI are way out therer
            #clip=c(-.2, .2), 
            # Getting the ticks auto-generate is 
            # a nightmare - it is usually better to 
            # specify them on your own
           # xticks=c(-.2, -.1, .0, .1, .2),
            boxsize=0.3,
            col=fpColors(box=c("blue", "darkred", "green")),
           confintNormalFn=c("fpDrawCircleCI",  "fpDrawNormalCI","fpDrawDiamondCI"),
            xlab="EQ-5D index",
            new_page=TRUE)

前もって感謝します。

編集

sweden1 <- structure(c(0.0408855062954068, -0.0551574080806885, -0.0383305964199184, 
0.0348395599810297, -0.0650808763059716, -0.0472794647337126, 
0.046931452609784, -0.0452339398554054, -0.0293817281061242), .Dim = c(3L, 
3L), .Dimnames = list(c("Males vs Female", "85 vs 65 years", 
"Charlsons Medium vs Low"), c("coef", "lower", "upper")))

denmark1 <- structure(c(0.0346284183072541, -0.0368279085760325, -0.0433553672510346, 
0.00349437418972517, -0.0833673052667752, -0.0903366633240568, 
0.065762462424783, 0.00971148811471034, 0.00362592882198759), .Dim = c(3L, 
3L), .Dimnames = list(c("Males vs Female", "85 vs 65 years", 
"Charlsons Medium vs Low"), c("coef", "lower", "upper")))

finland1 <- structure(c(0.061, -0.08, -0.05, 0.043, -0.12, -0.075, 0.087, 
-0.02, -0.025), .Dim = c(3L, 3L), .Dimnames = list(c("Males vs Female", 
"85 vs 65 years", "Charlsons Medium vs Low"), c("coef", "lower", 
"upper")))
4

1 に答える 1