Skip to content

Commit

Permalink
created
Browse files Browse the repository at this point in the history
  • Loading branch information
genkuroki committed Sep 2, 2024
1 parent 8cc6b1d commit 96e2c37
Show file tree
Hide file tree
Showing 3 changed files with 629 additions and 0 deletions.
101 changes: 101 additions & 0 deletions 0050/epiR epi.2by2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# formats: ipynb,R:hydrogen
# text_representation:
# extension: .R
# format_name: hydrogen
# format_version: '1.3'
# jupytext_version: 1.10.3
# kernelspec:
# display_name: R
# language: R
# name: ir
# ---

# %%
.Table <- matrix(c(15, 13, 5, 15), 2, 2, byrow=TRUE)
print(.Table)

# epiR で分析
analysis <- epiR::epi.2by2(
dat = .Table,
method = "cross.sectional",
digits = 3,
conf.level = 0.95,
units = 1,
outcome = "as.columns"
)

# Wald法
rr_result <- analysis$massoc.detail$PR.strata.wald
cat("\nWald RR:\n")
print(rr_result)

# スコア法
rr_result <- analysis$massoc.detail$PR.strata.score
cat("\nScore RR:\n")
print(rr_result)

# %%
(15/(15+13))/(5/(5+15))

# %%
(15/(15+5))/(13/(13+15))

# %%
.Table <- matrix(c(15, 13, 5, 15), 2, 2, byrow=TRUE)

# epiR で分析
analysis <- epiR::epi.2by2(
dat = .Table,
method = "cross.sectional",
digits = 3,
conf.level = 0.95,
units = 1,
outcome = "as.columns"
)
print(analysis)

# Wald法
rr_result <- analysis$massoc.detail$PR.strata.wald
cat("\nWald RR:\n")
print(rr_result)

# スコア法
rr_result <- analysis$massoc.detail$PR.strata.score
cat("\nScore RR:\n")
print(rr_result)

# %%
str(analysis)

# %%
.Table <- matrix(c(15, 13, 5, 15), 2, 2, byrow=FALSE)

# epiR で分析
analysis <- epiR::epi.2by2(
dat = .Table,
method = "cross.sectional",
digits = 3,
conf.level = 0.95,
units = 1,
outcome = "as.columns"
)
print(analysis)

# Wald法
rr_result <- analysis$massoc.detail$PR.strata.wald
cat("\nWald RR:\n")
print(rr_result)

# スコア法
rr_result <- analysis$massoc.detail$PR.strata.score
cat("\nScore RR:\n")
print(rr_result)

# %%
str(analysis)

# %%
Loading

0 comments on commit 96e2c37

Please sign in to comment.