This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mediapart<-userTimeline(user="mediapart", | |
n=500,cainfo="cacert.pem") | |
lemonde<-userTimeline(user="lemondefr", | |
n=500,cainfo="cacert.pem") | |
lefigaro<-userTimeline(user="Le_Figaro", | |
n=500,cainfo="cacert.pem") | |
leparisien<-userTimeline(user="le_Parisien", | |
n=500,cainfo="cacert.pem") | |
#Concaténation | |
Media.df<-rbind(mediapart.df, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lm_eqn = function(df) { | |
m = lm(pollution ~ pib, df); | |
l <- list(a = format(coef(m)[1], digits = 2), | |
b = format(abs(coef(m)[2]), digits = 2), | |
r2 = format(summary(m)$r.squared, digits = 3)); | |
if (coef(m)[2] >= 0) { | |
eq <- substitute(italic(Pollution) == a + b %.% italic(PIB)*","~~italic(R)^2~"="~r2,l) | |
} else { | |
eq <- substitute(italic(Pollution) == a - b %.% italic(PIB)*","~~italic(R)^2~"="~r2,l) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 18/05/2013 | |
# Key words : TextMining, Elections, France, Debate, 2nd Round | |
# We use the packages qdap from (donner le lien) and | |
# tm to perform textmining analysis and the classical | |
# package like ggplot or RColorBrewer to get the graphics pretty. | |
suppressPackageStartupMessages(require(twitteR)) | |
suppressPackageStartupMessages(require(XML)) | |
suppressPackageStartupMessages(require(tm)) | |
suppressPackageStartupMessages(require(rgdal)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plot(GROUPE~TAILLE) | |
abline(lm(GROUPE~TAILLE),col="tomato") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
png("Log", width=6,height=7) | |
x = seq(0.00001,0.9999,length = 100) | |
logit<-function(t) | |
{ | |
log(t/(1-t)) | |
} | |
curve(logit(x),col = "tomato",lwd = 2) | |
curve(qnorm(x),col = "blue",lwd = 2,add=T) | |
curve(log(-log(1-x)),col = "purple",lwd = 2,add=T) | |
a=par("usr") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lik | |
lik.logit <- function(init,y,x) | |
{ | |
x = as.matrix(x) | |
cste<- rep(1,length(x[,1])) | |
x <- cbind(cste,x) # Matrix of predictors | |
d <- init[1:ncol(x) ] # Number of parameters | |
xd<- x%*%d # Produit matriciel | |
sum( y*log(1+exp(-xd)) + (1-y)*log(1+exp(xd))) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
viaglm<- glm(don$GROUPE~don$TAILLE,don,family="binomial") ; viaglm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We compute the inverse logistic function | |
ilogit <- function (l) { | |
exp(l) / ( 1 + exp(l) ) | |
} | |
attach(don) | |
viaglm<- glm(GROUPE~TAILLE,don,family="binomial") | |
png("Comparison.png", width=1280,height=800) | |
plot(TAILLE,GROUPE, pch=16) | |
new<- seq(min(TAILLE),max(TAILLE),by=1) | |
# Prev avec R |