# 論文を書く際の統計的表現について

0.05未満は<0.05でよいのですか？

・・・

このように聞かれたり、議論になったりすることがあるので、纏めておきます。

あくまで、一例ですが、Annals of Internal Medicine (IF 17)の投稿規定は以下のようになっています。

p値は0.001より小さい場合は、<0.001、0.001-0.20は有効数字3桁、0.20より大きい場合で2桁、と書かれています。

Reporting guideline

##Percentages

Report percentages to one decimal place (i.e., xx.x%) when sample size is =200.

To avoid the appearance of a level of precision that is not present with small samples, do not use decimal places (i.e., xx%, not xx.xx%) when sample size is < 200.

##Standard deviations

Use “mean (SD)” rather than “mean ± SD” notation. The ± symbol is ambiguous and can represent standard deviation or standard error.

##Standard errors

Report confidence intervals, rather than standard errors, when possible.

##P values

For P values between 0.001 and 0.20, please report the value to the nearest thousandth. For P values greater than 0.20, please report the value to the nearest hundredth. For P values less than 0.001, report as “P<0.001.”

##“Trend”

Use the word trend when describing a test for trend or dose-response.

Avoid the term trend when referring to P values near but not below 0.05. In such instances, simply report a difference and the confidence interval of the difference (if appropriate) with or without the P value.

##Statistical software

Specify in the statistical analysis section the statistical software—version, manufacturer, and the specific functions, procedures, or programs—used for analyses.

##Cox models

When reporting findings from Cox proportional hazards models:

Do not describe hazard ratios as relative risks.
Do report how the assumption of proportional hazards was tested, and what the test showed.

##Descriptive tables

In tables that simply describe the characteristics of 2 or more groups (e.g., Table 1 of a clinical trial):

