Advertisement
federico_carosio

Esercizio_2b

Dec 27th, 2023 (edited)
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.97 KB | None | 0 0
  1. #     ESERCIZIO 2b
  2. rm(list=ls())
  3. library(moments)
  4. library(car)
  5.  
  6. data2 <- read.table("Exercise2b.txt", header = T, sep = "\t")
  7. duration <- c(5, 10, 20, 30, 40, 50, 60, 120, 180)
  8. for (i in 2:length(duration)+1) {
  9.   colnames(data2)[i] <- i
  10. }
  11.  
  12. par <- matrix(NA, nrow = length(duration), ncol = 3)
  13. colnames(par) <- c("media", "varianza", "skewness")
  14.  
  15. df <- data2[ ,2:10]
  16.  
  17. media <- rep(0, length(duration))
  18. varianza <- rep(0,length(duration))
  19. skewness <- rep(0,length(duration))
  20. for (i in 1:length(duration)) {
  21.   x <- df[ ,i]
  22.   media[i] <- mean(x)
  23.   varianza[i] <- var(x)
  24.   skewness[i] <- skewness(x)
  25.   par[i,1] <- media[i]
  26.   par[i,2] <- varianza[i]
  27.   par[i,3] <- skewness[i]  
  28. }
  29.  
  30. plot(duration, par[ ,1], ylab = "value", main = "Media", type = 'l', col = 'red', lwd = 2)
  31. plot(duration, par[ ,2], ylab = "value", main = "Varianza", col = 'blue', lwd = 2, type = 'l')
  32. plot(duration, par[ ,3], ylab = "value", main = "coeff. di Skewness", col = 'green', lwd = 2, type = 'l')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement