foot <- read.table("DATA/lrm-foot.txt",header=T) summary(foot) library(car) dataEllipse(foot$foot.L, foot$body.H, level=0.95, xlab='Delka chodidla (mm)', ylab='Telesna vyska (mm)', xlim=c(210,300), ylim=c(1500, 1950)) cor.test(foot$foot.L, foot$body.H, method='pearson') neck <- read.table("DATA/cneck.txt",header=T) summary(neck) plot(neck[,3:8]) cov(neck[,3:8], method='pearson') cor(neck[,3:8], method='pearson') library(Hmisc) rcorr(as.matrix(neck[,3:8]), type='pearson') m1 <- lm(neck.C ~ body.H + waist.C + hip.C + antb.C, data=neck) y.res <- m1$residuals m2 <- lm(body.W ~ body.H + waist.C + hip.C + antb.C, data=neck) z.res <- m2$residuals r_yz.x <- cor(y.res,z.res) r_yz.x n <- nrow(neck) k <- 4 t.obs <- r_yz.x*sqrt(n-k-2)/sqrt(1-r_yz.x^2) t.obs qt(0.975,n-k-2) 2*(1-pt(abs(t.obs), n-k-2)) library(ppcor) pcor(neck[,3:8], method='pearson') cor.yx <- cor(neck$neck.C, neck[,3:7], method='pearson') cor.yx cor.xx <- cor(neck[,3:7], method='pearson') cor.xx r.yx <- sqrt(cor.yx %*% solve(cor.xx) %*% t(cor.yx)) r.yx model <- lm(neck.C ~ body.W + body.H + waist.C + hip.C + antb.C, data=neck) y.odhad <- model$fitted.values r.yx <- cor(neck$neck.C, y.odhad, method='pearson') r.yx ID <- summary(model)$r.squared sqrt(ID) n <- nrow(neck) k <- 5 F.obs <- (n-k-1)/k * r.yx^2/(1-r.yx^2) F.obs ## [1] 97.33264 qf(0.95,df1=k, df2=n-k-1) summary(model)