Pour répondre à plusieurs questions, pour constituer sa propre base, il est important d'avoir différentes variables pour un même individu. Un individu peut être une entité plus large, comme une région, ou un quartier. Supposons que l'on s'intéresse aux votes lors d’élections. Désolé de reprendre des votes en France, mais les données sont faciles d'accès. Par exemple, pour Paris, on a les données de l'élection présidentielle de 2012, sur http://opendata.paris.fr/
> baseE=read.csv( + "http://freakonometrics.blog.free.fr/public/ data/election-paris-quartiers.csv", + header=TRUE,sep=";")
J'ai mes les données sur mon blog car c'est plus simple pour les lire. Les données ressemblent à ça,
> baseE[1:6,1:5] ARR QUARTIERS GRD_QUART INSCRITS EMARGEMENTS 1 1 SAINTGERMAINLAUXERROIS 7510101 1075 854 2 1 HALLES 7510102 5667 4529 3 1 PALAISROYAL 7510103 1986 1610 4 1 PLACEVENDOME 7510104 1762 1427 5 2 GAILLON 7510205 799 613 6 2 VIVIENNE 7510206 1929 1485
Les données sont "par arrondissement et par quartier" comme on le lit dans le descriptif. Une ligne est un quartier. Maintenant, si on veut expliquer le taux de vote, ou le taux obtenu par tel ou tel candidat, il faut des variables explicatives.
Pour cela, on peut aller sur http://www.recensement.insee.fr/ qui met en ligne beaucoup de données. En particulier, avec le même niveau de granularité, par quartier !
> base1=read.table( + "http://freakonometrics.blog.free.fr/public/ data/IRIS-PARIS-ACTIV.csv", + header=TRUE,sep=";")
> base1[1:15,c(1,2,3,4,5,7,8)] IRIS REG DEP UU2010 COM TRIRIS GRD_QUART 1 751010101 11 75 851 75101 750011 7510101 2 751010102 11 75 851 75101 750011 7510101 3 751010103 11 75 851 75101 750011 7510101 4 751010104 11 75 851 75101 750011 7510101 5 751010105 11 75 851 75101 750011 7510101 6 751010199 11 75 851 75101 750011 7510101 7 751010201 11 75 851 75101 750021 7510102 8 751010202 11 75 851 75101 750021 7510102 9 751010203 11 75 851 75101 750021 7510102 10 751010204 11 75 851 75101 750021 7510102 11 751010205 11 75 851 75101 750021 7510102 12 751010206 11 75 851 75101 750021 7510102 13 751010301 11 75 851 75101 750011 7510103 14 751010302 11 75 851 75101 750011 7510103 15 751010303 11 75 851 75101 750011 7510103
> base1t=aggregate(base1[,-(1:11)], + by=list(GRD_QUART=base1$GRD_QUART), FUN=sum) > base1t[1:5,c(1,4,5,7,8)] GRD_QUART P08_POP1564 P08_POP1524 P08_POP5564 P08_H1564 1 7510101 1278 222 250 662 2 7510102 7420 1187 1061 3987 3 7510103 2305 475 392 1171 4 7510104 2111 376 308 1010 5 7510205 875 111 136 426
> base2=read.table( + "http://freakonometrics.blog.free.fr/public/ data/IRIS-PARIS-POPUL.csv", + header=TRUE,sep=";") > base3=read.table( + "http://freakonometrics.blog.free.fr/public/ data/IRIS-PARIS-LOGEMENT.csv", + header=TRUE,sep=";") > base4=read.table( + "http://freakonometrics.blog.free.fr/public/ data/IRIS-PARIS-FORMATION.csv", + header=TRUE,sep=";")
> plot((baseT$P08_FNSCOL15P_SUP/baseT$P08_POP), + (baseT$VOTANTS/baseT$INSCRITS))

> base=data.frame( + Thollande=(baseT$HOLLANDE/baseT$INSCRITS), + Tsarkozy=(baseT$SARKOZY/baseT$INSCRITS), + T5pieces=(baseT$P08_RP_5PP/baseT$P08_RP), + Tfemmes=(baseT$P08_POPF/baseT$P08_POP), + Tpop2554=(baseT$P08_POP2554/baseT$P08_POP1564), + Tenfants018=((baseT$P08_POP0002+baseT$P08_POP0305 + +baseT$P08_POP1117+baseT$P08_POP0610)/baseT$P08_POP), + Tpop5564=(baseT$P08_POP5564/baseT$P08_POP1564), + Tactifs=(baseT$P08_ACT5564/baseT$P08_POP1564), + Tchomeur=(baseT$P08_CHOM1564/baseT$P08_POP1564), + Tetudiant=(baseT$P08_ETUD1564/baseT$P08_POP1564), + T65ansplus=(baseT$P08_POP65P/baseT$P08_POP), + Npop=baseT$INSCRITS)











Mercredi aura lieu le premier cours 













