PDFにページ数を挿入する場合
PDFにページ数を挿入する場合
PDFのファイル名はNo1,No2,No3の三枚
同じフォルダに入れる
\documentclass[uplatex,11pt]{jsarticle} \usepackage[top=15truemm,bottom=15truemm,left=15truemm,right=15truemm]{geometry} %余白 %図 \usepackage[dvipdfmx]{graphicx} %図の位置調整 改行後に[H] \usepackage{here} % 章が進むごとに図番号をリセットする \makeatletter% プリアンブルで定義開始 \renewcommand{\thefigure}{\arabic{figure}} \@addtoreset{figure}{section} \makeatother % プリアンブルで定義終了 %図とキャプションを狭くする \setlength\abovecaptionskip{5pt} %---------------------------------------------------% \begin{document} %---------- 1 ----------% \begin{figure}[H] %現在の位置に \centering \includegraphics[width=17cm]{No1.pdf} %図の挿入 \end{figure} %---------- 2 ----------% \newpage \begin{figure}[H] %現在の位置に \centering \includegraphics[width=17cm]{No2.pdf} %図の挿入 \end{figure} %---------- 3 ----------% \newpage \begin{figure}[H] %現在の位置に \centering \includegraphics[width=17cm]{No3.pdf} %図の挿入 \end{figure} \end{document}
層別した散布図と回帰直線
以下のサイトに移転しました
表1の作り方 "tableone"
下記のサイトに移転いたしました
if関数 層別カテゴリー化した変数を追加
下記のサイトに移転いたしました
よろしくお願いいたします
y2pt.com
並べ替え検定と正規近似
2017-07-11投稿, 2019.7.4更新
正確なp値
特定の確率分布をもとに推定を行うのではなく、母集団の未知のパラメータやサンプリング誤差が入らないため計算上も正しいp値が得られる.
並べ替え検定
例)x群とy群を比較します
x <- c(5, 9) #平均 = 7 y <- c(6, 12, 14, 16) #平均 = 12
xとyは同じ母集団からのサンプリングと考えます.それぞれのグループへの割付の際にたまたま差が生じました.なおxとyは正規分布には従いません.
帰無仮説:xとyに差はない
対立仮説:xよりyが大きい
並べ替え検定の考え方
もしが正しいと考えるとき、このサンプリングの平均差がどの程度大きいのかを考えます.( 5 , 6 , 9 , 12 , 14 , 16 ) がマークされている、6個の同質の玉が袋に入っていると考えます.
帰無仮説は、どのように取り出してもx(2個)とy(4個)が示す増加量が等しいということになります.
取り出し方は、
choose (6, 2)
の15通りあります.帰無仮説が正しいとすると、15通り全てが「xとyは等しい」ということになります.
xの平均は7、yの平均は12なので、y-x=5となります.つまり15通り中、差が平均の差5より大きくなる確率を正確なp値として考えます.
差が5以上になるのは2通りなので、片側検定のp値は2/15 =0.1333333 、両側検定のp値は 4/15 = 0.2666667 となります.
Rでは以下のような計算式になります
Package ‘coin’, March 8, 2019, Version 1.3-0, Date 2019-03-04より
https://cran.r-project.org/web/packages/coin/coin.pdf
#サンプルデータセット diffusion <- data.frame( pd = c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46, 1.15, 0.88, 0.90, 0.74, 1.21), age = factor(rep(c("At term", "12-26 Weeks"), c(10, 5))) ) # ソート (sortlist <- order(diffusion$pd)) ( diffusion <- diffusion[sortlist,] ) diffusion$no <- c(1:15);diffusion #セット > diffusion pd age no 9 0.73 At term 1 14 0.74 12-26 Weeks 2 1 0.80 At term 3 2 0.83 At term 4 12 0.88 12-26 Weeks 5 13 0.90 12-26 Weeks 6 4 1.04 At term 7 11 1.15 12-26 Weeks 8 15 1.21 12-26 Weeks 9 6 1.38 At term 10 5 1.45 At term 11 10 1.46 At term 12 8 1.64 At term 13 3 1.89 At term 14 7 1.91 At term 15
Rのパッケージ"coin"を使って検定します
#install.packages("coin") library(coin) #正確なP値を求めます:並び替え検定、Exact Wilcoxon-Mann-Whitney test (wt <- wilcox_test(pd ~ age, data = diffusion, distribution = "exact", conf.int = TRUE)) Exact Wilcoxon-Mann-Whitney Test data: pd by age (12-26 Weeks, At term) Z = -1.2247, p-value = 0.2544 alternative hypothesis: true mu is not equal to 0 95 percent confidence interval: -0.76 0.15 sample estimates: difference in location -0.305
期待値や分散など
statistic(wt, type = "linear")# sum of the ranks for age = "12-26 Weeks" 12-26 Weeks 30 expectation(wt)# 平均順位の差の期待値 12-26 Weeks 40 covariance(wt)# 平均順位の差の分散 12-26 Weeks 12-26 Weeks 66.66667 pvalue(wt) [1] 0.2544123 confint(wt) 95 percent confidence interval: -0.76 0.15 sample estimates: difference in location -0.305
Mann-Whitney の U 検定, wilcoxonの順位和検定(Wilcoxon rank-sum test)
正規近似を行って検定する方法.なお,この正規近似は m,n が 7 より大きければかなり正確であることも示されている.
ノンパラメトリック検定
(wt2 <- wilcox_test(pd ~ age, data = diffusion, conf.int = TRUE)) Asymptotic Wilcoxon-Mann-Whitney Test data: pd by age (12-26 Weeks, At term) Z = -1.2247, p-value = 0.2207 alternative hypothesis: true mu is not equal to 0 95 percent confidence interval: -0.7599742 0.1499702 sample estimates: difference in location -0.3038399
コンピュータの発達により、並べ替え検定や正確確率検定を行うのは無理ではなくなったので、わざわざp値の近似値を求める従来のパラメトリック検定やノンパラメトリック検定よりも、直観的かつ、わかりやすい結果が得られるといえるだろう. 水本 篤(2010)より引用
参考
柳川 堯 , 荒木 由布子; バイオ統計の基礎―医薬統計入門,近代科学社 ,2010,p162-164
水本 篤:統計数理研究所共同研究リポート 238『言語コーパス分析における数理データの統計的処理手法の検討』(2010) pp. 1–14