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

Similar documents
「統 計 数 学 3」

DAA04

DAA02

Use R

linguistics

DAA03

宿題の解答

Debian での数学ことはじめ。 - gnuplot, Octave, R 入門

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回

<4D F736F F F696E74202D2088E D8C768A7789C482CC8A778D5A F939D8C76835C FC96E52E >

(lm) lm AIC 2 / 1

R-introduction.R

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

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

DAA01

lec03

q( ) 2: R 2 R R R R C:nProgram FilesnRnrw1030) [File] [Change Dir] c:ndatadir OK 2

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

R分散分析06.indd

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

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

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

第1回(全5回) 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

plot type type= n text plot type= n text(x,y) iris 5 iris iris.label >iris.label<-rep(c(,, ),rep(50,3)) 2 13 >plot(iris[,1],iris

untitled

untitled

RとExcelを用いた分布推定の実践例

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


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

R による統計解析入門

untitled

untitled

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


Microsoft PowerPoint - 統計科学研究所_R_重回帰分析_変数選択_2.ppt


untitled

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

R Commanderを用いたデータ解析

DAA12

Excelfl—‘ãŁª’Í-flO“Z

バイオインフォマティクス特論12

Microsoft PowerPoint - Econometrics

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

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

2 2 GDP( ) 1 () 143,694 47,186 48,997 38,371 36,559 44,519 28,565 44,550 26,526 43,237 23,031 38,455 15,945 34,971 14,996 44,950 10,852 10,183 10,337

こんにちは由美子です

GraphicsWithPlotFull.nb Plot[{( 1), ( ),...}, {( ), ( ), ( )}] Plot Plot Cos x Sin x, x, 5 Π, 5 Π, AxesLabel x, y x 1 Plot AxesLabel

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

DAA09

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

5 5.1 A B mm 0.1mm Nominal Scale 74

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

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) - ロジスティック回帰と GLMM

untitled

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

Microsoft PowerPoint - R-intro-02.ppt

こんにちは由美子です

こんにちは由美子です

情報工学概論

pp R R Word R R R R Excel SPSS R Microsoft Word 2016 OS Windows7 Word2010 Microsoft Office2010 R Emacs ESS R R R R https:

分布

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

Rプログラミング

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

: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac

Rとは 統計言語であるSの思想に基づいて開発されたフリーのソフ トウェア ウェブから誰でも無料で入手できる 多様なプラットフォームに対応 Unix系OS Mac OS X, Windows 豊富なパッケージ群 パッケージ 共通の目的を達成するための関

1 2 Sample Sample Sample 3 1

untitled

R int num factor character 1 2 (dichotomous variable) (trichotomous variable) 3 (nominal scale) M F 1 2 coding as.numeric() as.integer() 2


取扱説明書 [F-05E]

.3 ˆβ1 = S, S ˆβ0 = ȳ ˆβ1 S = (β0 + β1i i) β0 β1 S = (i β0 β1i) = 0 β0 S = (i β0 β1i)i = 0 β1 β0, β1 ȳ β0 β1 = 0, (i ȳ β1(i ))i = 0 {(i ȳ)(i ) β1(i ))

