also,&a&“significant”&linear ... - université...

5
Groupe des U+lisateurs de R de l’Université Paris Sud La méthode MIME ALSO, A “SIGNIFICANT” LINEAR CORRELATION COEFFICIENT DOES NOT IMPLY THAT THE UNDERLYING RELATIONSHIP IS LINEAR. AND A NON8SIGNIFICANT ONE DOES NOT MEAN THAT THE VARIABLES ARE INDEPENDENT. Yoccoz NG (1991) Use, overuse, and misuse of significance tests in evolu+onary biology and ecology. Bulle+n of the Ecological Society of America 72:106S111 LA CORRELATION « SIMPLE » Les bases Générer des données Generate 100 normal random number x <S rnorm(100, 10, 2) y <S rnorm(100, 10, 2) plot(x, y)

Upload: vuthien

Post on 14-Sep-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

Groupe'des'U+lisateurs'de'R'de'l’Université'Paris'Sud'

La'méthode'MIME'

ALSO,&A&“SIGNIFICANT”&LINEAR&CORRELATION&COEFFICIENT&DOES&NOT&IMPLY&THAT&THE&UNDERLYING&RELATIONSHIP&IS&LINEAR.&AND&A&NON8SIGNIFICANT&ONE&DOES&NOT&MEAN&THAT&THE&VARIABLES&ARE&INDEPENDENT.&&

Yoccoz'NG'(1991)'Use,'overuse,'and'misuse'of'significance'tests'in'evolu+onary'biology'and'ecology.'Bulle+n'of'the'Ecological'Society'of'America'72:106S111'

LA&CORRELATION&«&SIMPLE&»&Les'bases'

Générer'des'données'

