# Prvni priklad - index determinace # nacteni dat load("cviceni4.RData") x <- data4$pr1$x y <- data4$pr1$y yhat <- data4$pr1$yhat # vypocet - 1. zpusob jmen <- mean((y-mean(y))^2) ID <- mean((yhat-mean(y))^2)/jmen ID # vypocet - 2. zpusob residuals <- y-yhat cit <- mean(residuals^2) ID <- 1-cit/jmen ID # Druhy priklad - mnohonasobna korelace vyb <- data4$pr2 y <- vyb$Ozone X<-vyb[,-1] RXX <- cor(X,X) r <- cor(y,X) ir<-solve(RXX) r%*%ir%*%t(r) #druhy zpusob R<-cor(vyb,vyb) (1-det(R)/det(RXX)) # Treti priklad - parcialni korelace pomoci prikazu # baliky #install.packages("ggm") library(ggm) pcor(c("Ozone","Solar.R","Wind","Temp"),var(vyb)) pcor(c("Ozone","Wind","Solar.R","Temp"),var(vyb)) pcor(c("Ozone","Temp","Wind","Solar.R"),var(vyb)) # parcialni Ozone X Solar.R s vyloucenim ost. rcit <- R[-1,-2] det(rcit)/sqrt(det(R[-1,-1])*det(R[-2,-2])) # -----------------------------------------------------------------