Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Esercizio: Piombo e Traffico
- Piombo <- c(44, 58, 43, 60, 23, 53, 48, 74, 14, 38, 50, 55, 14, 67, 66, 18, 32, 20, 30)
- Traffico <- c(69, 109, 90, 104, 57, 111, 124, 127, 54, 102, 121, 118, 35, 138, 135, 70, 90, 50, 70)
- Modello <- lm(Piombo ~ Traffico)
- summary(Modello)
- Pred.OttoSette<-predict(Modello, data.frame(Traffico = 87), interval="confidence", level=0.95)
- Pred.UnoCinqueZero<-predict(Modello, data.frame(Traffico = 150), interval="confidence", level=0.95)
- #Assicurati che esista la cartella C:\Temp o metti una qualsiasi altra cartella
- png(filename="C:/Temp/Regressione.png")
- plot(x=Traffico, y=Piombo, type="p", pch=16, main="Valori Reali e Retta di regressione", xlab="Traffico", ylab="Piombo")
- lines(x=Traffico, y=Modello$fitted.values, type="l", col="red")
- dev.off()
- png(filename="C:/Temp/Previsioni.png")
- plot(x=Traffico, y=Modello$fitted.values, type="l", main="Valori Attesi e Intervalli di Confidenza", sub="Per Traffico=87 e 150", xlab="Traffico", ylab="Piombo", xlim=c(30,150) ,ylim=c(10,Pred.UnoCinqueZero[,3]))
- lines(c(87,150),c(Pred.OttoSette[,1],Pred.UnoCinqueZero[,1]),col="blue",type="p",pch=16)
- lines(c(87,87),c(Pred.OttoSette[,2],Pred.OttoSette[,3]),col="red",lty=2)
- lines(c(150,150),c(Pred.UnoCinqueZero[,2],Pred.UnoCinqueZero[,3]),col="red",lty=2)
- dev.off()
- #I grafici li trovi nella cartella C:\Temp
- #Esercizio: Teyler’s Kernal & Red Charles Ross
- Teyler <- c(22, 24.5, 25.5, 27.5, 22.5, 27.5, 24, 26.5, 23.5, 25)
- Charles <- c(18.3, 18.4, 20.2, 22, 17.5, 18.1, 17.6, 16.8, 18.8, 18.9)
- summary(Teyler)
- summary(Charles)
- Test.Zero<-t.test(Teyler, Charles)
- emp<-seq(-max(Teyler-Charles),max(Teyler-Charles),length=1000)
- png(filename="C:/Temp/Test Uguaglianza.png")
- plot(emp,dt(emp,Test.Zero$parameter),type="l",xlab="t",ylab="f(t)", main="Test per l'uguaglianza di Teyler e Charles")
- lines(x=rep(8.023339,2),y=c(-0.1,0.4),type="l",col="red", lty=2)
- lines(x=rep(qt(0.95,Test.Zero$parameter),2),y=c(-0.1,0.4),type="l",col="green", lty=2)
- legend(-max(Teyler-Charles),0.4,legend=c("Distribuzione t di Student","Statistica Test","95o Percentile"),col=c("black","red","green"),lty=c(1,2,2),cex=0.8)
- dev.off()
- Test.Uno<-t.test(Teyler, Charles, mu=1)
- emp<-seq(-max(Teyler-Charles-1),max(Teyler-Charles-1),length=1000)
- png(filename="C:/Temp/Test Differenza 1.png")
- plot(emp,dt(emp,Test.Uno$parameter),type="l",xlab="t",ylab="f(t)", main="Test per la differenza di Teyler e Charles uguale a 1")
- lines(x=rep(Test.Uno$statistic,2),y=c(-0.1,0.4),type="l",col="red", lty=2)
- lines(x=rep(qt(0.95,Test.Uno$parameter),2),y=c(-0.1,0.4),type="l",col="green", lty=2)
- legend(-max(Teyler-Charles-1),0.4,legend=c("Distribuzione t di Student","Statistica Test","95o Percentile"),col=c("black","red","green"),lty=c(1,2,2),cex=0.8)
- dev.off()
- Test.Teyler<-t.test(Teyler)
- emp<-seq(-max(Teyler),max(Teyler),length=1000)
- png(filename="C:/Temp/Media Teyler.png")
- plot(mean(Teyler)+emp,dt(emp,Test.Teyler$parameter),type="l",xlab="t",ylab="f(t)", main="Distribuzione della madia campionaria di Teyler")
- lines(x=rep(mean(Teyler),2),y=c(-0.1,0.4),type="l",col="red", lty=2)
- lines(x=rep(Test.Teyler$conf.int[1],2),y=c(-0.1,0.4),type="l",col="green", lty=2)
- lines(x=rep(Test.Teyler$conf.int[2],2),y=c(-0.1,0.4),type="l",col="green", lty=2)
- legend(-2.5,0.4,legend=c("Distribuzione t di Student","Stima della media","Intervallo di Confidenza al 95%"),col=c("black","red","green"),lty=c(1,2,2),cex=0.8)
- dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement