# Modèle linéaire setwd("F:/formation juillet 2014") source("linear_model.r") ble_lm1=linear_model(1,2020,"ble_dpt.txt","ble_lm1.txt") ble_europe_lm1=linear_model(1,2020,"ble_eur.txt","ble_eur_lm1.txt") # sorties head(ble_lm1[[1]]) ble_lm1[[2]] # courbe source("courbe.r") courbe("Y",2020, "ble_dpt.txt","ble_lm1.txt",P=c("Y_10","Y_90") ) # carte rworldmap library(rworldmap) tab=read.table("ble_eur.txt",h=T) data=subset(tab,tab$Time==2011) map=joinCountryData2Map(data,joinCode ="NAME", nameJoinColumn ="Group") dev.new() mapParams=mapCountryData(map, mapRegion="europe" ,catMethod="quantiles",numCats=5,nameColumnToPlot="Y",borderCol="black",missingCountryCol="grey",addLegend='FALSE') do.call( addMapLegend, c( mapParams, legendLabels="all",legendWidth=0.5)) # carte carte() source("carte.r") carte("Y",2011,"departement","ble_dpt.txt","YlOrRd") ####################################################### # Exercice source("linear_model.r") ble_lm1=linear_model(2,2020,"ble_dpt.txt","ble_lm2.txt") ble_europe_lm1=linear_model(3,2020,"ble_eur.txt","ble_eur_lm2.txt") ### source("courbe.r") courbe("Y",2020, "ble_dpt.txt","ble_lm2.txt",P=c("Y_10","Y_90") ) courbe("Y",2020, "ble_eur.txt","ble_eur_lm2.txt",P=c("Y_10","Y_90") ) ### library(rworldmap) tab=read.table("ble_eur_lm2.txt",h=T) data=subset(tab,tab$Time==2015) map=joinCountryData2Map(data,joinCode ="NAME", nameJoinColumn ="Group") dev.new() mapParams=mapCountryData(map, mapRegion="europe" ,catMethod="quantiles",numCats=5,nameColumnToPlot="Y",borderCol="black",missingCountryCol="grey",addLegend='FALSE') do.call( addMapLegend, c( mapParams, legendLabels="all",legendWidth=0.5)) ### source("carte.r") carte("Y",2015,"departement","ble_lm2.txt","YlOrRd") ########################################################## # modele dlm source("dlm_model.r") ble_dlm1=dlm_model(c("France","Germany","Spain"),2020,0,"var_cste","ble_eur.txt","dlm_sans_pente.txt","D:/WinBUGS14",save_obs="dlm_obs1.txt",save_calcul="dlm_pred1.txt") ble_dlm2=dlm_model(c("France","Germany","Spain"),2020,1,"var_cste","ble_eur.txt","dlm_avec_pente.txt","D:/WinBUGS14",save_obs="dlm_obs2.txt",save_calcul="dlm_pred2.txt") # sorties head(ble_dlm1[[1]]) head(ble_dlm1[[2]]) ble_dlm1[[3]] # courbe courbe("Y",2015,"dlm_obs1.txt","dlm_pred1.txt",P=c("Y_10","Y_90")) # carte library(rworldmap) tab=read.table("dlm_eur_pente.txt",h=T) data=subset(tab,tab$Time==2011) map=joinCountryData2Map(data,joinCode ="NAME", nameJoinColumn ="Group") dev.new() mapParams=mapCountryData(map,mapRegion="europe",catMethod = "quantiles",numCats=5,nameColumnToPlot= "pente" ,borderCol="black",missingCountryCol="grey", addLegend='FALSE') do.call( addMapLegend, c( mapParams,legendLabels="all",legendWidth=0.5)) ############################################################## # Exercice library(rworldmap) tab=read.table("dlm_eur_pred1.txt",h=T) data=subset(tab,tab$Time==2020) map=joinCountryData2Map(data,joinCode ="NAME", nameJoinColumn ="Group") dev.new() mapParams=mapCountryData(map,mapRegion="europe",catMethod = "quantiles",numCats=5,nameColumnToPlot= "Y" ,borderCol="black",missingCountryCol="grey", addLegend='FALSE') do.call( addMapLegend, c( mapParams,legendLabels="all",legendWidth=0.5)) ### source("dlm_model.r") ble_dpt_dlm1=dlm_model(c("AIN","DROME","HAUTE-GARONNE"),2020,0,"var_cste","ble_dpt.txt", "dlm_sans_pente.txt","D:/WinBUGS14",save_obs="dlm_dpt_obs1.txt", save_calcul="dlm_dpt_pred1.txt") ble_dpt_dlm2=dlm_model(c("AIN","DROME","HAUTE-GARONNE"),2020,1,"var_cste","ble_dpt.txt", "dlm_avec_pente.txt","D:/WinBUGS14",save_obs="dlm_dpt_obs2.txt", save_calcul="dlm_dpt_pred2.txt") ### courbe("Y",2015,"dlm_dpt_obs1.txt","dlm_dpt_pred1.txt",P=c("Y_10","Y_90")) courbe("Y",2015,"dlm_dpt_obs2.txt","dlm_dpt_pred2.txt",P=c("Y_10","Y_90"))