sta s cs with r
play

Sta$s$cs with R Mining So0ware Repositories 2015 - PowerPoint PPT Presentation

Sta$s$cs with R Mining So0ware Repositories 2015 University of Koblenz Presenter: Hakan Aksu Content 1. Introduc$on to R 2. Basic Sta$s$cs 3. Advanced


  1. Sta$s$cs ¡with ¡R ¡ Mining ¡So0ware ¡Repositories ¡2015 ¡ University ¡of ¡Koblenz ¡ ¡ Presenter: ¡Hakan ¡Aksu ¡

  2. Content ¡ 1. Introduc$on ¡to ¡R ¡ 2. Basic ¡Sta$s$cs ¡ 3. Advanced ¡Sta$s$cs ¡ 4. Example ¡(MSR-­‑Papers) ¡ MSR ¡SS15 ¡ 2 ¡

  3. INTRODUCTION ¡TO ¡R ¡ MSR ¡SS15 ¡ 3 ¡

  4. What ¡is ¡R? ¡ R ¡is ¡a ¡free ¡so0ware ¡environment ¡for ¡sta$s$cal ¡compu$ng ¡and ¡graphics. ¡It ¡compiles ¡ and ¡runs ¡on ¡a ¡wide ¡variety ¡of ¡UNIX ¡pla^orms, ¡Windows ¡and ¡MacOS. ¡[1] ¡ • R ¡has ¡ – an ¡effec$ve ¡data ¡handling ¡and ¡storage ¡facility, ¡ – a ¡suite ¡of ¡operators ¡for ¡calcula$ons ¡on ¡arrays, ¡in ¡par$cular ¡ matrices, ¡ – a ¡large, ¡coherent, ¡integrated ¡collec$on ¡of ¡intermediate ¡tools ¡for ¡ data ¡analysis, ¡ – graphical ¡facili$es ¡for ¡data ¡analysis ¡and ¡display ¡either ¡directly ¡at ¡ the ¡computer, ¡and ¡ – a ¡well ¡developed, ¡simple ¡and ¡effec$ve ¡programming ¡language ¡ (called ¡‘S’) ¡which ¡includes ¡condi$onals, ¡loops, ¡user ¡defined ¡ recursive ¡func$ons ¡and ¡input ¡and ¡output ¡facili$es. ¡ ¡ ¡[1] ¡ MSR ¡SS15 ¡ 4 ¡

  5. How ¡to ¡get ¡R? ¡ • Download ¡and ¡install ¡the ¡free ¡sta$s$c-­‑ so0ware-­‑package ¡R ¡from ¡ hap://www.r-­‑project.org/ ¡ ¡ • R ¡IDE: ¡RSTUDIO ¡ hap://www.rstudio.com/ ¡ ¡ MSR ¡SS15 ¡ 5 ¡

  6. Simple ¡Manipula$ons ¡in ¡R ¡ a ¡<-­‑ ¡“Hello ¡World!“ ¡ ¡ ¡ ¡# ¡Assign ¡String ¡to ¡variable ¡ b ¡<-­‑ ¡3 ¡ ¡ ¡ ¡ ¡ ¡# ¡Assign ¡Integer ¡to ¡variable ¡ c ¡<-­‑ ¡paste(“s1“,...,“sn“,sep=“-­‑“) ¡# ¡Conca$na$on ¡of ¡Strings ¡with ¡Seperator ¡ ¡ d ¡<-­‑ ¡c(3,5,7,9,11) ¡ ¡ ¡ ¡# ¡Define ¡vector ¡and ¡assign ¡to ¡variable ¡ d[2] ¡ ¡ ¡ ¡ ¡ ¡ ¡# ¡2nd ¡value ¡of ¡the ¡vector ¡d ¡ d[-­‑2] ¡ ¡ ¡ ¡ ¡ ¡# ¡Vector ¡d ¡without ¡2nd ¡value ¡ e ¡<-­‑ ¡c(1:5) ¡ ¡ ¡ ¡ ¡# ¡e ¡<-­‑ ¡c(1,2,3,4,5) ¡ ¡ ¡ f ¡<-­‑ ¡matrix(c(1:12),ncol=3) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡# ¡Define ¡Matrix ¡with ¡3 ¡columns ¡ g ¡<-­‑ ¡cbind(e,d) ¡ ¡ ¡ ¡# ¡Define ¡Matrix ¡with ¡two ¡columns ¡e ¡and ¡d ¡ ¡ ¡ MSR ¡SS15 ¡ 6 ¡

  7. Graphics ¡in ¡R ¡ plot ¡ plot(g) ¡ ¡ ¡ ¡ ¡ ¡ ¡# ¡draw ¡graphic ¡– ¡e ¡as ¡x-­‑axis ¡and ¡d ¡as ¡y-­‑axis ¡ vx ¡<-­‑ ¡c(1:5) ¡ ¡ ¡ ¡ ¡ ¡# ¡Define ¡vector ¡vx ¡ vy ¡<-­‑ ¡c(6,12,8,3,5) ¡ ¡ ¡ ¡ ¡# ¡Define ¡vector ¡vy ¡ ¡ plot(vx,vy, ¡ type="l“, ¡col="red", ¡lwd=6, ¡ ¡ sub="test", ¡main="TEST", ¡ xlab="xaxis",ylab="yaxis“) ¡ ¡ ¡ Descrip$on ¡of ¡arguments ¡and ¡possible ¡values ¡are ¡described ¡in ¡detail ¡in ¡the ¡ ¡ “R ¡Documenta$on“ ¡ ?plot ¡ ¡ ¡ ¡ ¡# ¡Show ¡documenta$on ¡for ¡plot{graphics} ¡ ¡ ¡ MSR ¡SS15 ¡ 7 ¡

  8. Graphics ¡in ¡R ¡ boxplot ¡ A ¡graphic ¡representa$on ¡of ¡a ¡distribu$on, ¡which ¡mark ¡the ¡maximum ¡and ¡ minimum ¡values, ¡the ¡median ¡and ¡first ¡and ¡third ¡quar$les. ¡[2] ¡ hap://www.bom.gov.au/water/ssf/faq/boxplot.png ¡ MSR ¡SS15 ¡ 8 ¡

  9. Graphics ¡in ¡R ¡ boxplot ¡ vx ¡<-­‑ ¡c(1:9) ¡ ¡ ¡ vy ¡<-­‑ ¡c(6,13,8,3,5,2,7,16,3) ¡ boxplot(vx,vy) ¡ MSR ¡SS15 ¡ 9 ¡

  10. Graphics ¡in ¡R ¡ histogram ¡ A ¡sta$s$cal ¡graph ¡that ¡represents ¡the ¡frequency ¡of ¡values ¡of ¡a ¡quan$ty. ¡ ¡[3] ¡ ¡ h ¡<-­‑ ¡c(4,3,7,3,5,7,1,4,2,4,8,9,6,4,2,7,4,9,5,3,4) ¡ hist(h,breaks=0:9) ¡ MSR ¡SS15 ¡ 10 ¡

  11. Packages ¡in ¡R ¡ • library() ¡ ¡ ¡#shows ¡you ¡all ¡installed ¡packages ¡ • library(X) ¡#load ¡the ¡package ¡X ¡ • Install ¡new ¡packages: ¡ MSR ¡SS15 ¡ 11 ¡

  12. For ¡more ¡informa$on ¡about ¡R: ¡ hap://cran.r-­‑project.org/manuals.html ¡ ¡ MSR ¡SS15 ¡ 12 ¡

  13. BASIC ¡STATISTICS ¡ MSR ¡SS15 ¡ 13 ¡

  14. Basic ¡Sta$s$cs ¡ • Number ¡of ¡items ¡ • Frequnecy ¡of ¡values ¡ • Mean ¡ • Median ¡ • Min/Max ¡ • Quan$les ¡ • Variance ¡ MSR ¡SS15 ¡ 14 ¡

  15. Number ¡of ¡items ¡ For ¡a ¡given ¡distributen ¡X ¡= ¡[x 1 ,x 2 ,...,x n ] ¡is ¡ n ¡the ¡number ¡of ¡items ¡(length) ¡ ¡ Example: ¡ X ¡= ¡[3,1,5,5,3,1,5,1,1,4,6,5,4,2,1] ¡ ¡ ¡ ¡ ¡ à ¡n ¡= ¡15 ¡ R: ¡ length(X) ¡ MSR ¡SS15 ¡ 15 ¡

  16. Frequnecy ¡of ¡values ¡ ¡ In ¡sta$s$cs ¡the ¡ frequency ¡(or ¡ absolute ¡frequency ) ¡of ¡an ¡event ¡is ¡the ¡number ¡of ¡ $mes ¡the ¡event ¡occurred ¡in ¡an ¡experiment ¡or ¡study. ¡ These ¡frequencies ¡are ¡o0en ¡ ¡ graphically ¡represented ¡in ¡histograms. ¡[4] ¡ Example: ¡ X ¡= ¡[3,1,5,5,3,1,5,1,1,4,6,5,4,2,1] ¡ à ¡[1] ¡occurs ¡5 ¡$mes ¡ ¡[2] ¡occurs ¡1 ¡$mes ¡ ¡[3] ¡occurs ¡2 ¡$mes ¡ ¡[4] ¡occurs ¡2 ¡$mes ¡ ¡[5] ¡occurs ¡4 ¡$mes ¡ ¡[6] ¡occurs ¡1 ¡$mes ¡ R: ¡ hist(X,breaks=0:6) ¡ ¡ ¡ MSR ¡SS15 ¡ 16 ¡

  17. Mean ¡ The ¡ arithme)c ¡mean ¡ is ¡the ¡sum ¡of ¡the ¡sampled ¡values ¡divided ¡by ¡the ¡number ¡of ¡ ¡ items ¡in ¡the ¡sample. ¡[5] ¡ ¡ ¡ ¡ ¡ ¡ Example: ¡ X ¡= ¡[3,1,5,5,3,1,5,1,1,4,6,5,4,2,1] ¡ à The ¡mean ¡is ¡(3+1+5+5+...+4+2+1)/15 ¡≈ ¡ 3.133 ¡ ¡ R: ¡ mean(X) ¡ summary(X) ¡ MSR ¡SS15 ¡ 17 ¡

  18. Median ¡ The ¡Median ¡is ¡the ¡middle ¡number ¡in ¡a ¡given ¡sequence ¡of ¡numbers, ¡taken ¡as ¡ ¡ the ¡mean ¡of ¡the ¡two ¡middle ¡numbers ¡when ¡the ¡sequence ¡has ¡an ¡even ¡ number ¡of ¡items. ¡[6] ¡ ¡ Example: ¡ X ¡= ¡[3,1,5,5,3,1,5,1,1,4,6,5,4,2,1] ¡ X ¡= ¡[1,1,1,1,1,2,3,3,4,4,5,5,5,5,6] ¡ ¡Y ¡= ¡[2,4,5,8] ¡ ¡ à The ¡median ¡is ¡3 ¡ ¡ ¡ ¡ ¡ ¡ ¡ à ¡The ¡median ¡is ¡4.5 ¡ ¡ R: ¡ median(X) ¡ summary(X) ¡ boxplot(X) ¡ MSR ¡SS15 ¡ 18 ¡

  19. ¡ ¡ hap://de.urbandic$onary.com/define.php?term=min%2Fmax ¡ ¡ MSR ¡SS15 ¡ 19 ¡

  20. Min ¡& ¡Max ¡ ¡ The ¡minimum ¡is ¡the ¡lowest ¡and ¡the ¡maximum ¡the ¡highest ¡value ¡of ¡a ¡distribu$on ¡ Example: ¡ X ¡= ¡[3,1,5,5,3,1,5,1,1,4,6,5,4,2,1] ¡ X ¡= ¡[1,1,1,1,1,2,3,3,4,4,5,5,5,5,6] ¡ ¡ ¡min ¡ ¡ ¡ ¡ ¡ ¡max ¡ R: ¡ min(X) ¡ max(X) ¡ range(X) ¡ summary(X) ¡ boxplot(X) ¡ MSR ¡SS15 ¡ 20 ¡

  21. Quan$les ¡ • Important ¡quan$les ¡are: ¡ ¡ 0% ¡(min), ¡25%, ¡50% ¡(median), ¡ ¡ 75%, ¡100% ¡(max) ¡ • 9 ¡different ¡ ¡ quan$le ¡algorithms ¡ • Default ¡in ¡R: ¡type ¡= ¡7 ¡ • See ¡?quan$le ¡ MSR ¡SS15 ¡ 21 ¡

  22. Variance ¡ The ¡variance ¡is ¡a ¡numerical ¡measure ¡of ¡how ¡the ¡data ¡values ¡is ¡dispersed ¡around ¡the ¡mean. ¡ ¡ popula?on ¡variance ¡is ¡defined ¡in ¡terms ¡of ¡the ¡popula$on ¡ mean ¡ μ ¡and ¡popula$on ¡size ¡ N: ¡ ¡ ¡ ¡ (σ ¡is ¡called ¡standard ¡devia$on) ¡ Example: ¡ X ¡= ¡[3,1,5,5,3,1,5,1,1,4,6,5,4,2,1] ¡ à N ¡= ¡15, ¡ μ ¡ ≈ ¡3.133 ¡ à ¡The ¡variance ¡is ¡≈ ¡3.409524 ¡ R: ¡ var(X) ¡ MSR ¡SS15 ¡ 22 ¡

  23. MSR ¡SS15 ¡ 23 ¡

  24. ADVANCED ¡STATISTICS ¡ MSR ¡SS15 ¡ 24 ¡

  25. Precision, ¡Recall, ¡F-­‑Measure ¡and ¡Accuracy ¡ ¡ MSR ¡SS15 ¡ 25 ¡

  26. Which ¡method? ¡ Difference ¡of ¡ distribu$ons ¡are ¡ sta$s$cally ¡ significant? ¡ A ¡normal ¡ Not ¡a ¡normal ¡ distribu$on? ¡ distribu$on? ¡ Mann-­‑Whitney ¡U ¡ Mann-­‑Whitney ¡U ¡ test ¡ equivalent ¡to ¡ test ¡ equivalent ¡to ¡ T-­‑Test ¡ Wilcoxon ¡rank ¡ Wilcoxon ¡rank ¡ test ¡ test ¡ MSR ¡SS15 ¡ 26 ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend