Settings

# coding: UTF-8
library(BlandAltmanLeh) # for BA plots
knitr::opts_chunk$set(echo = TRUE, options(digits = 4), options(OutDec = ","))
# remove everything from the environment:
rm(list=ls())
setwd("F:/pendrivok/oktatos/oktatas_2020tavasz/nemet_stat/3")

Bland-Altman plot

Comparing 2 measurement: eg. blood pressure measured with Arm and Finger Device

BA <- read.csv("BA.csv", sep=";")

Create correlation

plot(BA$A~BA$B)
abline(lm(BA$A~BA$B))

Correlation coefficient

cor.test(BA$A,BA$B)
## 
##  Pearson's product-moment correlation
## 
## data:  BA$A and BA$B
## t = 58, df = 28, p-value <2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0,9911 0,9980
## sample estimates:
##    cor 
## 0,9958

Regression

mod_lm <- lm(A~B, data = BA)
mod_lm
## 
## Call:
## lm(formula = A ~ B, data = BA)
## 
## Coefficients:
## (Intercept)            B  
##      -8,388        0,952
summary(mod_lm)
## 
## Call:
## lm(formula = A ~ B, data = BA)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -53,38 -12,99  -1,81   8,77  94,45 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -8,3877     8,6056   -0,97     0,34    
## B             0,9520     0,0165   57,56   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0,001 '**' 0,01 '*' 0,05 '.' 0,1 ' ' 1
## 
## Residual standard error: 31,1 on 28 degrees of freedom
## Multiple R-squared:  0,992,  Adjusted R-squared:  0,991 
## F-statistic: 3,31e+03 on 1 and 28 DF,  p-value: <2e-16
confint(mod_lm)
##                2,5 % 97,5 %
## (Intercept) -26,0155 9,2401
## B             0,9181 0,9859

Opinion?

summary(BA)
##        A                B             X             X.1            X.2         
##  Min.   :   1,0   Min.   :   8,0   Mode:logical   Mode:logical   Mode:logical  
##  1st Qu.:  62,5   1st Qu.:  63,5   NA's:30        NA's:30        NA's:30       
##  Median : 275,0   Median : 297,5                                               
##  Mean   : 364,2   Mean   : 391,4                                               
##  3rd Qu.: 637,5   3rd Qu.: 715,5                                               
##  Max.   :1000,0   Max.   :1001,0                                               
##    X.3         
##  Mode:logical  
##  NA's:30       
##                
##                
##                
## 
t.test(BA$A,BA$B)
## 
##  Welch Two Sample t-test
## 
## data:  BA$A and BA$B
## t = -0,31, df = 58, p-value = 0,8
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -203,5  149,2
## sample estimates:
## mean of x mean of y 
##     364,2     391,4

BA plot (req. BlandAltmanLeh)

bland.altman.plot(BA$A,BA$B, conf.int = 0.95)

## NULL