Report averages with standard deviations, not standard errors, when data are normally distributed.
Report median (minimum, maximum) or median (25th, 75th percentile [interquartile range, or IQR] when data are not normally distributed.
Avoid reporting P values as there can be imbalance when P values are not significant (because of small sample size) and balance when P values are significant (because of large sample size).

##Tables reporting multivariable analyses

Authors sometimes present tables that compare one by one an outcome with multiple individual factors followed by a multivariable analysis that adjusts for confounding. If confounding is present, as is often the case, the one-way comparisons are simply intermediate steps that offer little useful information for the reader. In general, omit presenting these intermediate steps in the manuscript and do not focus on them in the Results or Discussion.

##Figures

When developing informative graphics, follow these simple rules of thumb:
Avoid pie charts.
Avoid simple bar plots that do not present measures of variability.
For meta-analysis forest plots, provide the raw data (numerators and denominators) in the margins.
For survival plots, provide the numbers of people at risk by group and time below the horizontal axis.


# Rを使って時系列データの変化点をみつける: changepoint

Rにchangepointというパッケージがあるので、実装してみる。

• １つのchangepointはdefaultのmethod = AMOCで良い。

• 複数のchangepointであれば、methodでPELT, SegNeighやBinSegを指定すれば良い。

#install.packages("changepoint")
library(changepoint)

# change in variance
x=c(rnorm(100,0,3),rnorm(100,0,10))
res1=cpt.var(x, )
plot(res1)
print(res1)

# change in mean
y=c(rnorm(100,0,1),rnorm(100,7,1))
res2=cpt.mean(y)
plot(res2,cpt.col='blue')
print(res2)

# change in mean and variance
z=c(rnorm(100,0,1),rnorm(100,3,7))
res3=cpt.meanvar(z)
plot(res3,cpt.width=3)
print(res3)

# change in mean and variance, multiple changepoints
w=c(rnorm(100,0,1),rnorm(100,3,7), rnorm(100,-5,1))
res4=cpt.meanvar(w, Q=2, method = "PELT")
plot(res4)
print(res4)

# 計量経済分析ことはじめ~時系列データを正しく扱う~

Rによる計量経済分析を読んだ。このシリーズはとても勉強になる。

キーワードと、キーとなるパッケージ・関数を列挙しておく。

## クロスセクションデータの回帰分析

BLUE (the best linear unbiased estimator)

### 不均一分散

1. Breusch-Pagan 検定

2. White 検定

3. Goldfeld-Quandt 検定: データを2分割して、それらを同じモデルを回帰した場合に誤差項の分散が等しくなるかどうかを検定

bptest(), gqtest()の説明書を見ながら、以下を実行。

library(lmtest)

## generate a regressor
x <- rep(c(-10,10), 100)

## generate heteroskedastic and homoskedastic disturbances
err1 <- rnorm(100, sd=rep(c(1,2), 50))
err2 <- rnorm(100)

## generate a linear relationship
y1 <- 1 + x + err1
y2 <- 1 + x + err2

## perform studentized Breusch-Pagan test
bptest(y1 ~ x)
bptest(y2 ~ x)

## perform Breusch-Pagan test
bptest(y1 ~ x, studentize = F) #studentize is a logical number
bptest(y2 ~ x, studentize = F)

## perform Goldfeld-Quandt test
gqtest(y1 ~ x, point=0.5) #point is interpreated to be a breakpoint.
gqtest(y2 ~ x, point=0.5)


## 時系列データの回帰分析

### 系列相関

#### 系列相関の検定

1. Durbin-Watson検定
2. Breusch-Godfrey検定
library(lmtest)
## perform Durbin-Watson test
dwtest(y1 ~ x)

## perform Breusch-Godfrey test for first-order serial correlation:
bgtest(y1 ~ x)
## or for fourth-order serial correlation
bgtest(y1 ~ x, order = 4)

#### 系列相関がある場合の推定

#FGLSを用いる方法
library(nlme)
res <- gls(y1~x, corr=corARMA(p=1))
summary(res)

#Newey-Westの修正を行う
library(sandwich)
coeftest(lm(y1~x), vcov=NeweyWest)

## Stationary time series analysis (定常時系列分析)

independent and identically distributed; IID

モデル化には、自己回帰と移動平均を考慮して考える。

1. Autoregressive model （自己回帰）: p次のAR modelはAR(p)と記述される。

2. Moving average model （移動平均

3. Autoregressive moving average model （自己回帰移動平均

4. Autoregressive integrated moving average model （自己回帰和分移動平均

## ARCHとGARCH

1. (Generalized) autoregressive conditional heteroskedasticity model

GARCH(1,1)でモデリングしたいときは以下。

library(fGarch)
GARCH <- garchFit(formula = ~ garch(1, 1), data = data,
trace = FALSE, include.mean =TRUE)
summary(GARCH)

## 多変量時系列

### VAR vector autoregressive model

#### 定常過程かどうか

library(tseries)
pp.test(data)

#### モデルの次数決定

library(vars)
VARselect(data, lag.max=5, type="const")
vars.res <- VAR(data, p=1, type="const")
summary(vars.res)
causality(vars.res, cause="A")
causality(vars.res, cause="B")

## 非定常時系列

library(tseries)
pp.test(data) #Phillips-Perron

library(urca)
ca.po(data) #Philips-Ouliaris
ca.jo(data) #Johansen

## パネル

fixed effectとrandom effectの推定結果の検定: Hausman検定

library(plm)
phtest(res.fixed, res.random)

# Rの基礎とプログラミング技法

Rの基礎とプログラミング技法に、Rを効率よく扱うコツについて非常にわかりやすく載っていたので、トライしてみた。

## 第5章：効率的なプログラミング

### apply

1. applyは、 ベクトル単位で処理できる
2. lapplyはリストやデータフレームごと処理できる
3. sapplyはlapplyの簡易版（返ってくるのはlistではなくベクトル）
4. mapplyは多変量に適用できる
5. tapplyはクロス集計表を作成できる
#apply

x<-matrix(c(1:9), nr=3)
apply(x,1,mean) #第二の引数は次元、ここでは行。2だと列。

#lapply, sapply

data(anscombe)
attach(anscombe)
ans.reg<-vector(4, mode="list")

for(i in 1:4){
x<-get(paste("x", i, sep=""))
y<-get(paste("y", i, sep=""))
ans.reg[[i]] <- lm(y~x)
}

lapply(ans.reg, coef) #データフレーム、リスト、ベクトルなどの構造に、coef()関数を適用
sapply(ans.reg, coef) #sはsimplifyであり、返されるのはベクトル

lapply(ans.reg, "[", 1) #このようにも[]を関数としても使える。

#mapply

mapply(sum, 1:10, 2:11, 3) #多変量に同じ処理が出来るが、一つ目の引数が関数となる。

#tapply

data(iris)
attach(iris)
tapply(Sepal.Width, Species, mean)

data(iris)
attach(iris)
tapply(Sepal.Length, Species, range)

### 効率性を分析する

proc.time() #Rを起動してからの経過時間を出力する
system.time() #式の実行時間を出力する

Rprof() #コレ以降の実行時間を分析開始
Rprof(NULL) #これまでで終了
summaryRprof() #summary表示

gc() #R実行中のメモリの消費状況を調べるには、gc()を使う。其の点で使われていないメモリ領域が解放される。

さらに詳しい分析は、proftools packageなどが使える。

## バッチ処理（第9章：拡張）

R CMD BATCH xxxx.r output.txt


# 分散分析

この東京大学出版会シリーズ、赤の統計学入門、緑の人文・社会科学の統計学と並んで、よく纏まっています。

あくまで、数式は使わずに言葉で纏めておきます。

## 一元配置分散分析

１つの要因への従属変数への影響を分析する（3グループ以上でも可能）。

http://elsur.jpn.org/resource/anova.pdf

1. 平方和を分解
2. 平均平方を算出
3. 検討したい要因についてF（変動部分と誤差部分の二つの分散比）を求め、帰無仮説の棄却の有無を判断

これらのばらつきが有意に差があるなら、「平均値には差がある」という判断ができる。

## 多元配置分散分析

この場合に、要因間の交互作用（interaction）を考慮する必要がある。

http://www.u.tsukuba.ac.jp/~hirai.akiyo.ft/forstudents/eigokyouikugaku7.files/2013_5_28.pdf

# 投稿先あれこれ

## NEJM

Please include a title for your submission. The title should contain no more than eight words. No more than two authors may be listed. Please provide the name, highest academic degree, address, e-mail address, telephone number, and fax number of each author. The legend should contain no more than 150 words.

http://www.nejm.org/page/author-center/images-in-clinical-medicine

## JAMA

"What Would You Do Next?" with 4 single-phrase plausible treatment options describing possible courses of action with 1 being preferred Case presentation: 250 words Discussion: 500-600 words ≤10 references ≤3 authors 1-2 small figures Patient permission may be needed

Instructions for Authors | JAMA | The JAMA Network

## Gastroenterology

Clinical Challenges and Images in GI (See full information about article types here) This article type is presented as an unknown with the diagnosis hinging on the correct interpretation and integration of the image and clinical data. Submissions must adhere to the following guidelines: Manuscript: only Microsoft Word documents will be accepted. Title Page: title (cannot reveal diagnosis); authors' names (limit of three); authors' institutions; corresponding author contact information; conflict of interest statement (for all authors). Word Count: Q&A format (one page each). Abstract: not required. Tables/Figures: no limit. Please submit figures as separate attachments in JPEG, TIFF, EPS, or PDF formats (300 PPI resolution). Each figure should be labeled with letters only (i.e., no subpanels). All necessary information pertaining to figures must be included in the text (i.e., no figure legends). The inclusion of three or more images will qualify the submission for online-only publication. References: limited to three.

## Clinical Gastroenterology and Hepatology

Image of the Month Image of the Month presents a striking clinical image(s) that is meant to challenge and inform the reader. Although priority will be given to exceptionally unique submissions, and those that are not similar to recently published cases; authors should be encouraged to present quality images of more commonly encountered diseases and conditions. All submissions should contain no more than four (4) color or black and white images of 300 dpi resolution. Images should be accompanied by a Word document containing a brief description of no more than 200 words. The text should succinctly present relevant clinical information, including a short description of the patient's history, relevant findings, clinical course, response to treatment, and condition at last follow-up. No more than three authors are allowed on each submission. Contributors must provide their names, addresses, phone, and e-mail addresses.

http://www.cghjournal.org/content/authorinfo

## Canadian Medical Association Journal

Clinical images Images are chosen because they are particularly intriguing, classic or dramatic. Preference is given to common presentations of important rare conditions and important unusual presentations of common problems. Structure: 300 word limit; up to two authors; up to three references formatted in the Vancouver style figure and case pertaining to a real patient; clear, appropriately labelled, high-resolution images must be accompanied by a figure caption A brief case description is followed by a concise explanation of the educational significance of the images that typically includes epidemiology, differential diagnosis, investigations, management and prognosis For examples, see Clinical images

Canadian Medical Association Journal: Submission guidelines

## Cleveland Clinic Journal of Medicine

http://www.mdedge.com/ccjm/page/clinical-picture

## Netherland Journal of Medicine

Photo quiz A photo quiz should not exceed 500 words and include no more than two figures and four references conform the Vancouver style. Abbreviations of measurements should be quoted in SI units.

## QJM（Quarterly Journal of Medicine）

Clinical pictures should be no more than 500 words. Ideally, we suggest 200-300 words. Only one figure file is allowed for the image. The selected figure file may contain two images (labelled figure 1a and 1b). Clinical pictures should have six references or fewer. The patient's consent is required for photographs of the patient. Consent should be in the form of a letter (written by author or patient) and must be signed by the patient.

Instructions to Authors | QJM: An International Journal of Medicine | Oxford Academic

## Journal of General Internal Medicine

Clinical images report on visual findings in clinical medicine that have educational value. They can include radiology results, high quality clinical images, or electrocardiograms. Images should have a text description that does not exceed 200 words. No more than three authors may be listed. In the initial submission (for clinical images ONLY), each image should be sent as a separate file with the submitted text.

https://jgimed.org/authors/JGIM%20Instructions%20for%20Authors.pdf

## European Journal of Internal Medicine

Internal Medicine Flashcards Please see Introducing the "Internal Medicine Flashcards": Call for papers Volume 24, Issue 6, published online only. Authors: maximum 3 Image: one, single or multi-paneled. Only original, high-quality images will be considered for publication, provided they do not contain material that has been submitted or published elsewhere. If a photo of an identifiable patient is used, a specific release form must be completed and signed by the patient and enclosed to the submission. All the printed information that might identify the patient or the authors' institution (including but not limited to the hospital or patient name, date or place) should be removed from the images Main section (case description): maximum 175 words Discussion section: maximum 225 words + maximum 3 references

Guide for authors - European Journal of Internal Medicine - ISSN 0953-6205

http://www.ejinme.com/article/S0953-6205(13)00206-9/fulltext

## Internal Medicine

Pictures in Clinical Medicine Images depicting an instructive case, a novel finding and/or element of current interest for clinical medicine. The manuscript text should not exceed 150 words with up to 2 references. The picture legend should not be contained. The title should be concise and contain up to 8 words and there should be no more than 4 pictures. Only 4 authors may be listed.

Instructions to Authors｜Internal Medicine

# macでzipをlockする

macでzipをlockする方法について覚書。

terminalでzipcloak ＜zipファイル名＞を入力し、passを入れるだけ。以下を参考にしました。