Vous êtes sur la page 1sur 5

Série2

1. Caractéristiques de l’échantillon
Y<-(round(3+rnorm(50),2)*100
Y
2. Mean(x) :moyenne du vecteur x
Mean(y)
3. Var(x) : variance du vecteur x
4. Sd(x) : écart-type
5. Median(x) : médiane du vecteur x
6. Quantile(x) : minimum, Q1,médiane, Q2, maximum
7. Graphiques
Z<-cbind(1 :10,(3+round(rnorm(10),2))*100)
z
8. Barplot(x) : diagramme en tuyaux d’orgue
Barplot(z[,2])
9. Plot(x) : diagramme par points
Y<-(round(3+rnorm(50),2))*100
Sort(y)
Plot(y)
10. Hist(x) : histogramme des données de x avec l’intervalle]b0,b1]
Hist(y)
11. Hist(x,right=f) : histogramme des données de x avec l’intervalle[b0,b1[
Hist(y,right=f)
Hist(notes)
Hist(notes,right=f)
12. Hist(x,n): histogramme avec environ n colonnes
Hist(y,10)
Z<-c(178,171,174,173,175,164,179,172,168,172,174,170,167,182,166,180,172,
183,176,180,172,175,171,175)
Hist(z,right=f)
Hist(z,2,right=f)
Hist(z,10,right=f=
13. Boxplot(x) : diagramme en boites
Boxplot(y)
Ages<-c(40,60,63,64,65,66,66,67,67,69,72,73,75,78,79,80,80,81,82,82,83,84,85,86,90,90)
Boxplot(ages)
14. Par(mfrow=c(m,n)) : fenêtre graphique divisée en m x n cellules
Par(mfrow=c(1,2))
Hist(y)
Boxplot(y)
Par(mfrow=c(1,1))
X<-round(13+rnorm(50),1)*10
15. Plot(x,y) : graphique des points de coordonnées
Plot(x,y)
sd(y)
median(y)
quantile(y)
z<-cbind(1 :10,(3+round(rnorm(10),2))*100)
z
barplot(z[,2])
y<-(round(3+rnorm(50),2))*100
sort(y)
plot(y)
hist(y)
hist(y,right=f)
hist(notes)
hist(notes,right=f)
hist(y,10)
z<-c(178,171,174,173,175,164,179,172,168,172,174,170,167,182,166,180,172,
183,176,180,172,175,171,175)
hist(z,right=f)
hist(z,2,right=f)
hist(z,10,right=f=
boxplot(y)
ages<-c(40,60,63,64,65,66,66,67,67,69,72,73,75,78,79,80,80,81,82,82,83,84,85,86,90,90)
boxplot(ages)
par(mfrow=c(1,2))
hist(y)
par(mfrow=c(1,1))
x<-round(13+rnorm(50),1)*10
plot(x,y)
Série n°3
Régression linéaire simple
1 . entrée des données
X<-c(30,20,60,80,40,50,60,30,70,60,50°
Y<-c(73,50,128,170,87,108,135,69,148,132,110)
2. estimation des coefficients
Reg2<-lm(y ~x)
Summary(reg1)
3. graphique
Plot(y,x)
Abline(reg1)
4. table anova
Anova(reg1)
5. intervalle de prévision
Predict(reg1,data.frame(x=c(65,100)),interval= “prediction“)
Predict(reg1,data.frame(x=c(65,100)),interval=“prediction“)
6. verification des hypotheses de la régression
6.1. linéarité
Plot(fitted.values(reg1),residuals(reg1))
Abline(h=0)
Lin.x<-c(75,80,100,95,125,130,145,150,170,180,195,200)
Lin.y<-c(28,42,112,136,160,150,143,161,156,124,104)
Reg2<-lm(lin.y~lin.x)
Summary(reg2)
Plot(lin.x,lin.y)
Abline(reg2)
Plot(fitted.values(reg2),residuals(reg2))
Abline(h=0)
6.2. homogénéité des variances
Plot(fitted.values(reg1),residuals(reg1))
Abline(h=0)
6.3. normalité des résidus
Qqnorm(residuals(reg1))
Qqline(residuals(reg1))
#ou
Shapiro.test(residuals(reg1))
x<-c(30,20,60,80,40,50,60,30,70,60,50)
y<-c(73,50,128,170,87,108,135,69,148,132,110)
reg1<-lm(y~x)
summary(reg1)
plot(y,x)
abline(reg1)
anova(reg1)
predict(reg1,data.frame(x=c(65,100)),interval= "prediction")
predict(reg1,data.frame(x=c(65,100)),interval="prediction")
plot(fitted.values(reg1),residuals(reg1))
abline(h=0)
lin.x<-c(75,80,100,95,125,130,145,150,170,180,195,200)
lin.y<-c(28,42,112,136,160,150,143,161,156,124,104)
reg2<-lm(y~x)
summary(reg2)
plot(x,y)
abline(reg2)
plot(fitted.values(reg2),residuals(reg2))
abline(h=0)
plot(fitted.values(reg1),residuals(reg1))
abline(h=0)
qqnorm(residuals(reg1))
qqline(residuals(reg1))
#ou
Shapiro.test(residuals(reg1))

Régression linéaire multiple


Entée des données
X<-c(30,20,60,80,40,50,60,30,70,60,50)
Y<-c(73,50,128,170,87,108,135,69,148,132,110)
Z<-c(16,10,32,40,20,28,30,16,35,30,29)
2. estimation des coefficients
Reg3<-lm(y~x+z)
Summary(reg3)
3: Intervalle de prevision
Predict(reg3,data.frame(x=65,z=25),interval=”prediction”)
Predict(reg3,data.frame(x=c(65,100),z=c(25,40)),interval=”prediction”)
4: verification des hypotheses de la régression
4,1 :Homogénéité des variances
Plot(fitted.values(reg3),residuals(reg3))
Abiline(h=0)
4,2 : normalité des résidus
Qqnorm(residuals(reg3))
Qqline(residuals(reg))
#ou
Shapiro.test(residuals(reg3))

Serie4
ts(x,start,freq)
1:données mensuelle
x0<-ts(rnorm(60),start=c(2004,1),freq=12)
x0
2:données trimestrielle
x1<-ts(rnorm(52),start=c(2004,1),freq=4)
x1
3: visualisation
plot(x0)
plot(x1)
4: Décompositions classiques
m<-decompose(x1,type="additive")
m
m$figure
plot(m)
5 : simulation d’un AR(p)
yt=0.7yt-1+et
ts.ar<-arima.sim(list(order=c(1,0,0),ar=0.7),n=200)
ts.ar
ts.plot(ts.ar,type="l")
acf(ts.ar,10)
pacf(ts.ar,10)
6: pour determiner un choix optimal pour le retard p
fit<-ar(ts.ar)
fit
tab<-read.table(file="H:\Touristes.txt")
tab
attach(tab)
x0<-ts(V1,start=c(1997,1),freq=12)
x0
ts.plot(x0,type="l")
acf(x0,10)
pacf(x0,10)
ar(x0,TRUE,4)

age<-c(37,65,21,60,40,75,15,56,29,38,55)

nombre<-c(2,11,3,8,5,6,4,12,1,3,8)

Reg1<-lm(nombre~age)

summary(reg1)

Plot(nombre,age)

Abline(reg1)

Plot(nombre,age)

Abline(reg1)

Vous aimerez peut-être aussi