DAA02

Similar documents
DAA03

DAA04

DAA01

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

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

「統 計 数 学 3」

DAA12

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

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

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


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

Microsoft PowerPoint - R-intro-02.ppt

DAA09

5 LATEX 2ε 2010

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

PowerPoint Presentation

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

宿題の解答

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

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

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

<4D F736F F F696E74202D2088E D8C768A7789C482CC8A778D5A F939D8C76835C FC96E52E >

II - ( 02 ) 1,,,, 2, 3. ( ) HP,. 2 MATLAB MATLAB, C Java,,., MATLAB, Workspace, Workspace. Workspace who. whos. MATLAB, MATLAB Workspace. 2.1 Workspac

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

teji010

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

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

レジャー産業と顧客満足の課題

lec03

スライド 1

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

<4D F736F F F696E74202D BD95CF97CA89F090CD F6489F18B4195AA90CD816A>


掲示用ヒート表 第34回 藤沢市長杯 2017

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:

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

untitled

再下版島_ (特集1).indd

INTERVIEW

.{...iNo.25.j

Interview 2 3

窶廰ナ・ア窶。X窶樞€昶€愴・.3

鹿大広報148号

鹿大広報151


海生研ニュース

sarupaw.dvi


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

★結果★ 藤沢市長杯 掲示用ヒート表

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

2017_Eishin_Style_H01

81

タイの食品市場(国庫用)訂正.PDF

なぜRでグラフを 書 くの? 1.グラフがきれい 2. 書 き 直 しが 簡 単 3. 同 じようなグラフを 簡 単 に 書 ける

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

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


好きですまえばし


R-introduction.R

Studies of Foot Form for Footwear Design (Part 9) : Characteristics of the Foot Form of Young and Elder Women Based on their Sizes of Ball Joint Girth

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

表紙01


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

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


Use R

第32回新春波乗り大会2018


4 100g

... 6

裁定審議会における裁定の概要 (平成23年度)

和県監査H15港湾.PDF


日本経大論集 第45巻 第1号


untitled

クレイによる、主婦湿疹のケア

(3)(4) (3)(4)(2) (1) (2) 20 (3)

untitled

群馬県野球連盟


<82B582DC82CB8E7188E782C48A47967B41342E696E6464>

untitled




<91E F1938C966B95FA8ECB90FC88E397C38B5A8F708A778F7091E589EF8EC08D7388CF88F5837D836A B E696E6464>

Microsoft Word - 入居のしおり.doc

untitled

( )

ESPEC Technical Report 12

syogaku

-26-

Taro12-希少樹種.jtd

untitled

河川砂防技術基準・基本計画編.PDF

Transcription:

c(var1,var2,...,varn) > x<-c(1,2,3,4) > x [1] 1 2 3 4 > x2<-c(x,5,6,7,8) > x2 [1] 1 2 3 4 5 6 7 8

c(var1,var2,...,varn) > y=c('a0','a1','b0','b1') > y [1] "a0" "a1" "b0" "b1 > z=c(x,y) > z [1] "1" "2" "3" "4" "a0" "a1" "b0" "b1"

rep(x, times) > x<-rep(1,4) (1) [1] 1 1 1 1 > x<-rep(c(1,7,87),3) (2) [1,7,87] [1] 1 7 87 1 7 87 1 7 87 > x<-rep(1:4,3) (3) 1:4 seq [1] 1 2 3 4 1 2 3 4 1 2 3 4 > x<-sort(rep(1:4,3)) (4) (3) [1] 1 1 1 2 2 2 3 3 3 4 4 4

seq(start, end, increment/decrement) > x<-seq(1,4,1) [1] 1 2 3 4 > x<-seq(0,40,10) [1] 0 10 20 30 40 > x<-seq(10,2,-2) [1] 10 8 6 4 2 > x<-1:4 # [1] 1 2 3 4 > x<-10:1 # - [1] 10 9 8 7 6 5 4 3 2 1

> a=1:10 [1] 1 2 3 4 5 6 7 8 9 10 > which(a<5) [1] 1 2 3 4 > b=10:1 [1] 10 9 8 7 6 5 4 3 2 1 > which(b<5) [1] 7 8 9 10

> x<-matrix(1:8, nrow=2) [,1] [,2] [,3] [,4] [1,] 1 3 5 7 [2,] 2 4 6 8 > x<-matrix(1:8, nrow=2,byrow=t) [,1] [,2] [,3] [,4] [1,] 1 2 3 4 [2,] 5 6 7 8

data01<-data.frame(score = c(2,4,3,4), dose = c(rep(10,2),rep(100,2)), condition = rep(c('exp','control'),2)) > data01 score dose condition 1 2 10 exp 2 4 10 control 3 3 100 exp 4 4 100 control

dat01<-read.csv("http://www.matsuka.info/data_folder/temp_data01.txt", header=t) > dat01 x y z 1 11 12 13 2 21 22 23 3 31 32 33

dat02<-read.csv("http://www.matsuka.info/data_folder/temp_data02.txt", header=t, row.name=1) > dat02 x y z katsuo 11 12 13 wakame 21 22 23 tarachan 31 32 33

> dat03<-read.table("http://www.matsuka.info/data_folder/temp_data03.txt", header=t, row.name=4) > dat03 x y z sazae 11 12 13 masuo 21 22 23 tarachan 31 32 33

matrix M[ ] > dat03 x y z sazae 11 12 13 masuo 21 22 23 tarachan 31 32 33 > dat03[1,1] #1 1 [1] 11

n M[n, ] m M[, m] > dat03 x y z sazae 11 12 13 masuo 21 22 23 tarachan 31 32 33 > dat03[2,] # x y z masuo 21 22 23 > dat03[,1] #1 [1] 11 21 31

M$varName > dat03 x y z sazae 11 12 13 masuo 21 22 23 tarachan 31 32 33 > dat03$x [1] 11 21 31 > dat03$y [1] 12 22 32 > dat03$z [1] 13 23 33

> dat03 x y z sazae 11 12 13 masuo 21 22 23 tarachan 31 32 33 > colnames(dat03)<-c("var1","var2","var3") > dat03 var1 var2 var3 sazae 11 12 13 masuo 21 22 23 tarachan 31 32 33

Dat03 score dat03 var1 var2 var3 Name Conditionn, var1, var2, var3 > dat04 score name condition 1 11 sazae var1 > dat03 2 21 masuo var2 var1 var2 var3 3 31 tarachan var3 sazae 11 12 13 4 12 sazae var1 masuo 21 22 23 5 22 masuo var2 6 32 tarachan var3 tarachan 31 32 33 7 13 sazae var1 8 23 masuo var2 9 33 tarachan var3

score var1 var2 var3 Name Conditionn, var1, var2, var3 > dat04<-data.frame(score=c(dat03$var1,dat03$var2,dat03$var3), name=rep(rownames(dat03),3), condition = rep(c("var1","var2","var3"),3))

dat<-read.csv("http://www.matsuka.info/data_folder/datwa01.txt", > head(dat) shoesize header=t); h gender 1 27.0 181.4 M 2 26.5 170.8 M 3 27.5 182.3 M 4 26.5 166.8 M 5 23.5 153.2 F 6 23.0 151.6 F > head(dat) shoesize height (meter) gender 1 27.0 1.814 M 2 26.5 1.708 M 3 27.5 1.823 M 4 26.5 1.668 M 5 23.5 1.532 F 6 23.0 1.516 F

mean(dat$shoesize[dat$gender == "M"]) [1] 25.98529 # mean(dat$shoesize[dat$gender == "F"]) [1] 23.72222 # mean(dat$shoesize[dat$h > 180]) [1] 27.5 # 180cm

v1 = seq(-3,3,0.1) v2 = v1^2 > plot(x = v1, y = v2) y 0 2 4 6 8-3 -2-1 0 1 2 3 x col= color > plot(v1, v2, col = 'red') y 0 2 4 6 8-3 -2-1 0 1 2 3 x

marker pch = N > plot(v1, v2, col= red ) > plot(v1, v2, col= red, pch = 20) # N: 0~25 # help(points)

marker cex = N > plot(v1, v2, col= red, pch = 20) > plot(v1, v2, col= red, pch = 20, cex = 3)

1 2 3 4 5 21 22 23 24 25 16 17 18 19 20 11 12 13 14 15 6 7 8 9 10 1 2 3 4 5 1 2 3 4 5

type= style > plot(v1, v2) > plot(v1, v2, type = l ) # style: p:points l:line b:both (points & line) o:overlay (points & line) n:none

lty = N #N: 1~6 lwd = W > plot(v1,v2,type='l',lty=4,lwd=3) y 0 2 4 6 8-3 -2-1 0 1 2 3 x

plot(v1, v2, main = "THIS IS THE TITLE", xlab = "Label for X-axis", ylab = "Label for Y-axis") THIS IS THE TITLE Label for Y-axis 0 2 4 6 8-3 -2-1 0 1 2 3 Label for X-axis

plot(v1, v2, main = "THIS IS THE TITLE", cex.lab = 1.5, xlab = "Label for X-axis",ylab = "Label for Y-axis")

X Y plot(v1, v2, main = "TITLE", xlab = "X here",ylab = "Y here", xlim = c(-3.5, 3.5), TITLE ylim = c(-0.5, 10)) Label for Y-axis 0 2 4 6 8 THIS IS THE TITLE -3-2 -1 0 1 2 3 Y here 0 2 4 6 8 10 Label for X-axis -3-2 -1 0 1 2 3 X here

plot(v1, v2, col = "blue", type = "o", lty = 2, pch = 19, cex.lab = 1.5, lwd = 3, main = "Y=X*X", xlab = "X", ylab="x*x", xlim=c(-3.5,3.5), ylim=c(-0.5, 10))

Histogram > dat<- read.csv("http://www.matsuka.info/data_folder/datwa01.txt") > hist(dat$h)

Histogram > hist(dat$h, breaks = 20, main = Histogram of Height, xlab = "Height", col = 'blue', xlim = c(140, 190))

dens<-density(dat$h); # hist(dat$h, main = "Histogram of Height", xlab = "Height", xlim = c(140,190), probability = T) lines(dens, lwd = 2, col = red, lty=2) # Histogram of Height Density 0.00 0.01 0.02 0.03 0.04 140 150 160 170 180 190 Height

#lines plot(v1, v2, col = "blue", type = "l", pch = 19, cex.lab = 1.5, lwd = 3, xlab = "X", ylab="f(x)", xlim=c(-3.5,3.5), ylim=c(-0.5, 10)) lines(v1, v1^3, col='red',lwd = 3)

#legend legend("bottomright", c("x^2","x^3"), col=c('blue','red'), lwd=2)

> boxplot(dat$h,main="boxplot of Height", ylab="height", col='cyan', ylim=c(140,190)) > boxplot(dat$h,main="boxplot of Height", xlab="height", col= ornage', horizontal=t) Boxplot of Height Height 140 150 160 170 180 190

http://www.stat.columbia.edu/~tzheng/files/rcolor.pdf

boxplot(dat$h ~ dat$gender, main="distribution of Height by Gender", ylab="gender", xlab="height", col=c('blue','cyan'), ylim=c(140,190), horizontal=t) Distribution of Height by Gender Gender F M 140 150 160 170 180 190

dat<-read.table("http://www.matsuka.info/data_folder/aov01.txt") boxplot(dat$h ~ dat$gender + dat$affil, main="distribution of Height by Gender and Affiliation", ylab="gender x Affiliation", xlab="height", col=c('blue,'cyan,'red,'magenta'), ylim=c(140,190),horizontal=t) Distribution of Height by Gender and Affiliation Gender x Affiliation F.cs M.cs F.psy M.psy 140 150 160 170 180 190 Height

interaction.plot(dat$gender, dat$affil, dat$h, Y pch=c(20,20), col=c("skyblue","orange"), xlab="gender", ylab= height", lwd=3,type='b',cex=2, trace.label="affiliation") Legend X

Distribution of Height by Gender and Affiliation Gender x Affiliation F.cs M.cs F.psy M.psy 140 150 160 170 180 190 Height

HISTOGRAM par(mfrow=c(1,2)) # figure Dist. of Height for Female Participants Dist. of Height for Male Participants Density 0.00 0.02 0.04 0.06 0.08 Density 0.00 0.02 0.04 0.06 0.08 140 150 160 170 180 190 Height 140 150 160 170 180 190 Height

HISTOGRAM hist(dat[dat$gender=='f',]$h, main="dist. of Height for Female Participants", xlab="height", xlim=c(140,190), probability=t) dens.f = density(dat[dat$gender=='f',]$h) lines(dens.f, col='blue',lwd=2) hist(dat[dat$gender== M,]$h, main= Dist. of Height for Male Participants, xlab= Height, xlim=c(140,190), probability=t,ylim=c(0,0.08)) dens.m = density(dat[dat$gender=='m',]$h) lines(dens.m, col='green', lwd=2)

HISTOGRAM Dist. of Height for Female Participants Dist. of Height for Male Participants Density 0.00 0.02 0.04 0.06 0.08 Density 0.00 0.02 0.04 0.06 0.08 140 150 160 170 180 190 Height 140 150 160 170 180 190 Height

par(mfrow=c(1,1)) plot(dens.f,col='blue',lwd=2, ylab='density', xlim=c(140,190), main="dist. of Height by gender",xlab='height') lines(dens.m,col='green',lwd=2) legend("topleft", c('female','male'), col=c('blue','green'), cex=1.5,lwd=2)

# text(x,y, TEXT ) text(157.5, 0.04, 'Female', col='blue', cex=2) text(170, 0.04,'Male', col='green', cex=2) Dist. of Height by gender density 0.00 0.02 0.04 0.06 Female Male 140 150 160 170 180 190 Height

21 22 23 24 25 1 2 3 4 5 16 17 18 19 20 11 12 13 14 15 6 7 8 9 10 1 2 3 4 5 1 2 3 4 5

# plot(x,y, ) plot(dat$shoesize, dat$h, main="relationship b/w shoesize and height, xlab = 'shoesize, ylab='height, pch=19, col='red ) Relationship b/w shoesize and height height 150 160 170 180 21 22 23 24 25 26 27 28 shoesize

txt = paste("r =",round(cor(dat$shoesize,dat$h), 4)) > txt[1] "r = 0.875" a=1:3 paste("s",a) => [1] "s 1" "s 2" "s 3" paste( s, a, sep= ) => [1] "s1" "s2" "s3"

txt = paste("r =", round(cor(dat$shoesize,dat$h), 4)) text(22, 175, txt, cex = 1.5) Relationship b/w shoesize and height height 150 160 170 180 r = 0.874 21 22 23 24 25 26 27 28 shoesize

abline: abline(h = mean(dat$h), col='blue'); abline(v = mean(dat$shoesize), col='green'); Relationship b/w shoesize and height H V height 150 160 170 180 r = 0.874 mean height mean shoesize 21 22 23 24 25 26 27 28 shoesize

abline(lm(dat$h~dat$shoesize), lty=2, lwd=2) Relationship b/w shoesize and height height 150 160 170 180 r = 0.874 21 22 23 24 25 26 27 28 shoesize

plot(dat[dat$gender=='f',]$shoesize, dat[dat$gender=='f',]$h, main="relationship b/w shoesize and height", xlab='shoesize', ylab='height', cex.lab=1.5, pch=19, col='blue', xlim=c(20,29), ylim=c(140,190)) Relationship b/w shoesize and height height 140 150 160 170 180 190 Female Male 20 22 24 26 28 shoesize

lines(dat[dat$gender=='m',]$shoesize,dat[dat$gender=='m',]$h, type = 'p', pch = 15, col = 'green') legend("topleft", c('female','male'), pch =c(19,15), col = c('blue','green'), cex = 1.5) height 140 150 160 170 180 190 Female Male Relationship b/w shoesize and height 20 22 24 26 28 shoesize

plot(dat.reg, pch=20, col=c('blue')) 100 140 180 50 100 150 200 material 2 4 6 8 10 100 140 180 price design 10 30 50 70 50 100 150 200 sales 2 4 6 8 10 10 20 30 40 50 60 70

plot(dat.pca, pch = rownames(dat.pca), cex = 1.7, col = 'blue') writing 40 50 60 70 80 90 a b c d e f g h i 40 50 60 70 80 90 a b c d e f g h i 40 50 60 70 80 90 a b c d e f g h i thesis a b c d e f g h i 40 50 60 70 80 90 a b c d e f g h i a b c d e f g h i 40 50 60 70 80 90 40 50 60 70 80 90 interview