win.metafile() emf Microsoft PowerPoint OpenOffice.org Draw 2 R CRAN R (2004) [ ](2004) (2005) The R Tips R The R Tips R 6

Size: px
Start display at page:

Download "win.metafile() emf Microsoft PowerPoint OpenOffice.org Draw 2 R CRAN R (2004) [ ](2004) (2005) The R Tips R The R Tips R 6"

Transcription

1 R nminato@med.gunma-u.ac.jp 1 R R GNU General Public License Version 2 1 GIS 2 R Fisher iris Gehan MASS Windows gehan Windows Macintosh Linux FreeBSD R CDC EPIINFO EPIINFO Windows R R SPSS R 3 R S test.r source("test.r") R R Commander Rcmdr pdf postscript png jpeg Windows (emf) emf Windows R 1 LGPL (Lesser GNU General Public License) Version CRAN ( CRAN R built-in base, datasets, grdevices, graphics, grid, methods, splines, stats, stats4, tcltk, tools, utils Recommended built-in KernSmooth, MASS, boot, class, cluster, foreign, lattice, mgcv, nlme, nnet, rpart, spatial, survival Windows library(survival) require(survival) search().packages(all.avail=t) detach(package:survival) Nature R Morris RJ, Lewis OT, Godfray HCJ: Experimental evidence for apparent competition in a tropical forest food web. Nature 428: ,

2 win.metafile() emf Microsoft PowerPoint OpenOffice.org Draw 2 R CRAN R (2004) [ ](2004) (2005) The R Tips R The R Tips R 6 RjpWiki 7 R 2 R Windows Linux Mac OS X \ Rgui R 8.Rprofile.RData > > R + R Source source( ) Windows / \\ R bin Windows 2000/XP R R R 2.1 R 4 ftp://ftp.u-aizu.ac.jp/pub/lang/r/cran/ (S) R_USER.Renviron R_USER="c:/work" proxy Windows proxy --internet2 2

3 > q() R 9 X x " NA comment(x)<-"test" > x <- 7 > x [1] 7 > comment(x) <- " " > x [1] 7 > comment(x) [1] " " > 6 -> x > x [1] 6 > comment(x) NULL > names(x) <- " " > x 6 > x[1] <- 4 > x 4 > z <<- 5 # R html pdf Html t t.test() > help(t.test); #?t.test Fisher fisher.test(stats) Fihser 9 3

4 > help.search("fisher") R > example(barplot) R c() : > x <- c(2,7,11:19) > x [1] R function() list() > x <- 2 > z <- function(a) { x <<- x+a } > print(z(5)) [1] 7 > x [1] 7 > meansd <- function(x) {list(mean=mean(x),sd=sd(x))} > meansd(c(1,5,8)) $mean [1] $sd [1] CRAN CRAN > options(repos=" R.Rprofile install.packages(" ") vcd dep=t dependency TRUE > install.packages("vcd",dep=t) 4

5 2.2 R factor character ordered numeric integer logical data.frame list ts matrix vector data.frame numeric double single C Fortran complex dat$c <- as.factor(dat$c) dat$s <- as.character(dat$s) dat$i <- as.ordered(dat$i) dat$x <- as.numeric(dat$x) str(dat) names(dat) R 155 cm 160 cm 170 cm c(155,160,170) seq() rep() mean(dat) sd(dat) cm 50 kg A 160 cm 55 kg B 170 cm 70kg C data.frame(ht=c(155,160,170),wt=c(50,55,70)) $ attach() attach() detach() > dat <- c(155,160,170) > dat2 <- seq(155,170,by=5) > dat3 <- rep(160,3) > mean(dat) [1] > sd(dat) [1] > dat4 <- data.frame(ht=c(155,160,170),wt=c(50,55,70)) > dat4$ht [1] > attach(dat4) > wt [1] > detach(dat4)

6 dat > dat <- matrix(c(20,12,10,18),nc=2) > rownames(dat) <- c(, ) > colnames(dat) <- c(, ) 2 3 matrix() 1 2 nc=2 2 1 chisq.test(dat) ID (cm) (kg) Microsoft Excel OpenOffice.org 11 calc PID, HT, WT Microsoft Excel (F) (T) (*.txt) xls (S) OK Excel R R sample.txt R dat <- read.delim("sample.txt") dat R de() 11 Microsoft Office 12 Windows Excel calc R dat <- read.delim("clipboard") 6

7 > attach(dat) > cor.test(ht,wt) > detach(dat) 3.3 (NA) R NA Excel 13 Excel R dat 1 datc > datc <- subset(dat,complete.cases(dat),drop=t) (recovery rate) 80% 80/100) (effective recovery rate) 75% 75/100 80% 3.4 Microsoft Access Oracle postgresql PHP4 Apache httpd 14 Tcl/Tk R RODBC R Dbase Oracle postgresql

8 4 R 4.1 ID (cm) (kg) M F M M F F F M F M 45 1 PID, HT, WT, SEX, AGE R sample.txt > dat <- read.delim("sample.txt") dat c() matrix nc=5 5 1 byrow=t as.data.frame() colnames() 1 Factor M read.delim() > dat <- as.data.frame(matrix(c( + 1, 170, 70, 1, 54, + 2, 162, 50, 2, 34, + 3, 166, 72, 1, 62, + 4, 170, 75, 1, 41, + 5, 164, 55, 2, 37, + 6, 159, 62, 2, 55, + 7, 168, 80, 2, 67, + 8, 183, 78, 1, 47, + 9, 157, 47, 2, 49, + 10, 185, 100, 1, 45),nc=5,byrow=T)) + colnames(dat) <- c( PID, HT, WT, SEX, AGE ) > dat$sex <- as.factor(dat$sex) > levels(dat$sex) <- c( M, F ) data.frame() 8

9 4.2 R [ ] > attach(dat) > mean(ht[sex== M ]) [1] > detach(dat) [dat$sex== M ] > cnms <- function(x,c) { list(n=nrow(x[c]),mean=mean(x[c]),sd=sd(x[c])) } N mean sd cnms() > attach(dat) > cnms(ht,sex== M ) $N [1] 5 $mean [1] $sd [1] > detach(dat) == is.na() 40! > attach(dat) > overforty <- AGE>=40 > cnms(ht,overforty) $N [1] 8 $mean [1] $sd [1] > detach(dat) & 40 9

10 > attach(dat) > males <- SEX== M > cnms(wt,overforty&males) $N [1] 5 $mean [1] 79 $sd [1] > detach(dat) [ ] 4.3 R tapply() > attach(dat) > tapply(ht,sex,mean) M F > detach(dat) 5 TFR PowerPoint OpenOffice.org Impress PowerPoint 16 OpenOffice.org Draw Adobe Illustrator 10

11 (2005) (ISBN ) X R barplot(table(x)) M ± table(x) c() names() barplot() OpenOffice.org Draw 17 table() 11

12 > ob <- c(4,1,2,12,97) > names(ob) <- c("+++","++","+"," ","-") > barplot(ob,ylim=c(0,100),main=" \n ") 2 barplot() > ob <- c(4,1,2,12,97) > names(ob) <- c("+++","++","+"," ","-") > ii <- barplot(matrix(ob,nrow(ob)),beside=f,ylim=c(0,120), + main=" ") > oc <- ob > for (i in 1:length(ob)) { oc[i] <- sum(ob[1:i])-ob[i]/2 } > text(ii,oc,paste(names(ob))) ± ± 7 50 R > obm <- c(0,0,1,5,47) > obf <- c(4,1,1,7,50) > obx <- cbind(obm,obf) > rownames(obx) <- c("+++","++","+"," ","-") > colnames(obx) <- c(" "," ") > ii <- barplot(obx,beside=f,ylim=c(0,70),main=" ") > oc <- obx > for (i in 1:length(obx[,1])) { oc[i,1] <- sum(obx[1:i,1])-obx[i,1]/2 } > for (i in 1:length(obx[,2])) { oc[i,2] <- sum(obx[1:i,2])-obx[i,2]/2 } > text(ii[1],oc[,1],paste(rownames(obx))) > text(ii[2],oc[,2],paste(rownames(obx))) 12

13 100% R 2 (%) 4 horiz=t > ob <- c(4,1,2,12,97) > obp <- ob/sum(ob)*100 > names(obp) <- c("+++","++","+"," ","-") > ii <- barplot(matrix(obp,nrow(obp)),horiz=t,beside=f,xlim=c(0,100), + xlab="(%)",main=" ") > oc <- obp > for (i in 1:length(obp)) { oc[i] <- sum(obp[1:i])-obp[i]/2 } > text(oc,ii,paste(names(obp))) barplot() dotchart() 13

14 > obm <- c(0,0,1,5,47) > obf <- c(4,1,1,7,50) > obx <- cbind(obm,obf) > rownames(obx) <- c("+++","++","+"," ","-") > colnames(obx) <- c(" "," ") > dotchart(obx) > dotchart(t(obx)) 100% 18 R pie() 19 R > ob <- c(4,1,2,12,97) > names(ob) <- c("+++","++","+"," ","-") > pie(ob) 5.2 Excel R hist() Cleveland Cleveland WS (1985) The elements of graphing data. Wadsworth, Monterey, CA, USA. p.264 R help 19 R-1.5 piechart()

15 > attach(dat) > hist(ht,main=" ") > detach(dat) qqnorm() qqline() > qqnorm(dat$ht,main=" ",ylab=" (cm)") > qqline(dat$ht,lty=2) stem and leaf plot 5 10 R stem() > stem(dat$ht) box and whisker plot boxplot (median) 1/4 (first quartile) 1/4 (third quartile) 1.5 R boxplot() > boxplot(dat$ht) R stripchart() vert=t > attach(dat) > mht <- tapply(ht,sex,mean) > sht <- tapply(ht,sex,sd) > IS <- c(1,2)+0.15 > stripchart(ht~sex,method="jitter",vert=t,ylab=" (cm)") > points(is,mht,pch=18) > arrows(is,mht-sht,is,mht+sht,code=3,angle=90,length=.1) > detach(dat) 21 source(" stem() gstem() 15

16 R plot() plot() pch points() symbols() 22 matplot() matpoints() pairs() text() identify() > plot(dat$ht,dat$wt,pch=paste(dat$sex),xlab=" (cm)",ylab=" (kg)") R stars() 5.3 maptools ESRI GIS 23 6 N(µ, σ 2 ) µ σ 2 µ σ 2 central tendency variability parameter (location parameter) (scale

17 6.1 1 table(c) Q1 Q3 fivenum(x) NROW(X) length(x) sum(x) max(x) min(x) mean(x) sum(x)/length(x) exp(mean(log(x))) prod(x)^(1/nrow(x)) 1/(mean(1/X)) median(x) fivenum(x)[4]-fivenum(x)[2] (fivenum(x)[4]-fivenum(x)[2])/2 var(x) sum((x-mean(x))^2)/(length(x)-1) sd(x) sqrt(var(x)) table(c1,c2) cor(x,y) cor(x,y,method="spearman") 6.3 R try(data()) ChickWeight Chick Diet Time weight X > data(chickweight) > attach(chickweight) > X <- weight[time==20] > detach(chickweight) R d p q r 15 t 97.5% qt(0.975,df=15) rnorm(100,0,1) 17

18 norm t t F f chisq wilcox help.search() curve() 10 2 (0,20) > curve(dnorm(x,10,2),0,20) R p.value 7.3 Shapiro-Wilk Shapiro-Wilk Z i = (X i µ)/σ Z i X N(0, 1) c(i) = E[Z(i)], d ij = Cov(Z(i), Z(j)) X(1) < X(2) <... < X(n) c(1), c(2),...c(n) σ n ˆ(σ) = i=1 a ix(i) S 2 = n i=1 (X i X) 2 W = (kˆσ 2 )/S 2 k n i=1 (ka i) 2 = 1 X > shapiro.test(x) X R length(x) W 24 5% 1% 18

19 7.4 1 shapiro.test(x) t.test(x,mu= ) binom.test(table(b)[2],length(b),p= ) 7.5 X Y µ X µ Y µ X = mean(x) = X/n µ Y = mean(y ) = Y/n H0 : µ X = µ Y H1 : µ X µ Y H1 µ X > µ Y µ X < µ Y t 0 t 0 5% t 0 t 2.5% t 0 t 2.5% 97.5% t t 0 t 25 X Y X Y H0 : µ X µ Y H1 : µ X < µ Y t 0 5% t 0 t 5% 95% R t.test() alt="greater" alt="less" X Y n X n Y 26 V z 0 = E(X) E(Y ) / V/n X + V/n Y F X Y SX<-var(X) SY<-var(Y) SX>SY F0<-SX/SY 1 DFX<-length(X)-1 2 DFY<-length(Y)-1 F 1-pf(F0,DFX,DFY) F0 var.test(x,y) X C C X var.test(x~c) 2. Welch 25 t t 0 t t 0 1 R 1-pt(t0, ) [11] 27 Mann-Whitney U Wilcoxon 19

20 S S<-(DFX*SX+DFY*SY)/(DFX+DFY) t0<-abs(mean(x)-mean(y))/sqrt(s/length(x)+s/length(y)) DFX+DFY t X Y (1-pt(t0,DFX+DFY))*2 R t.test(x,y,var.equal=t) F t.test(x~c,var.equal=t) t.test(x,y,var.equal=t,alternative="less") alternative="less" X<Y X>=Y Welch t 0 = E(X) E(Y ) / S X /n X + S Y /n Y φ t φ φ = (S X /n X + S Y /n Y ) 2 {(S X /n X ) 2 /(n X 1) + (S Y /n Y ) 2 /(n Y 1)} R t.test(x,y,var.equal=f) var.equal Welch t.test(x,y) t.test(x~c) Fisher setosa virginica Sepal.Length t Fisher versicolor 3 3 setosa virginica p-value > data(iris) > setosa.sl <- iris$sepal.length[iris$species=="setosa"] > virginica.sl <- iris$sepal.length[iris$species=="virginica"] > vareq <- var.test(setosa.sl,virginica.sl)$p.value >= 0.05 > t.test(setosa.sl,virginica.sl,var.equal=vareq) Welch Two Sample t-test data: setosa.sl and virginica.sl t = , df = , p-value < 2.2e-16 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of x mean of y setosa virginica virginica 50 Sepal.Length Petal.Length 2 paired-t 0 R X Y paired-t t.test(x,y,paired=t) t.test(x-y,mu=0) 20

21 R t p-value virginica > data(iris) > virginica <- subset(iris,species=="virginica",drop=t) > attach(virginica) > t.test(sepal.length,petal.length,paired=t) Paired t-test data: Sepal.Length and Petal.Length t = , df = 49, p-value < 2.2e-16 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: sample estimates: mean of the differences > wilcox.test(sepal.length,petal.length,paired=t) Wilcoxon signed rank test with continuity correction data: Sepal.Length and Petal.Length V = 1275, p-value = 7.481e-10 alternative hypothesis: true mu is not equal to 0 > detach(virginica) n 2 nc % % (Kruskal-Wallis) 5% 2 1 5% 2 (1997),

22 post hoc 8.2 R chickwts 71 R Console?chickwts Anonymous (1948) Biometrika, 35: (g) (casein) 368, 390, 379, 260, 404, 318, 352, 359, 216, 222, 283, 332 (horsebean) 179, 160, 136, 227, 217, 168, 108, 124, 143, 140 (linseed) 309, 229, 181, 141, 260, 203, 148, 169, 213, 257, 244, 271 (meatmeal) 325, 257, 303, 315, 380, 153, 263, 242, 206, 344, 258 (soybean) 243, 230, 248, 327, 329, 250, 193, 271, 316, 267, 199, 171, 158, 248 (sunflower) 423, 340, 392, 339, 341, 226, 320, 295, 334, 322, 297, 318 chickwts weight feed > data(chickwts) > attach(chickwts) > layout(cbind(1,2)) > boxplot(weight~feed,ylab=" (g)") > stripchart(weight~feed,vert=t,method="jitter",ylab=" (g)") > detach(chickwts) weight feed

23 R Console summary(aov(weight~feed)) anova(lm(weight~feed)) > attach(chickwts) > summary(aov(weight~feed)) Df Sum Sq Mean Sq F value Pr(>F) feed e-10 *** Residuals Signif. codes: 0 *** ** 0.01 * > detach(chickwts) * Pr(>F) Sum Sq (sum of squares) feed Sum Sq feed Residuals Sum Sq Mean Sq (mean square) (Df) feed Mean Sq Residuals Mean Sq 3009 F value F F > 1 1-pf(15.365,5,65) Pr(>F) 5.936e feed 5% 6 (Bartlett) R bartlett.test( ~ ) kruskal.test() bartlett.test(weight~feed) p-value % 29 1-pf(15.365,5,65) 3 1 F value 23

24 > attach(chickwts) > print(res.bt <- bartlett.test(weight~feed)) Bartlett test of homogeneity of variances data: weight by feed Bartlett s K-squared = , df = 5, p-value = 0.66 > ifelse(res.bt$p.value<0.05, + cat(" Bartlett p=",res.bt$p.value,"\n"), + summary(aov(weight~feed))) [[1]] Df Sum Sq Mean Sq F value Pr(>F) feed e-10 *** Residuals Signif. codes: 0 *** ** 0.01 * > detach(chickwts) 8.3 R R Holm R > attach(chickwts) > pairwise.t.test(weight,feed) Pairwise comparisons using t tests with pooled SD data: weight and feed casein horsebean linseed meatmeal soybean horsebean 2.9e linseed meatmeal e soybean sunflower e e P value adjustment method: holm > detach(chickwts) Fisher 3 (Petal.Width) 24

25 (case control study) R 2 table() mosaicplot() > pid <- 1:13 > sex <- as.factor(c(rep(1,6),rep(2,7))) > levels(sex) <- c(" "," ") > disease <- as.factor(c(1,1,1,2,2,2,1,1,1,1,2,2,2)) > levels(disease) <- c(" "," ") > print(ctab <- table(sex,disease)) disease sex > mosaicplot(ctab,main="2 2 ") chisq.test(ctab) (cohort study) 25

26 a a /200 = /200 = /200 = /200 = 32.5 χ 2 c = (80 68) 2 / (55 67) 2 / (20 32) 2 / (45 33) 2 /32.5 = pchisq(13.128,1) % R > X <- matrix(c(80,20,55,45),nr=2) > chisq.test(x) Pearson s Chi-squared test with Yates continuity correction data: X X-squared = , df = 1, p-value = > smoker <- c(80,55) > pop <- c(100,100) > prop.test(smoker,pop) Fisher X fisher.test(x) % 2 2 fisher.test() 95%

27 (1) (prevalence) point prevalence prevalence prevalence (cumulative incidence) (risk) 20 (incidence rate) International Epidemiological Association Last JM [Ed.] A Dictionary of Epidemiology, 4th Ed. (Oxford Univ. Press, 2001) incidence (odds) (disease-odds) (exposure-odds) (2) Relative Risk (risk ratio) cumulative incidence rate ratio (incidence rate ratio) (mortality rate ratio) rate ratio (odds ratio) 2 (attributable risk) (risk difference) (incidence rate difference) (excess risk) (attributable proportion) 1 95% 1 5% 32 (prospective study) (cohort 32 Rothman Greenland 95% Rothman p-value 27

28 (follow-up study) case-control study 33 cross-sectional study 34 (exposure-odds ratio) (disease-odds ratio) a b m 1 c d m 2 n 1 n 2 N a/m 1 c/m 2 = am 2 cm 1 a/b c/d = ad bc a/c b/d = ad bc R fisher.test() ad/bc fisher.test() vcd oddsratio() log=f (a+0.5)(d+0.5) 0 (b+0.5)(c+0.5) summary(oddsratio()) confint(oddsratio())

29 (4/100000)/(2/100000) = 2 ( )/( ) Yule Q test-retest-reliability κ 95% m 1 m 2 X Y X m 1 X m 1 Y m 2 Y m 2 X + Y N X Y N π 1 = X/m 1 π 2 = Y/m 2 RR = π 1 /π 2 = (Xm 2 )/(Y m 1 ) N Bailey 95% RR exp( qnorm(0.975) 1/X 1/m 1 + 1/Y 1/m 2 ) (1) 35 95% 29

30 RR exp(qnorm(0.975) 1/X 1/m 1 + 1/Y 1/m 2 ) (2) RR 2 95% (0.37, 10.9) 2 95% 1 5% > riskratio2 <- function(x,y,m1,m2) { + data <- matrix(c(x,y,m1-x,m2-y,m1,m2),nr=2) + colnames(data) <- c(" "," ") + rownames(data) <- c(" "," ") + print(data) + RR <- (X/m1)/(Y/m2) + RRL <- RR*exp(-qnorm(0.975)*sqrt(1/X-1/m1+1/Y-1/m2)) + RRU <- RR*exp(qnorm(0.975)*sqrt(1/X-1/m1+1/Y-1/m2)) + cat(" : ",RR," 95% = [ ",RRL,", ",RRU," ]\n") + } > riskratio2(4,2,100000,100000) epitools riskratio() rateratio() midp wald boot method="wald" median-unbiased epitools 2 95% (0.37, 10.9) median-unbiased > library(epitools) > rateratio(c(2,4,5*100000,5*100000),method="wald") a, b, c, d OR OR = (ad)/(bc) Cornfield (1956) 95% OR exp( qnorm(0.975) 1/a + 1/b + 1/c + 1/d) OR exp(qnorm(0.975) 1/a + 1/b + 1/c + 1/d) Cornfield Newton % (0.37, 10.9) 30

31 > oddsratio2 <- function(a,b,c,d) { + data <- matrix(c(a,b,a+b,c,d,c+d,a+c,b+d,a+b+c+d),nr=3) + colnames(data) <- c(" "," ") + rownames(data) <- c(" "," "," ") + print(data) + OR <- (a*d)/(b*c) + ORL <- OR*exp(-qnorm(0.975)*sqrt(1/a+1/b+1/c+1/d)) + ORU <- OR*exp(qnorm(0.975)*sqrt(1/a+1/b+1/c+1/d)) + cat(" : ",OR," 95% = [ ",ORL,", ",ORU," ]\n") + } > oddsratio2(4,2,99996,99998) Windows Fisher workspace vcd oddsratio() > fisher.test(matrix(c(4,2,99996,99998), nr=2),workspace= ) Fisher s Exact Test for Count Data data: matrix(c(4, 2, 99996, 99998), nr = 2) p-value = alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: sample estimates: odds ratio > require(vcd) > oddsratio(matrix(c(4,2,99996,99998), nr=2),log=f) [1] vcd oddsratio() 95% confint() % [0.43, 9.39] > require(vcd) > OR <- oddsratio(matrix(c(4,2,99996,99998),nr=2),log=f) > ORCI <- confint(or) > cat(" : ",OR," 95% = [ ",ORCI[1],", ",ORCI[2]," ]\n") 9.3 π 1 π 2 (π 1 π 2 )/π 1 (π 1 π 2 )/(1 π 2 ) π = (X + Y )/(m 1 + m 2 ) (π π 2 )/π Q 1 1 Q = (OR 1)/(OR + 1) 0 31

32 (φ) 1,0 θ 1, θ 2 φ = (π 1 π 2 )(θ 1 θ 2 ) k m χ 2 0 n χ 2 0 /n k m t 0 t 1 C C = φ 2 /(1 + φ 2 ) 0 (t 1)/t V V = φ/ t V vcd assocstats() > require(vcd) > assocstats(matrix(c(4,2,99996,99998),nr=2)) 9.4 κ test-retest reliability vcd agreementplot() a b m 1 c d m 2 n 1 n 2 N P e = (n 1 m 1 /N + n 2 m 2 /N)/N P o = (a + d)/n κ = (P o P e )/(1 P e ) κ κ V (κ) V (κ) = P e /(N (1 P e )) κ/ V (κ) κ = 0 κ 95% κ 95% R

33 > kappa.test <- function(x) { + x <- as.matrix(x) + a <- x[1,1]; b <- x[1,2]; c <- x[2,1]; d <- x[2,2] + m1 <- a+b; m2 <- c+d; n1 <- a+c; n2 <- b+d; N <- sum(x) + Pe <- (n1*m1/n+n2*m2/n)/n + Po <- (a+d)/n + kappa <- (Po-Pe)/(1-Pe) + sek0 <- sqrt(pe/(n*(1-pe))) + sek <- sqrt(po*(1-po)/(n*(1-pe)^2)) + p.value <- 1-pnorm(kappa/seK0) + kappal<-kappa-qnorm(0.975)*sek + kappau<-kappa+qnorm(0.975)*sek + list(kappa=kappa,conf.int=c(kappal,kappau),p.value=p.value) + } > kappa.test(matrix(c(10,3,2,19),nr=2)) $kappa [1] $conf.int [1] $p.value [1] e-05 vcd Kappa() m m κ 36 confint() 37 > require(vcd) > print(mykappa <- Kappa(matrix(c(10,3,2,19),nr=2))) > confint(mykappa) C3 2 C1 C2 mantelhaen.test(c1,c2,c3) TMP <- table(c1,c2,c3) 3 TMP mantelhaen.test(tmp) C 2 2 B1 B2 36 Po Pe weights= weights="equal-spacing" weights="fleiss-cohen" nc 1-(abs(outer(1:nc,1:nc,"-"))/(nc-1))^2 weights="equal-spacing" 1-abs(outer(1:nc,1:nc,"-"))/(nc-1) 2 matrix(c(1,0,0,1),nc=2) 37 κ 95 poor slight fair moderate substantial almost perfect 1 perfect Landis and Koch, 1977, Biometrics, 33: vcd κ = 0 33

34 Woolf vcd woolf.test(table(b1,b2,c)) 2 subset() chisq.test(table(c1,c2)) Fisher fisher.test(table(c1,c2)) library(vcd); summary(oddsratio(table(b1,b2),log=f)) library(vcd); assocstats(table(c1,c2)) library(vcd); Kappa(table(C1,C2)) prop.trend.test(table(b,i)[2,],table(i)) Cochran-Armitage var.test(x~b) F t.test(x~b,var.equal=t) t t.test(x~b) Welch wilcox.test(x~b) Wilcoxon t.test(x,y,paired=t) paired-t bartlett.test(x~c) aov(x~c) C TukeyHSD(aov(X~C)) pairwise.t.test(x,c) Tukey Holm library(multcomp) simtest(x~c,type="dunnett") simtest(x~c,type="williams") kruskal.test(x~c) pairwise.wilcox.test(x,c) Wilcoxon cor.test(x,y) cor.test(x,y,method="spearman") cor.test(x,y,method="kendall") 34

35 11 (Generalized Linear Model) Y = β 0 + βx + ε Y 38 X β 0 β ε 39 R glm() lm() CRAN nls() 11.1 R glm() (1) X1 X2 Y Y (2)(1) (3)dat Y Y (4) C1 C2 Y > glm(y ~ X1+X2) > glm(y ~ X1+X2-1) > glm(y ~., data=dat, family="binomial") > glm(y ~ C1+C2+C1:C2) family "gaussian" 2 family (1) lm(y ~ X1+X2) summary(lm()) lm() (4) lm() * (4) C1*C2 (4) anova(lm(y ~ C1*C2)) res <- glm(y ~ X1+X2) plot(residuals(res)) summary(res) AIC(res) AIC step(res) R 35

36 11.2 t (Y ) (X) t Welch 2 Type I Type IV Type I SS Type II Type III Type II Type II SS 2 Type III Type II Type IV SAS SAS MANOVA Type II Type I Type II 16 IML Type III R anova() aov() Type I anova(lm()) aov() car Anova() Type II Type III type= III library(car) help(anova) Anova() Type II SAS Type II Type III car John Fox An R and S-PLUS companion to applied regression. p.140 Type III A B A B A Type III SAS R library(car) Anova(lm(Y~C1*C2)) Type II 36

37 AIC t > res <- lm(y ~ X+Z) > sdd <- c(0,sd(x),sd(z)) > stb <- coef(res)*sdd/sd(y) > print(stb) 11.4 (multicolinearity) Y X1 X2 lm(y ~ X1+X2) X1 X2 X1 X2 X2 (multicolinearity) 2 1 VIF Variance Inflation Factor; VIF 10 Armitage et al DBP SBP centring R MASS lm.ridge() DAAG Maindonald and Braun, 2003 vif() VIF Armitage et al. 37

38 data(airquality) Ozone ppb Solar.R 8:00 12: Langley Wind LaGuardia 7:00 10:00 Temp Month Day LaGuardia Armitage VIF R > data(airquality) > attach(airquality) > res <- lm(ozone ~ Solar.R+Wind+Temp) > VIF <- function(x) { 1/(1-summary(X)$r.squared) } > VIF(lm(Solar.R ~ Wind+Temp)) > VIF(lm(Wind ~ Solar.R+Temp)) > VIF(lm(Temp ~ Solar.R+Wind)) > summary(res) Call: lm(formula = Ozone ~ Solar.R + Wind + Temp) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) ** Solar.R * Wind e-06 *** Temp e-09 *** --- Signif. codes: 0 *** ** 0.01 * Residual standard error: on 107 degrees of freedom Multiple R-Squared: , Adjusted R-squared: F-statistic: on 3 and 107 DF, p-value: < 2.2e-16 > detach(airquality) 3 VIF 10 summary(res) 5% Adjusted R-squared 3 60% 11.5 (1) (2) 38

39 AIC 11.6 res Wind plot(residuals(res)~res$model$wind) plot(residuals(res)) predict() Wind 95% Wind Ozone 42 95% > data(airquality) > attach(airquality) > res <- lm(ozone ~ Solar.R+Wind+Temp) > EW <- seq(min(wind),max(wind),len=100) > ES <- rep(mean(solar.r,na.rm=t),100) > ET <- rep(mean(temp,na.rm=t),100) > Ozone.EWC <- predict(res,list(wind=ew,solar.r=es,temp=et),interval="conf") > plot(ozone~wind) > lines(ew,ozone.ewc[,1],lty=1) > lines(ew,ozone.ewc[,2],lty=2,col="blue") > lines(ew,ozone.ewc[,3],lty=2,col="blue") > detach(airquality) 42 95% 95% predict() interval="conf" interval="pred" 39

40 f(x, θ) {x 1, x 2,..., x n } θ L(θ) = f(x 1, θ)f(x 2, θ) f(x n, θ) L(θ) θ θ L(θ) θ θ θ ln L(θ) µ (1995) -2 λ R loglik() % 2 3 > data(airquality) > attach(airquality) > res.3 <- lm(ozone ~ Solar.R+Wind+Temp) > res.2 <- lm(ozone ~ Solar.R+Wind) > lambda <- -2*(logLik(res.2)-logLik(res.3)) > print(1-pchisq(lambda,1)) log Lik e-09 (df=4) > detach(airquality) lm() 2 glm() nls() 11.8 AIC: AIC L n AIC = 2 ln L + 2n AIC R AIC() extractaic() 2 Akaike s An Information Criterion The (generalized) Akaike *A*n *I*nformation *C*riterion for a fitted parametric model extractaic() MASS S4 step() 40

41 2 AIC AIC(res.3) -2*logLik(res.3)+2*attr(logLik(res.3),"df") extractaic(res.3) res.2 AIC(res.2) extractaic(res.2) AIC AIC() extractaic() step() AIC 44 step(lm(ozone~wind+solar.r+temp)) step() (direction="forward") (direction="backward") (direction="both") direction="backward" step() step() direction ress <- step(lm(ozone~solar.r+wind+temp)) 3 AIC 682 ress AIC step() extractaic() AIC AIC(ress) lm() 111 Ozone Solar.R AIC(ress)-111*(1+log(2*pi)) step() > data(airquality) > attach(airquality) > res <- lm(ozone~solar.r+wind+temp) > ress <- step(res) > summary(ress) > AIC(ress) 5% n n R 8 AIC() 2 ln L + 2θ L θ n p σ n(1 + ln(2πσ 2 )) + 2(p + 1) extractaic() n ln(σ 2 ) + 2p n(1 + ln(2π)) R-help S-plus step.glm() R 41

42 n 1 M.G R step() predict() > data(airquality) > attach(airquality) > res<-lm(ozone~solar.r+wind+temp) > predict(res, list(solar.r=mean(res$model$solar.r), + Wind=mean(res$model$Wind), Temp=mean(res$model$Temp))) [1] > detach(airquality) Solar.R Temp Solar.R mean(solar.r,na.rm=t) Wind= % AIC Wind Ozone Wind Ozone Wind Solar.R 2 > data(airquality) > attach(airquality) > resmr <- nls(ozone ~ a*exp(-b*wind) + c*solar.r, start=list(a=200,b=0.2,c=1)) > summary(resmr) Formula: Ozone ~ a * exp(-b * Wind) + c * Solar.R Parameters: Estimate Std. Error t value Pr(> t ) a e-09 *** b e-11 *** c e-05 *** --- Signif. codes: 0 *** ** 0.01 * Residual standard error: on 108 degrees of freedom > AIC(resmr) [1] R 42

43 AIC 2 extractaic() Temp > SRM <- mean(subset(solar.r,!is.na(ozone)&!is.na(solar.r)&!is.na(wind)&!is.na(temp))) > predict(resmr,list(wind=25,solar.r=srm)) ppb Y = β 0 + β 1 X 1 + β 2 X 2 + β 12 X 1 X 2 + ε X 1 Y Y X 2 X 2 X 2 Y (slope) X 1 X 2 Y adjusted mean; X 1 R X 1 C C factor X 2 X Y Y summary(lm(y~c+x)) X C Y C 1 2 C2 (slope) summary(lm(y[c==1]~x[c==1]); summary(lm(y[c==2]~x[c==2]) summary(lm(y~c+x+c:x)) summary(lm(y~c*x)) C X Y Coefficients C2:X R ToothGrowth 10 3 C len supp dose coplot(len~dose supp) 2 43

44 > data(toothgrowth) > attach(toothgrowth) > plot(dose,len,pch=as.integer(supp),ylim=c(0,35)) > legend(max(dose)-0.5,min(len)+1,levels(supp),pch=c(1,2)) > abline(lm1 <- lm(len[supp== VC ]~dose[supp== VC ])) > abline(lm2 <- lm(len[supp== OJ ]~dose[supp== OJ ]),lty=2) > summary(lm1) > summary(lm2) summary(lm1) summary(lm2) > lm3 <- lm(len ~ supp*dose) > summary(lm3) Call: lm(formula = len ~ supp * dose) Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) e-09 *** suppvc *** dose e-08 *** suppvc:dose * --- Signif. codes: 0 *** ** 0.01 * Residual standard error: on 56 degrees of freedom Multiple R-Squared: , Adjusted R-squared: F-statistic: on 3 and 56 DF, p-value: 6.521e-16 suppvc:dose len % glm() P ln(p/(1 P )) = b 0 + b 1 X b k X k X 1 X 2,...X k X 1 = 0 X 1 = 1 b1 = ln(p 1 /(1 P 1 )) ln(p 0 /(1 P 0 )) = ln(p 1 (1 P 0 )/(P 0 (1 P 1 ))) 44

45 b 1 95% exp(b 1 ± 1.96 SE(b 1 )) library(mass) data(birthwt) Springfield Baystate 189 str(birthwt) low age lwt race smoke ptl ht ui ftv bwt 2.5 kg 1 a (g) a lb. 1 lb kg > require(mass) > data(birthwt) > attach(birthwt) > low <- factor(low) > race <- factor(race, labels=c("white","black","other")) > ptd <- factor(ptl>0) > smoke <- (smoke>0) > ht <- (ht>0) > ui <- (ui>0) > ftv <- factor(ftv) > levels(ftv)[-(1:2)] <- "2+" > bw <- data.frame(low,age,lwt,race,smoke,ptd,ht,ui,ftv) > detach(birthwt) > summary(res <- glm(low ~., family=binomial, data=bw)) > summary(res2 <- step(res)) smoketrue SE % 45

46 > exp( ) [1] > exp( qnorm(0.975)* ) [1] > exp( qnorm(0.975)* ) [1] % [1.08, 5.26] 95% 1 5% 12 survival (1995) Gehan R MASS 2 library() require() 12.1 (1995) p Gehan 6-MP R Surv() summary() summary 46

47 > require(mass) > require(survival) > print(res<-survfit(surv(time,cens)~treat,data=gehan)) Call: survfit(formula = Surv(time, cens) ~ treat, data = gehan) n events median 0.95LCL 0.95UCL treat=6-mp Inf treat=control > summary(res) Call: survfit(formula = Surv(time, cens) ~ treat, data = gehan) treat=6-mp time n.risk n.event survival std.err lower 95% CI upper 95% CI treat=control time n.risk n.event survival std.err lower 95% CI upper 95% CI NA NA NA > plot(res,lty=c(1,2)) > legend(30,0.2,lty=c(1,2),legend=levels(gehan$treat)) LaTeX LaTeX graphicx eps eps OpenOffice.org Draw eps 47

48 difftime() ISOdate() x names dob dod difftime() 4 [x$names=="robert"] Robert alivedays ISOdate(,, ) > x <- data.frame( + names = c("edward","shibasaburo","robert","hideyo"), + dob = c(" "," "," "," "), + dod = c(" "," "," "," ")) > alivedays <- difftime(x$dod,x$dob)[x$names=="robert"] > alivedays/ > difftime(isodate(2005,1,31),x$dob) A 2 B 1 4,6,8,9 2 5,7,12,

49 1 2 i j e ij i d i i j n ij i n i e ij = d i n ij /n i 47 e 11 = 1 n 11 /n 1 = 4/8 = 0.5 i j d ij w i i j u ij u ij = w i (d ij e ij ) 1 u 1 = i (d i1 e i1 ) u 1 = (1 4/8) + (0 3/7) + (1 3/6) + (0 2/5) + (1 2/4) + (1 1/3) + (0 0/2) + (0 0/1) V = V jj = i (n i n ij )n ij d i (n i d i ) n i2 (n i 1) V = (8 4) 4 (7 3) 3 (6 3) 3 (5 2) 2 (4 2) 2 (3 1) *4/64+4*3/49+3*3/36+3*2/25+2*2/16+2*1/ χ 2 = /1.457 = % % R time event group survdiff(surv(time,event)~group) > require(survival) > time2 <- c(4,6,8,9,5,7,12,14) > event <- c(1,1,1,1,1,1,1,1) > group <- c(1,1,1,1,2,2,2,2) > survdiff(surv(time2,event)~group) χ 2 = p = %

50 12.3 z i = (z i1, z i2,..., z ip ) i t h(z i, t) h(z i, t) = h 0 (t) exp(β 1 z i1 + β 2 z i β p z ip ) h 0 (t) t β 1, β 2,..., β p exp(β x z ix ) Cox z i 1 2 t h 0 (t) exp(β 1 z 11 + β 2 z β p z 1p ) exp(β 1 z 21 + β 2 z β p z 2p ) T S(t) T t S(0) = 1 h(t) t Pr(t T < t + t T t) S(t) S(t + t) h(t) = lim = lim t 0 t t 0 ts(t) = ds(t) dt 1 S(t) = d(log(s(t)) dt H(t) = t h(u)du = log S(t) S(t) = exp( H(t)) 0 z S(z, t) H(z, H(z, t) = t 0 h(z, u)du = t 0 h 0 (u) exp(βz)du = exp(βz)h 0 (t) S(z, t) = exp( H(z, t)) = exp{ exp(βz)h 0 (t)} log( log S(z, t)) = βz + log H 0 (t) βz 12.4 β t i t 1 t i 50

51 i L L β L Cox Exact Breslow Efron Exact Breslow R coxph() Efron Breslow Efron Exact time event group coxph(surv(time,event)~group) 2 Exact coxph(surv(time,event)~group, method="exact") Gehan 6-MP > require(mass) > require(survival) > res <- coxph(surv(time,cens)~treat,data=gehan) > summary(res) Call: coxph(formula = Surv(time, cens) ~ treat, data = gehan) n= 42 coef exp(coef) se(coef) z p treatcontrol exp(coef) exp(-coef) lower.95 upper.95 treatcontrol Rsquare= (max possible= ) Likelihood ratio test= 16.4 on 1 df, p=5.26e-05 Wald test = 14.5 on 1 df, p= Score (logrank) test = 17.3 on 1 df, p=3.28e-05 > plot(survfit(res)) 5% 6-MP exp(coef) MP % [2.15, 10.8] 6-MP plot() 2 95% coxph() subset=(x=="6-mp") 51

52 R coxph() strata() time event treat stage coxph(surv(time,event)~treat+strata(stage)) 2 AIC Breslow R Exact Efron 12.6 survreg() R RjpWiki (1995) SAS 2. (2003) R 3. (2004) R 4. (2004) The R Book R 5. (2005) The R Tips R 6. (1995) 7. Armitage P, Berry G, Matthews JNS (2002) Statistical Methods in Medical Research, 4th ed. Blackwell Publishing 8. Maindonald J, Braun J (2003) Data analysis and graphics using R Cambridge Univ. Press 52

exp( β i z i ) survreg() R survival library(survival) require(survival) 3 survfit() t 1, t 2,... t 1 d 1 t 2 d 2 t 1, t 2,... n 1, n 2,... n i t i n 1

exp( β i z i ) survreg() R survival library(survival) require(survival) 3 survfit() t 1, t 2,... t 1 d 1 t 2 d 2 t 1, t 2,... n 1, n 2,... n i t i n 1 1 13 2007 1 22 (nminato@med.gunma-u.ac.jp) web http://phi.med.gunma-u.ac.jp/medstat/ (Survival Analysis Event History Analysis) Kaplan-Meier 2 0.5 0 10 a x x (T x) x (l x) q x l x (1 q x /2) x x + 1 L

More information

Use R

Use R Use R! 2008/05/23( ) Index Introduction (GLM) ( ) R. Introduction R,, PLS,,, etc. 2. Correlation coefficient (Pearson s product moment correlation) r = Sxy Sxx Syy :, Sxy, Sxx= X, Syy Y 1.96 95% R cor(x,

More information

1 R Windows R 1.1 R The R project web R web Download [CRAN] CRAN Mirrors Japan Download and Install R [Windows 9

1 R Windows R 1.1 R The R project web   R web Download [CRAN] CRAN Mirrors Japan Download and Install R [Windows 9 1 R 2007 8 19 1 Windows R 1.1 R The R project web http://www.r-project.org/ R web Download [CRAN] CRAN Mirrors Japan Download and Install R [Windows 95 and later ] [base] 2.5.1 R - 2.5.1 for Windows R

More information

(lm) lm AIC 2 / 1

(lm) lm AIC 2 / 1 W707 s-taiji@is.titech.ac.jp 1 / 1 (lm) lm AIC 2 / 1 : y = β 1 x 1 + β 2 x 2 + + β d x d + β d+1 + ϵ (ϵ N(0, σ 2 )) y R: x R d : β i (i = 1,..., d):, β d+1 : ( ) (d = 1) y = β 1 x 1 + β 2 + ϵ (d > 1) y

More information

k2 ( :35 ) ( k2) (GLM) web web 1 :

k2 ( :35 ) ( k2) (GLM) web   web   1 : 2012 11 01 k2 (2012-10-26 16:35 ) 1 6 2 (2012 11 01 k2) (GLM) kubo@ees.hokudai.ac.jp web http://goo.gl/wijx2 web http://goo.gl/ufq2 1 : 2 2 4 3 7 4 9 5 : 11 5.1................... 13 6 14 6.1......................

More information

講義のーと : データ解析のための統計モデリング. 第3回

講義のーと :  データ解析のための統計モデリング. 第3回 Title 講義のーと : データ解析のための統計モデリング Author(s) 久保, 拓弥 Issue Date 2008 Doc URL http://hdl.handle.net/2115/49477 Type learningobject Note この講義資料は, 著者のホームページ http://hosho.ees.hokudai.ac.jp/~kub ードできます Note(URL)http://hosho.ees.hokudai.ac.jp/~kubo/ce/EesLecture20

More information

R EZR 2013 11 5 *1 1 R 2 1.1 R [2013 11 5 ]................................ 2 1.2 R................................................ 3 1.3 Rgui......................................... 3 1.4 EZR...................................................

More information

R John Fox R R R Console library(rcmdr) Rcmdr R GUI Windows R R SDI *1 R Console R 1 2 Windows XP Windows * 2 R R Console R ˆ R

R John Fox R R R Console library(rcmdr) Rcmdr R GUI Windows R R SDI *1 R Console R 1 2 Windows XP Windows * 2 R R Console R ˆ R R John Fox 2006 8 26 2008 8 28 1 R R R Console library(rcmdr) Rcmdr R GUI Windows R R SDI *1 R Console R 1 2 Windows XP Windows * 2 R R Console R ˆ R GUI R R R Console > ˆ 2 ˆ Fox(2005) jfox@mcmaster.ca

More information

R EZR 2016 10 3 *1 1 R 2 1.1 R [2016 10 3 ]................................ 2 1.2 R................................................ 3 1.3 Rgui......................................... 3 1.4 EZR...................................................

More information

1 15 R Part : website:

1 15 R Part : website: 1 15 R Part 4 2017 7 24 4 : website: email: http://www3.u-toyama.ac.jp/kkarato/ kkarato@eco.u-toyama.ac.jp 1 2 2 3 2.1............................... 3 2.2 2................................. 4 2.3................................

More information

k3 ( :07 ) 2 (A) k = 1 (B) k = 7 y x x 1 (k2)?? x y (A) GLM (k

k3 ( :07 ) 2 (A) k = 1 (B) k = 7 y x x 1 (k2)?? x y (A) GLM (k 2012 11 01 k3 (2012-10-24 14:07 ) 1 6 3 (2012 11 01 k3) kubo@ees.hokudai.ac.jp web http://goo.gl/wijx2 web http://goo.gl/ufq2 1 3 2 : 4 3 AIC 6 4 7 5 8 6 : 9 7 11 8 12 8.1 (1)........ 13 8.2 (2) χ 2....................

More information

こんにちは由美子です

こんにちは由美子です 1 2 . sum Variable Obs Mean Std. Dev. Min Max ---------+----------------------------------------------------- var1 13.4923077.3545926.05 1.1 3 3 3 0.71 3 x 3 C 3 = 0.3579 2 1 0.71 2 x 0.29 x 3 C 2 = 0.4386

More information

Rによる計量分析:データ解析と可視化 - 第3回 Rの基礎とデータ操作・管理

Rによる計量分析:データ解析と可視化 - 第3回  Rの基礎とデータ操作・管理 R 3 R 2017 Email: gito@eco.u-toyama.ac.jp October 23, 2017 (Toyama/NIHU) R ( 3 ) October 23, 2017 1 / 34 Agenda 1 2 3 4 R 5 RStudio (Toyama/NIHU) R ( 3 ) October 23, 2017 2 / 34 10/30 (Mon.) 12/11 (Mon.)

More information

R Console >R ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R R Rcmdr Rcmdr Fox, 2007 Fox and Carvalho, 2012 R R 2

R Console >R ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R R Rcmdr Rcmdr Fox, 2007 Fox and Carvalho, 2012 R R 2 R John Fox Version 1.9-1 2012 9 4 2012 10 9 1 R R Windows R Rcmdr Mac OS X Linux R OS R R , R R Console library(rcmdr)

More information

DAA09

DAA09 > summary(dat.lm1) Call: lm(formula = sales ~ price, data = dat) Residuals: Min 1Q Median 3Q Max -55.719-19.270 4.212 16.143 73.454 Coefficients: Estimate Std. Error t value Pr(> t ) (Intercept) 237.1326

More information

一般化線形 (混合) モデル (2) - ロジスティック回帰と GLMM

一般化線形 (混合) モデル (2) - ロジスティック回帰と GLMM .. ( ) (2) GLMM kubo@ees.hokudai.ac.jp I http://goo.gl/rrhzey 2013 08 27 : 2013 08 27 08:29 kubostat2013ou2 (http://goo.gl/rrhzey) ( ) (2) 2013 08 27 1 / 74 I.1 N k.2 binomial distribution logit link function.3.4!

More information

5 Armitage x 1,, x n y i = 10x i + 3 y i = log x i {x i } {y i } 1.2 n i i x ij i j y ij, z ij i j 2 1 y = a x + b ( cm) x ij (i j )

5 Armitage x 1,, x n y i = 10x i + 3 y i = log x i {x i } {y i } 1.2 n i i x ij i j y ij, z ij i j 2 1 y = a x + b ( cm) x ij (i j ) 5 Armitage. x,, x n y i = 0x i + 3 y i = log x i x i y i.2 n i i x ij i j y ij, z ij i j 2 y = a x + b 2 2. ( cm) x ij (i j ) (i) x, x 2 σ 2 x,, σ 2 x,2 σ x,, σ x,2 t t x * (ii) (i) m y ij = x ij /00 y

More information

講義のーと : データ解析のための統計モデリング. 第5回

講義のーと :  データ解析のための統計モデリング. 第5回 Title 講義のーと : データ解析のための統計モデリング Author(s) 久保, 拓弥 Issue Date 2008 Doc URL http://hdl.handle.net/2115/49477 Type learningobject Note この講義資料は, 著者のホームページ http://hosho.ees.hokudai.ac.jp/~kub ードできます Note(URL)http://hosho.ees.hokudai.ac.jp/~kubo/ce/EesLecture20

More information

untitled

untitled 2011/6/22 M2 1*1+2*2 79 2F Y YY 0.0 0.2 0.4 0.6 0.8 0.000 0.002 0.004 0.006 0.008 0.010 0.012 1.0 1.5 2.0 2.5 3.0 3.5 4.0 Y 0 50 100 150 200 250 YY A (Y = X + e A ) B (YY = X + e B ) X 0.00 0.05 0.10

More information

こんにちは由美子です

こんにちは由美子です Analysis of Variance 2 two sample t test analysis of variance (ANOVA) CO 3 3 1 EFV1 µ 1 µ 2 µ 3 H 0 H 0 : µ 1 = µ 2 = µ 3 H A : Group 1 Group 2.. Group k population mean µ 1 µ µ κ SD σ 1 σ σ κ sample mean

More information

JMP V4 による生存時間分析

JMP V4 による生存時間分析 V4 1 SAS 2000.11.18 4 ( ) (Survival Time) 1 (Event) Start of Study Start of Observation Died Died Died Lost End Time Censor Died Died Censor Died Time Start of Study End Start of Observation Censor

More information

28

28 y i = Z i δ i +ε i ε i δ X y i = X Z i δ i + X ε i [ ] 1 δ ˆ i = Z i X( X X) 1 X Z i [ ] 1 σ ˆ 2 Z i X( X X) 1 X Z i Z i X( X X) 1 X y i σ ˆ 2 ˆ σ 2 = [ ] y i Z ˆ [ i δ i ] 1 y N p i Z i δ ˆ i i RSTAT

More information

1.2 R R Windows, Macintosh, Linux(Unix) Windows Mac R Linux redhat, debian, vinelinux ( ) RjpWiki ( RjpWiki Wiki

1.2 R R Windows, Macintosh, Linux(Unix) Windows Mac R Linux redhat, debian, vinelinux ( ) RjpWiki (  RjpWiki Wiki R 2005 9 12 ( ) 1 R 1.1 R R R S-PLUS( ) S version 4( ) S (AT&T Richard A. Becker, John M. Chambers, and Allan R. Wilks ) S S R R S ( ) S GUI( ) ( ) R R R R http://stat.sm.u-tokai.ac.jp/ yama/r/ R yamamoto@sm.u-tokai.ac.jp

More information

BMIdata.txt DT DT <- read.table("bmidata.txt") DT head(dt) names(dt) str(dt)

BMIdata.txt DT DT <- read.table(bmidata.txt) DT head(dt) names(dt) str(dt) ?read.table read.table(file, header = FALSE, sep = "", quote = "\" ", dec = ".", numerals = c("allow.loss", "warn.loss", "no.loss"), row.names, col.names, as.is =!stringsasfactors, na.strings = "NA", colclasses

More information

2 H23 BioS (i) data d1; input group patno t sex censor; cards;

2 H23 BioS (i) data d1; input group patno t sex censor; cards; H BioS (i) data d1; input group patno t sex censor; cards; 0 1 0 0 0 0 1 0 1 1 0 4 4 0 1 0 5 5 1 1 0 6 5 1 1 0 7 10 1 0 0 8 15 0 1 0 9 15 0 1 0 10 4 1 0 0 11 4 1 0 1 1 5 1 0 1 1 7 0 1 1 14 8 1 0 1 15 8

More information

151021slide.dvi

151021slide.dvi : Mac I 1 ( 5 Windows (Mac Excel : Excel 2007 9 10 1 4 http://asakura.co.jp/ books/isbn/978-4-254-12172-8/ (1 1 9 1/29 (,,... (,,,... (,,, (3 3/29 (, (F7, Ctrl + i, (Shift +, Shift + Ctrl (, a i (, Enter,

More information

統計研修R分散分析(追加).indd

統計研修R分散分析(追加).indd http://cse.niaes.affrc.go.jp/minaka/r/r-top.html > mm mm TRT DATA 1 DM1 2537 2 DM1 2069 3 DM1 2104 4 DM1 1797 5 DM2 3366 6 DM2 2591 7 DM2 2211 8

More information

インターネットを活用した経済分析 - フリーソフト Rを使おう

インターネットを活用した経済分析 - フリーソフト Rを使おう R 1 1 1 2017 2 15 2017 2 15 1/64 2 R 3 R R RESAS 2017 2 15 2/64 2 R 3 R R RESAS 2017 2 15 3/64 2-4 ( ) ( (80%) (20%) 2017 2 15 4/64 PC LAN R 2017 2 15 5/64 R R 2017 2 15 6/64 3-4 R 15 + 2017 2 15 7/64

More information

1 R ID 1. ID Before After 1 X 1 Y 1 2 X 2 Y n 1 X n 1 Y n 1 n X n Y n. ID Group Measure. 1 1 Y 1... n 1 1 Y n1 n Y n n 0 Y n 1 E

1 R ID 1. ID Before After 1 X 1 Y 1 2 X 2 Y n 1 X n 1 Y n 1 n X n Y n. ID Group Measure. 1 1 Y 1... n 1 1 Y n1 n Y n n 0 Y n 1 E 2010 R 0 C626 R 2 t Welch t Wilcoxon 3 Fisher McNemar Box-Muller p- Excel R 1 B USB tomo-statim i.softbank.jp R WWW D3 C626 E-Mail d082905 hiroshima-u.ac.jp url http://home.hiroshima-u.ac.jp/d082905/r.html

More information

untitled

untitled 2 : n =1, 2,, 10000 0.5125 0.51 0.5075 0.505 0.5025 0.5 0.4975 0.495 0 2000 4000 6000 8000 10000 2 weak law of large numbers 1. X 1,X 2,,X n 2. µ = E(X i ),i=1, 2,,n 3. σi 2 = V (X i ) σ 2,i=1, 2,,n ɛ>0

More information

Mantel-Haenszelの方法

Mantel-Haenszelの方法 Mantel-Haenszel 2008 6 12 ) 2008 6 12 1 / 39 Mantel & Haenzel 1959) Mantel N, Haenszel W. Statistical aspects of the analysis of data from retrospective studies of disease. J. Nat. Cancer Inst. 1959; 224):

More information

最小2乗法

最小2乗法 2 2012 4 ( ) 2 2012 4 1 / 42 X Y Y = f (X ; Z) linear regression model X Y slope X 1 Y (X, Y ) 1 (X, Y ) ( ) 2 2012 4 2 / 42 1 β = β = β (4.2) = β 0 + β (4.3) ( ) 2 2012 4 3 / 42 = β 0 + β + (4.4) ( )

More information

kubostat2017c p (c) Poisson regression, a generalized linear model (GLM) : :

kubostat2017c p (c) Poisson regression, a generalized linear model (GLM) : : kubostat2017c p.1 2017 (c), a generalized linear model (GLM) : kubo@ees.hokudai.ac.jp http://goo.gl/76c4i 2017 11 14 : 2017 11 07 15:43 kubostat2017c (http://goo.gl/76c4i) 2017 (c) 2017 11 14 1 / 47 agenda

More information

R分散分析06.indd

R分散分析06.indd http://cse.niaes.affrc.go.jp/minaka/r/r-top.html > mm mm TRT DATA 1 DM1 2537 2 DM1 2069 3 DM1 2104 4 DM1 1797 5 DM2 3366 6 DM2 2591 7 DM2 2211 8 DM2

More information

²¾ÁÛ¾õ¶·É¾²ÁË¡¤Î¤¿¤á¤Î¥Ñ¥Ã¥±¡¼¥¸DCchoice ¡Ê»ÃÄêÈÇ¡Ë

²¾ÁÛ¾õ¶·É¾²ÁË¡¤Î¤¿¤á¤Î¥Ñ¥Ã¥±¡¼¥¸DCchoice ¡Ê»ÃÄêÈÇ¡Ë DCchoice ( ) R 2013 2013 11 30 DCchoice package R 2013/11/30 1 / 19 1 (CV) CV 2 DCchoice WTP 3 DCchoice package R 2013/11/30 2 / 19 (Contingent Valuation; CV) WTP CV WTP WTP 1 1989 2 DCchoice package R

More information

こんにちは由美子です

こんにちは由美子です Prevalence (proportion) 1. 1991 23.8 2. 1960 52 85 2477 310 cross sectional study prevalence Time referent: prevalence 1985 40 45 prevalence 0.5 80 85 43 Time referent 1985 time referent Risk and Cumulative

More information

% 10%, 35%( 1029 ) p (a) 1 p 95% (b) 1 Std. Err. (c) p 40% 5% (d) p 1: STATA (1). prtesti One-sample test of pr

% 10%, 35%( 1029 ) p (a) 1 p 95% (b) 1 Std. Err. (c) p 40% 5% (d) p 1: STATA (1). prtesti One-sample test of pr 1 1. 2014 6 2014 6 10 10% 10%, 35%( 1029 ) p (a) 1 p 95% (b) 1 Std. Err. (c) p 40% 5% (d) p 1: STATA (1). prtesti 1029 0.35 0.40 One-sample test of proportion x: Number of obs = 1029 Variable Mean Std.

More information

1 2 Windows 7 *3 Windows * 4 R R Console R R Console ˆ R GUI R R R *5 R 2 R R R 6.1 ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R Rconsole R --sdi R M

1 2 Windows 7 *3 Windows * 4 R R Console R R Console ˆ R GUI R R R *5 R 2 R R R 6.1 ˆ 2 ˆ 2 ˆ Graphics Device 1 Rcmdr R Console R Rconsole R --sdi R M R John Fox and Milan Bouchet-Valat Version 2.0-1 2013 11 8 2013 11 11 1 R Fox 2005 R R Core Team, 2013 GUI R R R R R R R R R the Comprehensive R Archive Network (CRAN) R CRAN 6.4 R Windows R Rcmdr Mac

More information

t sex N y y y Diff (1-2)

t sex N y y y Diff (1-2) Armitage 1 1.1 2 t 1.2 SAS Proc GLM 2 2.1 1 1 2.1.1 50 1 1 t sex N y 50 116.45 119.6 122.75 11.071 1.5657 93.906 154.32 y 50 127.27 130.7 134.13 12.072 1.7073 102.68 163.37 y Diff (1-2) -15.7-11.1-6.504

More information

201711grade2.pdf

201711grade2.pdf 2017 11 26 1 2 28 3 90 4 5 A 1 2 3 4 Web Web 6 B 10 3 10 3 7 34 8 23 9 10 1 2 3 1 (A) 3 32.14 0.65 2.82 0.93 7.48 (B) 4 6 61.30 54.68 34.86 5.25 19.07 (C) 7 13 5.89 42.18 56.51 35.80 50.28 (D) 14 20 0.35

More information

x y 1 x 1 y 1 2 x 2 y 2 3 x 3 y 3... x ( ) 2

x y 1 x 1 y 1 2 x 2 y 2 3 x 3 y 3... x ( ) 2 1 1 1.1 1.1.1 1 168 75 2 170 65 3 156 50... x y 1 x 1 y 1 2 x 2 y 2 3 x 3 y 3... x ( ) 2 1 1 0 1 0 0 2 1 0 0 1 0 3 0 1 0 0 1...... 1.1.2 x = 1 n x (average, mean) x i s 2 x = 1 n (x i x) 2 3 x (variance)

More information

I L01( Wed) : Time-stamp: Wed 07:38 JST hig e, ( ) L01 I(2017) 1 / 19

I L01( Wed) : Time-stamp: Wed 07:38 JST hig e,   ( ) L01 I(2017) 1 / 19 I L01(2017-09-20 Wed) : Time-stamp: 2017-09-20 Wed 07:38 JST hig e, http://hig3.net ( ) L01 I(2017) 1 / 19 ? 1? 2? ( ) L01 I(2017) 2 / 19 ?,,.,., 1..,. 1,2,.,.,. ( ) L01 I(2017) 3 / 19 ? I. M (3 ) II,

More information

Microsoft Word - StatsDirectMA Web ver. 2.0.doc

Microsoft Word - StatsDirectMA Web ver. 2.0.doc Web version. 2.0 15 May 2006 StatsDirect ver. 2.0 15 May 2006 2 2 2 Meta-Analysis for Beginners by using the StatsDirect ver. 2.0 15 May 2006 Yukari KAMIJIMA 1), Ataru IGARASHI 2), Kiichiro TSUTANI 2)

More information

yamadaiR(cEFA).pdf

yamadaiR(cEFA).pdf R 2012/10/05 Kosugi,E.Koji (Yamadai.R) Categorical Factor Analysis by using R 2012/10/05 1 / 9 Why we use... 3 5 Kosugi,E.Koji (Yamadai.R) Categorical Factor Analysis by using R 2012/10/05 2 / 9 FA vs

More information

こんにちは由美子です

こんにちは由美子です Sample size power calculation Sample Size Estimation AZTPIAIDS AIDSAZT AIDSPI AIDSRNA AZTPr (S A ) = π A, PIPr (S B ) = π B AIDS (sampling)(inference) π A, π B π A - π B = 0.20 PI 20 20AZT, PI 10 6 8 HIV-RNA

More information

Stata 11 Stata ROC whitepaper mwp anova/oneway 3 mwp-042 kwallis Kruskal Wallis 28 mwp-045 ranksum/median / 31 mwp-047 roctab/roccomp ROC 34 mwp-050 s

Stata 11 Stata ROC whitepaper mwp anova/oneway 3 mwp-042 kwallis Kruskal Wallis 28 mwp-045 ranksum/median / 31 mwp-047 roctab/roccomp ROC 34 mwp-050 s BR003 Stata 11 Stata ROC whitepaper mwp anova/oneway 3 mwp-042 kwallis Kruskal Wallis 28 mwp-045 ranksum/median / 31 mwp-047 roctab/roccomp ROC 34 mwp-050 sampsi 47 mwp-044 sdtest 54 mwp-043 signrank/signtest

More information

数理統計学Iノート

数理統計学Iノート I ver. 0/Apr/208 * (inferential statistics) *2 A, B *3 5.9 *4 *5 [6] [],.., 7 2004. [2].., 973. [3]. R (Wonderful R )., 9 206. [4]. ( )., 7 99. [5]. ( )., 8 992. [6],.., 989. [7]. - 30., 0 996. [4] [5]

More information

Part () () Γ Part ,

Part () () Γ Part , Contents a 6 6 6 6 6 6 6 7 7. 8.. 8.. 8.3. 8 Part. 9. 9.. 9.. 3. 3.. 3.. 3 4. 5 4.. 5 4.. 9 4.3. 3 Part. 6 5. () 6 5.. () 7 5.. 9 5.3. Γ 3 6. 3 6.. 3 6.. 3 6.3. 33 Part 3. 34 7. 34 7.. 34 7.. 34 8. 35

More information

,, Poisson 3 3. t t y,, y n Nµ, σ 2 y i µ + ɛ i ɛ i N0, σ 2 E[y i ] µ * i y i x i y i α + βx i + ɛ i ɛ i N0, σ 2, α, β *3 y i E[y i ] α + βx i

,, Poisson 3 3. t t y,, y n Nµ, σ 2 y i µ + ɛ i ɛ i N0, σ 2 E[y i ] µ * i y i x i y i α + βx i + ɛ i ɛ i N0, σ 2, α, β *3 y i E[y i ] α + βx i Armitage.? SAS.2 µ, µ 2, µ 3 a, a 2, a 3 a µ + a 2 µ 2 + a 3 µ 3 µ, µ 2, µ 3 µ, µ 2, µ 3 log a, a 2, a 3 a µ + a 2 µ 2 + a 3 µ 3 µ, µ 2, µ 3 * 2 2. y t y y y Poisson y * ,, Poisson 3 3. t t y,, y n Nµ,

More information

1 Stata SEM LightStone 4 SEM 4.. Alan C. Acock, Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press 3.

1 Stata SEM LightStone 4 SEM 4.. Alan C. Acock, Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press 3. 1 Stata SEM LightStone 4 SEM 4.. Alan C. Acock, 2013. Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press 3. 2 4, 2. 1 2 2 Depress Conservative. 3., 3,. SES66 Alien67 Alien71,

More information

y i OLS [0, 1] OLS x i = (1, x 1,i,, x k,i ) β = (β 0, β 1,, β k ) G ( x i β) 1 G i 1 π i π i P {y i = 1 x i } = G (

y i OLS [0, 1] OLS x i = (1, x 1,i,, x k,i ) β = (β 0, β 1,, β k ) G ( x i β) 1 G i 1 π i π i P {y i = 1 x i } = G ( 7 2 2008 7 10 1 2 2 1.1 2............................................. 2 1.2 2.......................................... 2 1.3 2........................................ 3 1.4................................................

More information

(pdf) (cdf) Matlab χ ( ) F t

(pdf) (cdf) Matlab χ ( ) F t (, ) (univariate) (bivariate) (multi-variate) Matlab Octave Matlab Matlab/Octave --...............3. (pdf) (cdf)...3.4....4.5....4.6....7.7. Matlab...8.7.....9.7.. χ ( )...0.7.3.....7.4. F....7.5. t-...3.8....4.8.....4.8.....5.8.3....6.8.4....8.8.5....8.8.6....8.9....9.9.....9.9.....0.9.3....0.9.4.....9.5.....0....3

More information

kubostat2015e p.2 how to specify Poisson regression model, a GLM GLM how to specify model, a GLM GLM logistic probability distribution Poisson distrib

kubostat2015e p.2 how to specify Poisson regression model, a GLM GLM how to specify model, a GLM GLM logistic probability distribution Poisson distrib kubostat2015e p.1 I 2015 (e) GLM kubo@ees.hokudai.ac.jp http://goo.gl/76c4i 2015 07 22 2015 07 21 16:26 kubostat2015e (http://goo.gl/76c4i) 2015 (e) 2015 07 22 1 / 42 1 N k 2 binomial distribution logit

More information

(2/24) : 1. R R R

(2/24) : 1. R R R R? http://hosho.ees.hokudai.ac.jp/ kubo/ce/2004/ : kubo@ees.hokudai.ac.jp (2/24) : 1. R 2. 3. R R (3/24)? 1. ( ) 2. ( I ) : (p ) : cf. (power) p? (4/24) p ( ) I p ( ) I? ( ) (5/24)? 0 2 4 6 8 A B A B (control)

More information

Stata11 whitepapers mwp-037 regress - regress regress. regress mpg weight foreign Source SS df MS Number of obs = 74 F(

Stata11 whitepapers mwp-037 regress - regress regress. regress mpg weight foreign Source SS df MS Number of obs = 74 F( mwp-037 regress - regress 1. 1.1 1.2 1.3 2. 3. 4. 5. 1. regress. regress mpg weight foreign Source SS df MS Number of obs = 74 F( 2, 71) = 69.75 Model 1619.2877 2 809.643849 Prob > F = 0.0000 Residual

More information

10

10 z c j = N 1 N t= j1 [ ( z t z ) ( )] z t j z q 2 1 2 r j /N j=1 1/ N J Q = N(N 2) 1 N j j=1 r j 2 2 χ J B d z t = z t d (1 B) 2 z t = (z t z t 1 ) (z t 1 z t 2 ) (1 B s )z t = z t z t s _ARIMA CONSUME

More information

1 Stata SEM LightStone 3 2 SEM. 2., 2,. Alan C. Acock, Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press.

1 Stata SEM LightStone 3 2 SEM. 2., 2,. Alan C. Acock, Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press. 1 Stata SEM LightStone 3 2 SEM. 2., 2,. Alan C. Acock, 2013. Discovering Structural Equation Modeling Using Stata, Revised Edition, Stata Press. 2 3 2 Conservative Depress. 3.1 2. SEM. 1. x SEM. Depress.

More information

講義のーと : データ解析のための統計モデリング. 第2回

講義のーと :  データ解析のための統計モデリング. 第2回 Title 講義のーと : データ解析のための統計モデリング Author(s) 久保, 拓弥 Issue Date 2008 Doc URL http://hdl.handle.net/2115/49477 Type learningobject Note この講義資料は, 著者のホームページ http://hosho.ees.hokudai.ac.jp/~kub ードできます Note(URL)http://hosho.ees.hokudai.ac.jp/~kubo/ce/EesLecture20

More information

untitled

untitled R 8 2 6 24 M1 M2 1 8 Takahashi, Y., Roberts, B.W., Yamagata, S., & Kijima, N. (in press). Personality traits show differential relations with anxiety and depression in a non-clinical sample. Psychologia:

More information

1 kawaguchi p.1/81

1 kawaguchi p.1/81 1 kawaguchi atsushi@kurume-u.ac.jp 2005 7 2 p.1/81 2.1 2.2 2.2.3 2.3 AUC 4.4 p.2/81 X Z X = α + βz + e α : Z = 0 X ( ) β : Z X ( ) e : 0 σ 2 p.3/81 2.1 Z X 1 0.045 2 0.114 4 0.215 6 0.346 7 0.41 8 0.52

More information

(iii) x, x N(µ, ) z = x µ () N(0, ) () 0 (y,, y 0 ) (σ = 6) *3 0 y y 2 y 3 y 4 y 5 y 6 y 7 y 8 y 9 y ( ) *4 H 0 : µ

(iii) x, x N(µ, ) z = x µ () N(0, ) () 0 (y,, y 0 ) (σ = 6) *3 0 y y 2 y 3 y 4 y 5 y 6 y 7 y 8 y 9 y ( ) *4 H 0 : µ t 2 Armitage t t t χ 2 F χ 2 F 2 µ, N(µ, ) f(x µ, ) = ( ) exp (x µ)2 2πσ 2 2 0, N(0, ) (00 α) z(α) t * 2. t (i)x N(µ, ) x µ σ N(0, ) 2 (ii)x,, x N(µ, ) x = x + +x ( N µ, σ2 ) (iii) (i),(ii) x,, x N(µ,

More information

H22 BioS (i) I treat1 II treat2 data d1; input group patno treat1 treat2; cards; ; run; I

H22 BioS (i) I treat1 II treat2 data d1; input group patno treat1 treat2; cards; ; run; I H BioS (i) I treat II treat data d; input group patno treat treat; cards; 8 7 4 8 8 5 5 6 ; run; I II sum data d; set d; sum treat + treat; run; sum proc gplot data d; plot sum * group ; symbol c black

More information

kubostat2017e p.1 I 2017 (e) GLM logistic regression : : :02 1 N y count data or

kubostat2017e p.1 I 2017 (e) GLM logistic regression : : :02 1 N y count data or kubostat207e p. I 207 (e) GLM kubo@ees.hokudai.ac.jp https://goo.gl/z9ycjy 207 4 207 6:02 N y 2 binomial distribution logit link function 3 4! offset kubostat207e (https://goo.gl/z9ycjy) 207 (e) 207 4

More information

: (EQS) /EQUATIONS V1 = 30*V F1 + E1; V2 = 25*V *F1 + E2; V3 = 16*V *F1 + E3; V4 = 10*V F2 + E4; V5 = 19*V99

: (EQS) /EQUATIONS V1 = 30*V F1 + E1; V2 = 25*V *F1 + E2; V3 = 16*V *F1 + E3; V4 = 10*V F2 + E4; V5 = 19*V99 218 6 219 6.11: (EQS) /EQUATIONS V1 = 30*V999 + 1F1 + E1; V2 = 25*V999 +.54*F1 + E2; V3 = 16*V999 + 1.46*F1 + E3; V4 = 10*V999 + 1F2 + E4; V5 = 19*V999 + 1.29*F2 + E5; V6 = 17*V999 + 2.22*F2 + E6; CALIS.

More information

untitled

untitled R (1) R & R 1. R Ver. 2.15.3 Windows R Mac OS X R Linux R 2. R R 2 Windows R CRAN http://cran.md.tsukuba.ac.jp/bin/windows/base/ R-2.15.3-win.exe http://cran.md.tsukuba.ac.jp/bin/windows/base/old/ 3 R-2.15.3-win.exe

More information

H22 BioS t (i) treat1 treat2 data d1; input patno treat1 treat2; cards; ; run; 1 (i) treat = 1 treat =

H22 BioS t (i) treat1 treat2 data d1; input patno treat1 treat2; cards; ; run; 1 (i) treat = 1 treat = H BioS t (i) treat treat data d; input patno treat treat; cards; 3 8 7 4 8 8 5 5 6 3 ; run; (i) treat treat data d; input group patno period treat y; label group patno period ; cards; 3 8 3 7 4 8 4 8 5

More information

kubostat2018d p.2 :? bod size x and fertilization f change seed number? : a statistical model for this example? i response variable seed number : { i

kubostat2018d p.2 :? bod size x and fertilization f change seed number? : a statistical model for this example? i response variable seed number : { i kubostat2018d p.1 I 2018 (d) model selection and kubo@ees.hokudai.ac.jp http://goo.gl/76c4i 2018 06 25 : 2018 06 21 17:45 1 2 3 4 :? AIC : deviance model selection misunderstanding kubostat2018d (http://goo.gl/76c4i)

More information

層化

層化 (confounding) Confounding Exposure? Outcome Confounders adjustment (confounders) Not Confounding? 2 exposure 3rd factor 3rd factor NEJM 2000; 342: 1930-6. (adjustment) univariate or crude relative risk

More information

80 X 1, X 2,, X n ( λ ) λ P(X = x) = f (x; λ) = λx e λ, x = 0, 1, 2, x! l(λ) = n f (x i ; λ) = i=1 i=1 n λ x i e λ i=1 x i! = λ n i=1 x i e nλ n i=1 x

80 X 1, X 2,, X n ( λ ) λ P(X = x) = f (x; λ) = λx e λ, x = 0, 1, 2, x! l(λ) = n f (x i ; λ) = i=1 i=1 n λ x i e λ i=1 x i! = λ n i=1 x i e nλ n i=1 x 80 X 1, X 2,, X n ( λ ) λ P(X = x) = f (x; λ) = λx e λ, x = 0, 1, 2, x! l(λ) = n f (x i ; λ) = n λ x i e λ x i! = λ n x i e nλ n x i! n n log l(λ) = log(λ) x i nλ log( x i!) log l(λ) λ = 1 λ n x i n =

More information

st.dvi

st.dvi 9 3 5................................... 5............................. 5....................................... 5.................................. 7.........................................................................

More information

AR(1) y t = φy t 1 + ɛ t, ɛ t N(0, σ 2 ) 1. Mean of y t given y t 1, y t 2, E(y t y t 1, y t 2, ) = φy t 1 2. Variance of y t given y t 1, y t

AR(1) y t = φy t 1 + ɛ t, ɛ t N(0, σ 2 ) 1. Mean of y t given y t 1, y t 2, E(y t y t 1, y t 2, ) = φy t 1 2. Variance of y t given y t 1, y t 87 6.1 AR(1) y t = φy t 1 + ɛ t, ɛ t N(0, σ 2 ) 1. Mean of y t given y t 1, y t 2, E(y t y t 1, y t 2, ) = φy t 1 2. Variance of y t given y t 1, y t 2, V(y t y t 1, y t 2, ) = σ 2 3. Thus, y t y t 1,

More information

untitled

untitled IT (1, horiike@ml.me.titech.ac.jp) (1, jun-jun@ms.kagu.tus.ac.jp) 1. 1-1 19802000 2000ITIT IT IT TOPIX (%) 1TOPIX 2 1-2. 80 80 ( ) 2004/11/26 S-PLUS 2 1-3. IT IT IT IT 2. 2-1. a. b. (Size) c. B/M(Book

More information

linguistics

linguistics R @ linguistics 2007/08/24 ( ) R @ linguistics 2007/08/24 1 / 24 1 2 R 3 R 4 5 ( ) R @ linguistics 2007/08/24 2 / 24 R R: ( ) R @ linguistics 2007/08/24 3 / 24 R Life is short. Use the command line. (Crawley

More information

4 OLS 4 OLS 4.1 nurseries dual c dual i = c + βnurseries i + ε i (1) 1. OLS Workfile Quick - Estimate Equation OK Equation specification dual c nurser

4 OLS 4 OLS 4.1 nurseries dual c dual i = c + βnurseries i + ε i (1) 1. OLS Workfile Quick - Estimate Equation OK Equation specification dual c nurser 1 EViews 2 2007/5/17 2007/5/21 4 OLS 2 4.1.............................................. 2 4.2................................................ 9 4.3.............................................. 11 4.4

More information

1 Amazon.co.jp *1 5 review *2 web Google web web 5 web web 5 (a) (b) (c) 3 S-PLUS S S-PLUS 1 S-PLUS S R R RMeCab *3 R term matrix S-PLUS S-PLUS *1 Ama

1 Amazon.co.jp *1 5 review *2 web Google web web 5 web web 5 (a) (b) (c) 3 S-PLUS S S-PLUS 1 S-PLUS S R R RMeCab *3 R term matrix S-PLUS S-PLUS *1 Ama 5 1 2 2 3 2.1....................................... 3 2.2............................... 4 2.3....................................... 5 2.4................................ 5 3 6 3.1.........................................

More information

Rを用いた生物統計解析入門

Rを用いた生物統計解析入門 R を用いた生物統計解析入門 2006 年 5 月 26 日日本計量生物学会チュートリアルセミナー ( 於 国立保健医療科学院 ) 群馬大学大学院医学系研究科社会環境医療学講座生態情報学中澤港 May 26, 2006 / Slide 1 本日の目的 聴衆としては, SAS ユーザを想定 既に SAS で統計処理をする方法や, 統計の理論はわかっている方が対象 したがって, 統計の詳しい説明はしない

More information

( )/2 hara/lectures/lectures-j.html 2, {H} {T } S = {H, T } {(H, H), (H, T )} {(H, T ), (T, T )} {(H, H), (T, T )} {1

( )/2   hara/lectures/lectures-j.html 2, {H} {T } S = {H, T } {(H, H), (H, T )} {(H, T ), (T, T )} {(H, H), (T, T )} {1 ( )/2 http://www2.math.kyushu-u.ac.jp/ hara/lectures/lectures-j.html 1 2011 ( )/2 2 2011 4 1 2 1.1 1 2 1 2 3 4 5 1.1.1 sample space S S = {H, T } H T T H S = {(H, H), (H, T ), (T, H), (T, T )} (T, H) S

More information

newmain.dvi

newmain.dvi 数論 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/008142 このサンプルページの内容は, 第 2 版 1 刷発行当時のものです. Daniel DUVERNEY: THÉORIE DES NOMBRES c Dunod, Paris, 1998, This book is published

More information

PackageSoft/R-033U.tex (2018/March) R:

PackageSoft/R-033U.tex (2018/March) R: ................................................................................ R: 2018 3 29................................................................................ R AI R https://cran.r-project.org/doc/contrib/manuals-jp/r-intro-170.jp.pdf

More information

GLM PROC GLM y = Xβ + ε y X β ε ε σ 2 E[ε] = 0 var[ε] = σ 2 I σ 2 0 σ 2 =... 0 σ 2 σ 2 I ε σ 2 y E[y] =Xβ var[y] =σ 2 I PROC GLM

GLM PROC GLM y = Xβ + ε y X β ε ε σ 2 E[ε] = 0 var[ε] = σ 2 I σ 2 0 σ 2 =... 0 σ 2 σ 2 I ε σ 2 y E[y] =Xβ var[y] =σ 2 I PROC GLM PROC MIXED ( ) An Introdunction to PROC MIXED Junji Kishimoto SAS Institute Japan / Keio Univ. SFC / Univ. of Tokyo e-mail address: jpnjak@jpn.sas.com PROC MIXED PROC GLM PROC MIXED,,,, 1 1.1 PROC MIXED

More information

p.1/22

p.1/22 p.1/22 & & & & Excel / p.2/22 & & & & Excel / p.2/22 ( ) ( ) p.3/22 ( ) ( ) Baldi Web p.3/22 ( ) ( ) Baldi Web ( ) ( ) ( p.3/22 ) Text Mining for Clementine True Teller Text Mining Studio Text Miner Trustia

More information

10:30 12:00 P.G. vs vs vs 2

10:30 12:00 P.G. vs vs vs 2 1 10:30 12:00 P.G. vs vs vs 2 LOGIT PROBIT TOBIT mean median mode CV 3 4 5 0.5 1000 6 45 7 P(A B) = P(A) + P(B) - P(A B) P(B A)=P(A B)/P(A) P(A B)=P(B A) P(A) P(A B) P(A) P(B A) P(B) P(A B) P(A) P(B) P(B

More information

橡表紙参照.PDF

橡表紙参照.PDF CIRJE-J-58 X-12-ARIMA 2000 : 2001 6 How to use X-12-ARIMA2000 when you must: A Case Study of Hojinkigyo-Tokei Naoto Kunitomo Faculty of Economics, The University of Tokyo Abstract: We illustrate how to

More information

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè2²ó

¥¤¥ó¥¿¡¼¥Í¥Ã¥È·×¬¤È¥Ç¡¼¥¿²òÀÏ Âè2²ó 2 2015 4 20 1 (4/13) : ruby 2 / 49 2 ( ) : gnuplot 3 / 49 1 1 2014 6 IIJ / 4 / 49 1 ( ) / 5 / 49 ( ) 6 / 49 (summary statistics) : (mean) (median) (mode) : (range) (variance) (standard deviation) 7 / 49

More information

i

i 2012 i 1 1 1.1.................................. 1 1.2................................. 2 1.3.................................. 4 1.4.................................. 5 2 7 2.1....................................

More information

第11回:線形回帰モデルのOLS推定

第11回:線形回帰モデルのOLS推定 11 OLS 2018 7 13 1 / 45 1. 2. 3. 2 / 45 n 2 ((y 1, x 1 ), (y 2, x 2 ),, (y n, x n )) linear regression model y i = β 0 + β 1 x i + u i, E(u i x i ) = 0, E(u i u j x i ) = 0 (i j), V(u i x i ) = σ 2, i

More information

2.1 R, ( ), Download R for Windows base. R ( ) R win.exe, 2.,.,.,. R > 3*5 # [1] 15 > c(19,76)+c(11,13)

2.1 R, ( ),   Download R for Windows base. R ( ) R win.exe, 2.,.,.,. R > 3*5 # [1] 15 > c(19,76)+c(11,13) 3 ( ) R 3 1 61, 2016/4/7( ), 4/14( ), 4/21( ) 1 1 2 1 2.1 R, ( )................ 2 2.2 ggm............................ 3 2.3,................ 4 2.4...................................... 6 2.5 1 ( )....................

More information

情報管理学科で学ぶ

情報管理学科で学ぶ 1/17 ` http://www.biwako.shiga-u.ac.jp/sensei/kumazawa/ 6............................................ 5 1............................... 1 1.1 I II III 1 1.2 2 1.3 2 2......................................

More information

ECCS. ECCS,. ( 2. Mac Do-file Editor. Mac Do-file Editor Windows Do-file Editor Top Do-file e

ECCS. ECCS,. (  2. Mac Do-file Editor. Mac Do-file Editor Windows Do-file Editor Top Do-file e 1 1 2015 4 6 1. ECCS. ECCS,. (https://ras.ecc.u-tokyo.ac.jp/guacamole/) 2. Mac Do-file Editor. Mac Do-file Editor Windows Do-file Editor Top Do-file editor, Do View Do-file Editor Execute(do). 3. Mac System

More information

seminar0220a.dvi

seminar0220a.dvi 1 Hi-Stat 2 16 2 20 16:30-18:00 2 2 217 1 COE 4 COE RA E-MAIL: ged0104@srv.cc.hit-u.ac.jp 2004 2 25 S-PLUS S-PLUS S-PLUS S-code 2 [8] [8] [8] 1 2 ARFIMA(p, d, q) FI(d) φ(l)(1 L) d x t = θ(l)ε t ({ε t }

More information

日本統計学会誌, 第44巻, 第2号, 251頁-270頁

日本統計学会誌, 第44巻, 第2号, 251頁-270頁 44, 2, 205 3 25 270 Multiple Comparison Procedures for Checking Differences among Sequence of Normal Means with Ordered Restriction Tsunehisa Imada Lee and Spurrier (995) Lee and Spurrier (995) (204) (2006)

More information

分布

分布 (normal distribution) 30 2 Skewed graph 1 2 (variance) s 2 = 1/(n-1) (xi x) 2 x = mean, s = variance (variance) (standard deviation) SD = SQR (var) or 8 8 0.3 0.2 0.1 0.0 0 1 2 3 4 5 6 7 8 8 0 1 8 (probability

More information

Presentation Title Goes Here

Presentation  Title Goes Here SAS 9: (reprise) SAS Institute Japan Copyright 2004, SAS Institute Inc. All rights reserved. Greetings, SAS 9 SAS 9.1.3 Copyright 2004, SAS Institute Inc. All rights reserved. 2 Informations of SAS 9 SAS

More information

一般化線型モデルとは? R 従属変数群が独立変数群の一次結合と誤差で表されるという形のモデルを線型モデルという ( 回帰分析はデータへの線型モデルの当てはめである ) 式で書けば Y = β 0 + βx + ε R では glm( ) という関数で実行する glm( ) は量的なデータが正規分布に

一般化線型モデルとは? R 従属変数群が独立変数群の一次結合と誤差で表されるという形のモデルを線型モデルという ( 回帰分析はデータへの線型モデルの当てはめである ) 式で書けば Y = β 0 + βx + ε R では glm( ) という関数で実行する glm( ) は量的なデータが正規分布に 統計学第 13 回 一般化線型モデル入門 中澤港 http://phi.ypu.jp/stat.html R 一般化線型モデルとは? R 従属変数群が独立変数群の一次結合と誤差で表されるという形のモデルを線型モデルという ( 回帰分析はデータへの線型モデルの当てはめである ) 式で書けば Y = β 0 + βx + ε R では glm( ) という関数で実行する

More information

鉄鋼協会プレゼン

鉄鋼協会プレゼン NN :~:, 8 Nov., Adaptive H Control for Linear Slider with Friction Compensation positioning mechanism moving table stand manipulator Point to Point Control [G] Continuous Path Control ground Fig. Positoining

More information

1 Tokyo Daily Rainfall (mm) Days (mm)

1 Tokyo Daily Rainfall (mm) Days (mm) ( ) r-taka@maritime.kobe-u.ac.jp 1 Tokyo Daily Rainfall (mm) 0 100 200 300 0 10000 20000 30000 40000 50000 Days (mm) 1876 1 1 2013 12 31 Tokyo, 1876 Daily Rainfall (mm) 0 50 100 150 0 100 200 300 Tokyo,

More information

Microsoft Word - 計量研修テキスト_第5版).doc

Microsoft Word - 計量研修テキスト_第5版).doc Q9-1 テキスト P166 2)VAR の推定 注 ) 各変数について ADF 検定を行った結果 和文の次数はすべて 1 である 作業手順 4 情報量基準 (AIC) によるラグ次数の選択 VAR Lag Order Selection Criteria Endogenous variables: D(IG9S) D(IP9S) D(CP9S) Exogenous variables: C Date:

More information