初心者用

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 (

kubostat2017b p.1 agenda I 2017 (b) probability distribution and maximum likelihood estimation :

untitled

橡00扉.PDF

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

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 LATEX 2ε 2010

表1-表4_No78_念校.indd

untitled

untitled

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

1 15 R Part : website:

R による心理学研究法入門 5 章教育測定に関する実証研究 2015/07/15( ) D1 D1 1

スライド 1


数量的アプローチ 年 6 月 11 日 イントロダクション データ分析をマスターする 12 のレッスン ウェブサポートページ ( 有斐閣 ) 水落研究室 R http:

<4D F736F F F696E74202D BD95CF97CA89F090CD F6489F18B4195AA90CD816A>

Microsoft PowerPoint - Rによる演習v2.ppt [互換モード]

2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa

dicutil1_5_2.book

Transcription:

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 [R-2.5.1-win32.exe] 1.2 R Windows R [ ] [OK] R web 1

1.3 R web 1. RjpWiki http://www.okada.jp.org/rwiki/ 2. R-Tips http://cse.naro.affrc.go.jp/takezawa/r-tips/r.html 3. R http://aoki2.si.gunma-u.ac.jp/r/ 4. R R R http://www1.doshisha.ac.jp/ mjin/r/index.html R URL1 web URL2 R 1 URL3 web 1 URL4 R PDF 2 R 2.1 R R Microsoft Excel R R > R 2

> 12 + 3-67 # [1] -52 > 3 * 90 / 45 # [1] 6 > sqrt(2) # sqrt() [1] 1.414214 # 2 sqrt() 5 R > 12 ^ 2 # [1] 144 > sin(1) #sin" " [1] 0.841471 > cos(5) #cos" " [1] 0.2836622 > tan(3) #tan" " [1] -0.1425465 > log10(12) # ( 10 ) [1] 1.079181 > exp(1) # [1] 2.718282 R 3

+, -, *, / 2.2 R > a <- 244 # a > a # [1] 244 > b <- 0.12345 # b > b [1] 0.12345 > c <- "Katasho" # c > c [1] "Katasho" 1 1 R 4

> a <- c(1, 2, 3, 4, 5) # > a [1] 1 2 3 4 5 > b <- c("a", "b", "c", "d", "e") # > b [1] "a" "b" "c" "d" "e" > c <- c(1, "b", 3, "d", 5) # > c [1] "1" "b" "3" "d" "5" 1 c() 1 c 1 244 a a [1, 2, 3, 4, 5] 5 244 a [1, 2, 3, 4, 5] a 5 1 1 5

> dat <- matrix(c( + 1, 2, 3, + 4, 5, 6, + 7, 8, 9), nrow=3, ncol=3, byrow=t) > dat [,1] [,2] [,3] [1,] 1 2 3 [2,] 4 5 6 [3,] 7 8 9 > dat2 <- matrix(c( + 1, 2, 3, + 4, 5, 6, + 7, 8, 9), ncol=3) > dat2 [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 matrix() 2 matrix() nrow=3 3 ncol=3 3 3 3 ncol byrow byrow=t dat2 1 6

> dat4 <- cbind(x1, x2, x3) # cbind() > dat4 x1 x2 x3 [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > dat5 <- rbind(x1, x2, x3) # rbind() > dat5 [,1] [,2] [,3] x1 1 2 3 x2 4 5 6 x3 7 8 9 7

> my.data <- data.frame(x1 = x1, X2 = x2, Y = x3) # > my.data X1 X2 Y 1 1 4 7 2 2 5 8 3 3 6 9 > attach(my.data) #my.data > X1 [1] 1 2 3 > X2 [1] 4 5 6 > Y [1] 7 8 9 > detach(my.data) # > X1 "X1" attach() detach() detach() 2.3 R 8

> dat <- rnorm(100, mean=50, sd=10) > mean(dat) # [1] 49.10156 > median(dat) # [1] 50.10624 > var(dat) # [1] 104.4191 > sd(dat) # [1] 10.21857 > dat2 <- rnorm(100, mean=100, sd=20) > var(dat, dat2) # [1] -34.2106 > cor(dat, dat2) # [1] -0.1832966 3 3.1 t t t 2 2 2 R R t t.test() paired paired=false t t var.equal=false 9

> group1 <- c(56, 49, 59, 42, 58, 61, 53) # > group2 <- c(73, 86, 54, 60, 65, 70, 53) # > t.test(group1, group2, var.equal=false) # t Welch Two Sample t-test data: group1 and group2 t = -2.3395, df = 9.518, p-value = 0.04259 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -23.2278060-0.4864797 sample estimates: mean of x mean of y 54.00000 65.85714 > t.test(group1, group2, paired=true) # t Paired t-test data: group1 and group2 t = -2.2632, df = 6, p-value = 0.06427 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -24.6769481 0.9626624 sample estimates: mean of the differences -11.85714 3.2 1 1 summary() aov() 1 2 3 10

10 1 > #1 > class.one <- c(3.9, 3.8, 3.6, 4.4, 4.7, 3.5, 3.7, 4.6, 3.9, 3.6) > #2 > class.two <- c(5.8, 4.4, 4.5, 6.4, 4.9, 7.2, 4.8, 5.7, 5.6, 3.4) > #3 > class.thr <- c(6.0, 5.8, 6.1, 5.6, 6.2, 6.0, 6.1, 5.7, 6.4, 5.9) > group <- as.factor(rep(c(1, 2, 3), c(10, 10, 10))) # > # > my.data <- data.frame( + Y = c(class.one, class.two, class.thr), X = group) > result <- summary(aov(y ~ X, my.data)) # result > result # Df Sum Sq Mean Sq F value Pr(>F) X 2 20.7807 10.3903 21.55 2.548e-06 *** Residuals 27 13.0180 0.4821 --- Signif. codes: 0 *** 0.001 ** 0.01 * 0.05. 0.1 1 t R web web 11

4 R Excel > x <- rnorm(100) > y <- rnorm(100) > plot(x, y) # > plot(x, y, xlim=c(-3,3), ylim=c(-3,3)) #x y > plot(x, y, xlab=" ", ylab=" ") #x y > plot(x, y, col="red", pch=18) # (col) (pch) R plot() plot() plot() > x <- 1:6 > y <- c(1, 5, 6, 3, 9, 10) > plot(x, y, type="b") # > plot(x, y, type="b", lty=2) # plot() type type= l type= s type= n plot() barplot() 12

# 1 > x <- c(12, 34, 72, 56, 20) > names(x) <- c("a1", "A2", "A3", "A4", "A5") > barplot(x, col="blue") > abline(h=0) # 2 > y <- c(17, 34, 69, 32, 12) > mat <- rbind(x, y) > mat A1 A2 A3 A4 A5 x 12 34 72 56 20 y 17 34 69 32 12 > barplot(mat, beside=true, col=c("blue", "red")) > legend(2, 60, + paste(c(" "," ")), + fill=c("blue", "red")) # k 3 > g1 <- rnorm(10, 10, 1) > g2 <- rnorm(10, 20, 1) > g3 <- rnorm(10, 5, 1) > #x > plot(x, c(g1,g2,g3), xlab="group", ylab="score", xaxt="n") > axis(1, at=1:3, label=c("g1", "g2", "g3")) #x > M <- c(mean(g1), mean(g2), mean(g3)) # > x.jiku <- 1:3 # x > points(x.jiku, M, pch=3, col="red", type="b") # 13

5 5.1 (1) (2) (3) 3 mean() mean () ( ) { } 5.2 pow 1 pow(2) 2 2 = 4 # pow() pow <- function(x){ } res <- x ^ 2 res # > pow(2)#2 [1] 4 > pow(12) #12 [1] 144 1 14

# pow2 pow2 <- function(x, y){ res <- x ^ y res } # > pow2(2, 4) #2 4 [1] 16 > pow2(2, -4) #2-4 [1] 0.0625 R Windows R [ ][ ] R R sd() sd() } sd2 <- function(x){ var2 <- function(x){ } # x if(is.vector(x)) n <- length(x) # x if(is.matrix(x)) n <- nrow(x) var2 <- var(x) * (n-1) / n # sd2 <- sqrt(var2(x)) # var2 sd2 15

1 R R 5.3 R 1 1 2 3 Excel R plot() #1 one.func <- function(x){ } 2*x + 1 # > plot(one.func) 1 3 1 > thr.func <- function(x) 3*x^3-0.5*x^2 + sqrt(x) + (3/4) > plot(thr.func) plot() points() legend() lwd 16

> plot(thr.func, xlim=c(-2,2), ylim=c(-5,5)) #thr.func plot() > abline(h=0) # x > abline(v=0) # y > x.dat <- seq(-2, 2, 0.1) #one.func x > points(x.dat, 2*x.dat+1, type="l", col="pink") #points() > legend(-1.5, 4, + c("one.func", "thr.func"), lwd=2, + col=c("black", "pink")) # 17