•  Generate'100'normal'random'number''x'<S'rnorm(100,'10,'2)'y'<S'rnorm(100,'10,'2)'plot(x,'y)''

Les'lois'de'distribu+on'

The'func+ons'density/mass'func+on,'cumula+ve'distribu+on'func+on,'quan+le'func+on'and'random'variate'genera+on'are'named'in'the'form'dxxx,'pxxx,'qxxx'and'rxxx'respec+vely''

beta'distribu+on:'[x]beta'binomial'(including'Bernoulli)'distribu+on:'[x]binom'Cauchy'distribu+on:'[x]cauchy'chiSsquared'distribu+on:'[x]chisq'exponen+al'distribu+on:'[x]exp'F'distribu+on:'[x]f'gamma'distribu+on:'[x]gamma'geometric'distribu+on:'[x]geom'hypergeometric'distribu+on:'[x]hyper'

logSnormal'distribu+on:'[x]lnorm'mul+nomial'distribu+on:'[x]mul+nom'nega+ve'binomial'distribu+on:'[x]nbinom'normal'distribu+on:'[x]norm'Poisson'distribu+on:'[x]pois'Student's't'distribu+on:'[x]t'uniform'distribu+on:'[x]unif'Weibull'distribu+on:'[x]weibull'

Représenter'des'données'

plot(x,'y,'xlab="Variable'x",'ylab="Variable'y",'main="Correla+on",'bty="n")'

Calculer'un'coefficient'de'corréla+on'

•  #'cor(x,'y'='NULL,'use'='"everything",'method'='c("pearson",'"kendall",'"spearman"))'

•  #'use'is'an'op+onal'character'string'giving'a'method'for'compu+ng'covariances'in'the'presence'of'missing'values.'This'must'be'(an'abbrevia+on'of)'one'of'the'strings'"everything",'"all.obs",'"complete.obs",'"na.or.complete",'or'"pairwise.complete.obs".'

cor(x,'y,'method'='"pearson")'#'corréla+on'des'valeurs'cor(x,'y,'method="kendall")'#'corréla+on'des'rangs'cor(x,'y,'method="spearman")'#'corréla+on'des'rangs'

Agrémenter'le'graphique'

abline(lm(y'~'x))'text(14,'8,'paste("r=",'sprini("%.3f",cor(x,'y,'method'='"pearson")),'sep=""))'

Tester'la'corréla+on'•  #'cor.test(x,'y,'alterna+ve'='c("two.sided",'"less",'"greater"),'method'='

c("pearson",'"kendall",'"spearman"),'exact'='NULL,'conf.level'='0.95,'con+nuity'='FALSE,'...)'

(testcor'<S'cor.test(x,'y,'method'='"pearson"))'str(testcor)'testcor$p.value'text(14,'7.5,'paste("p=",'sprini("%.3f",'testcor$p.value),'sep=""))'

Tester'la'corréla+on'x'<S'c(rnorm(50,'1,'1),'rnorm(50,'100,'50))'y'<S'c(rnorm(50,'100,'50),'rnorm(50,'1,'1))'plot(x,'y,'xlab="Variable'x",'ylab="Variable'y",'main="Correla+on",'bty="n")'abline(lm(y'~'x))''text(100,'50,'labels'='subs+tute(r^2'=='A,'list(A'='sprini("%.3f",cor(x,'y,'method'='"pearson")^2))))'text(120,'35,'paste("p=",'sprini("%.3f",'cor.test(x,'y,'method'='"pearson")$p.value),'sep=""))'

La'corréla+on'teste'une'rela+on'linéaire'mais'pas'un'degré'd’associa+on'entre'deux'variables.'

Pourquoi'ces'mesures'ne'sont'pas'sa+sfaisantes'?'

•  Seules'les'rela+ons'linéaires'sont'modélisées.'–  Il'faut'donc'faire'des'changements'de'variable'mais'une'infinité'est'possible.'

•  Les'rela+ons'linéaires'guident'de'telles'rela+ons'vers'les'significa+vités'les'plus'fortes.'

Généralité'et'équité'•  Par'généralité,'on'entend'qu’avec'une'taille'd'échan+llon'suffisante,'la'sta+s+que'doit'capturer'un'large'éventail'd'associa+ons'sans'se'limiter'à'des'fonc+ons'spécifiques'(comme'linéaire,'exponen+elle'ou'périodique).'Dans'l’idéal,'la'sta+s+que'doit'capturer'toutes'les'rela+ons'fonc+onnelles'même'des'superposi+ons'de'fonc+ons.'

•  Par'équité,'on'entend'que'la''sta+s+que'doit'donner'des''scores'similaires'aux'rela+ons''ayant'un'bruit'semblable'et'ce''indépendamment'de'l’associa+on.'

Une'solu+on'•  Reshef&DN,&Reshef&YA,&Finucane&HK,&Grossman&SR,&McVean&

G,&Turnbaugh&PJ,&Lander&ES,&Mitzenmacher&M,&SabeE&PC&(2011)&DetecEng&novel&associaEons&in&large&data&sets.&Science&334:1518T1524&

•  Mesure'de'l’associa+on'entre'deux'variables'par'le'coefficient'd’informa+on'maximal'(MIC).'

•  L’informa+on'mutuelle'de'deux'variables'aléatoires'est:'

•  Avec'p(x,'y)'la'probabilité'de'x'et'y'et'p(x)'et'p(y)'les'probabilités'marginales'de'x'et'y.'

•  Intui+vement'l’informa+on'mutuelle'désigne'l’informa+on'disponible'dans'X'qui'permet'de'connaître'Y.'

La'nouveauté…'

•  Décomposi+on'du'graph'en'une'grille'et'recherche'de'l’informa+on'maximale'selon'tous'les'arrangements'possibles'de'la'grille'(en'fait'démarche'heuris+que).'

Généralité'et'équité'

•  Quelques'exemples'

Généralité'et'équité'

•  Quelques'exemples'

U+lisa+on'de'la'méthode'

•  hwp://www.exploredata.net'

Script'R'•  hwp://www.exploredata.net/xp/MINE.r'

•  How'to'run'MINE'in'R'•  First,'make'sure'both'R'and'Java'are'installed.'Next,'download'and'save'both'

MINE.jar'and'MINE.r'into'the'same'directory'and'make'that'directory'the'working'directory'in'R.'The'example'below'then'runs'MINE'on'all'the'variable'pairs'in'the'file'example.csv.'

•  install.packages("rJava")'#'1S+me'ini+aliza+on'step'•  source("MINE.R")'•  MINE("example.csv","all.pairs")'

•  The'library'exposes'two'func+ons:'MINE,'and'rMINE.'The'difference'between'them'is'that'MINE'takes'as'input'a'path'to'a'csv'file'to'be'analyzed,'while'rMINE'takes'as'input'an'R'matrix'containing'the'data'to'be'analyzed.'Both'func+ons'take'parameters'iden+cal'to'those'in'the'Java'version.'

Répertoire'de'base'

•  Quand'R'doit'chercher'un'fichier,'soit'on'lui'donne'le'chemin'en+er,'pas'simple,'soit'on'lui'a'indiqué'le'chemin'par'défaut'avec:''setwd('“chemin“)'On'lit'le'chemin'en'cours'avec':'getwd()'Mais'encore'une'fois,'pas'simple'de'connaître'le'chemin.'Il'vaut'mieux'u+liser:'file.choose()'

Chemin'd’un'fichier'ou'd’un'dossier'

Mais'encore'une'fois,'pas'simple'de'connaître'le'chemin.'Il'vaut'mieux'u+liser:'file.choose()'On'récupère'alors'une'chaîne'de'caractère'avec'le'chemin.'Mais'on'ne'peut'pointer'que'sur'un'fichier'alors'que'setwd(«'path'»)'awend'le'chemin'd’un'dossier.'L’astuce'est'de'mewre'un'moins'un'fichier'dans'le'dossier'et'faire:'setwd(dirname(file.choose()))''