【R】jstable

1. はじめに

jstableは、‘GLM’, ‘GEE’, ‘GLMM’, ‘Cox’のRegression tableを表示してくれるパッケージです。

2. インストール

CRANからインストールできます。

install.packages("jstable")

3. つかってみる

まずは、GLMのRegression tableです。

library(jstable)
library(modeldata)

data("penguins")

head(penguins)

glm_gaus <- glm(body_mass_g~flipper_length_mm + bill_length_mm, data = penguins)
glmshow.display(glm_gaus, decimal = 3)
$first.line
[1] "Linear regression predicting body_mass_g\n"

$table
                  crude coeff.(95%CI)      crude P value adj. coeff.(95%CI)       adj. P value
flipper_length_mm "49.686 (46.709,52.662)" "< 0.001"     "48.145 (44.203,52.087)" "< 0.001"   
bill_length_mm    "87.415 (74.867,99.963)" "< 0.001"     "6.047 (-4.105,16.2)"    "0.2438"    

$last.lines
[1] "No. of observations = 342\nR-squared = 0.75996\nAIC value = 5063.48249\n\n"

attr(,"class")
[1] "display" "list"  

GEE tableの例です。

library(geepack)  
data(dietox)
dietox$Cu <- as.factor(dietox$Cu)
dietox$ddn <- as.numeric(rnorm(nrow(dietox)) > 0)
head(dietox)
gee01 <- geeglm (Weight ~ Time + Evit , id = Pig, data = dietox, family = gaussian, corstr = "ex")
geeglm.display(gee01)
> head(dietox)
   Pig    Evit    Cu Litter Start   Weight      Feed Time ddn
1 4601 Evit000 Cu000      1  26.5 26.50000        NA    1   0
2 4601 Evit000 Cu000      1  26.5 27.59999  5.200005    2   0
3 4601 Evit000 Cu000      1  26.5 36.50000 17.600000    3   1
4 4601 Evit000 Cu000      1  26.5 40.29999 28.500000    4   0
5 4601 Evit000 Cu000      1  26.5 49.09998 45.200001    5   0
6 4601 Evit000 Cu000      1  26.5 55.39999 56.900002    6   0
> geeglm.display(gee01)
$caption
[1] "GEE(gaussian) predicting Weight by Time, Evit - Group Pig"

$table
                   crude coeff(95%CI)  crude P value adj. coeff(95%CI)    adj. P value
Time               "6.94 (6.79,7.1)"   "< 0.001"     "6.94 (6.79,7.1)"    "< 0.001"   
Evit: ref.=Evit000 NA                  NA            NA                   NA          
      100          "1.81 (-1.93,5.56)" "0.343"       "2.03 (-1.65,5.7)"   "0.28"      
      200          "-1.3 (-4.97,2.38)" "0.489"       "-1.17 (-4.83,2.49)" "0.531"     

$metric
                                 crude coeff(95%CI) crude P value adj. coeff(95%CI) adj. P value
                                 NA                 NA            NA                NA          
Estimated correlation parameters "0.771"            NA            NA                NA          
No. of clusters                  "72"               NA            NA                NA          
No. of observations              "861"              NA            NA                NA   

4. さいごに

いろいろ機能があるようですが、今日はここまで。

Add a Comment

メールアドレスが公開されることはありません。