Back Pain
and Age
.Back Pain
and Body Fat
Back Pain
and BMI
Back Pain
and Body Weight
Back Pain
and High Blood Pressure
Back Pain
and Alcohol Intake in the last 12 month
Back Pain
and Attentiveness Problems
Amount of Sleep
and Back Pain
This notebooks conducts a statistical analysis of hypotheses derived through the VAST’14 publication Interactive Visual Analysis of Image-Centric Cohort Study Data.
Sources are:
Load the data and only keep subjects with extracted centerlines. This is necessary to have a concurrent population with the paper.
library(gplots)
library(jsonlite)
library(dplyr)
library(vcd)
library(gridExtra)
# Odds Ratio Function according to https://de.wikipedia.org/wiki/Quotenverh%C3%A4ltnis#Anwendung
calculate_odds <- function(contingency_table) {
return ( ( contingency_table[1,1] * contingency_table[2,2] ) / ( contingency_table[1,2] * contingency_table[2,1] ) )
}
calculate_odds_inverse <- function(contingency_table) {
return ( ( contingency_table[1,2] * contingency_table[2,1] ) / ( contingency_table[1,1] * contingency_table[2,2] ) )
}
# Get all subjects IDs with centerlines
centerlines <- list.files('/Users/paul/Sites/vis14/site/data/centerlines')
# Replace the centerlines to leave only the subject IDs
centerlines <- gsub(pattern = '_MESH_COR_ES.vtk', replacement = '', centerlines)
#'/Users/paul/Sites/vis14/site/data/ship-data/data/shipdata/s0-t0_correlations.json'
# Now read both SHIP cohorts and only keep the subjects with a centerline
ship_s2 <- read.csv('/Users/paul/Sites/vis14/site/data/ship-data/data/shipdata/SHIP_2013_174_D_S2_complete/SHIP_2013_174_D_S2_complete.csv')
ship_t0 <- read.csv('/Users/paul/Sites/vis14/site/data/ship-data/data/shipdata/SHIP_2013_174_D_T0_complete/SHIP_2013_174_D_T0_complete.csv')
# Rename dimension names
same_features <- fromJSON('same_features.json')
for (rename_feature in same_features) {
names(ship_t0)[names(ship_t0)==rename_feature$name_t0] <- rename_feature$newName
names(ship_s2)[names(ship_s2)==rename_feature$name_s2] <- rename_feature$newName
}
ship <- merge(ship_s2, ship_t0, all = TRUE)
# Only keep subjects with an extracted centerline (https://stackoverflow.com/questions/9860090/in-r-why-is-better-than-subset)
ship <- ship[ship$zz_nr %in% centerlines, ]
# Add BMI
ship <- mutate(ship, BMI = ship$Gewicht / ( (ship$Groesse / 100) * (ship$Groesse / 100) ) )
# Add Subjects Over 60
ship <- mutate(ship, AgeOver60 = ship$Age > 60)
ship <- mutate(ship, AgeOver70 = ship$Age > 70)
ship <- mutate(ship, AgeOver80 = ship$Age > 80)
# Filter Subjects above 60
ship_age <- filter(ship, Age > 60)
Back Pain
and Age
.At first, display the means between the groups.
H_0 There is no difference in Back Pain
regarding Age
.
H_1 The Back Pain
groups are not equal w.r.t. Age
.
par(mfrow=c(2,2), oma=c(1,1,2,1), mar=c(2,2,2,2))
plotmeans(ship$Age ~ ship$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of Age by back pain")
## Warning in qt((1 + p)/2, ns - 1): NaNs produced
## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
boxplot(ship$Age ~ ship$Rueckenschmerz_3Monate, main="Back pain by age (mean is black dot)", xlab="back pain", ylab="age", col=rainbow(7))
plotmeans(ship_age$Age ~ ship_age$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of Age by back pain")
## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, li, x, pmax(y - gap, li), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
## Warning in arrows(x, ui, x, pmin(y + gap, ui), col = barcol, lwd = lwd, :
## zero-length arrow is of indeterminate angle and so skipped
boxplot(ship_age$Age ~ ship_age$Rueckenschmerz_3Monate, main="Back pain by age (mean is black dot)", xlab="back pain", ylab="age", col=rainbow(7))
title(main = "Top: Age by Back Pain; Bottom: Subjects older than 60 years", outer=TRUE)
The few outliers may distort the analysis, therefore I remove them.
# Convert back pain to a factor variable
ship$Rueckenschmerz_3Monate <- as.factor(ship$Rueckenschmerz_3Monate)
ship_age$Rueckenschmerz_3Monate <- as.factor(ship_age$Rueckenschmerz_3Monate)
# Analyze only for subjects with valid back pain indicators
ship_valid_backpain <- filter(ship, !(as.character(Rueckenschmerz_3Monate)%in% c("99996", "99998", "99999")))
ship_age_valid_backpain <- filter(ship_age, !(as.character(Rueckenschmerz_3Monate)%in% c("99996", "99998", "99999")))
ship_valid_backpain <- droplevels(ship_valid_backpain)
ship_age_valid_backpain <- droplevels(ship_age_valid_backpain)
Apply the same plot again.
par(mfrow=c(2,2), oma=c(1,1,2,1), mar=c(2,2,2,2))
plotmeans(ship_valid_backpain$Age ~ ship_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of Age by back pain")
boxplot(ship_valid_backpain$Age ~ ship_valid_backpain$Rueckenschmerz_3Monate, main="Back pain by age (mean is black dot)", xlab="back pain", ylab="age", col=rainbow(7))
plotmeans(ship_age_valid_backpain$Age ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of Age by back pain")
boxplot(ship_age_valid_backpain$Age ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, main="Back pain by age (mean is black dot)", xlab="back pain", ylab="age", col=rainbow(7))
title(main = "Top: Age by Back Pain; Bottom: Subjects older than 60 years", outer=TRUE)
Calculate the ANOVA for both data sets.
summary(aov(formula = Age~Rueckenschmerz_3Monate, data = ship))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 4 1685 421.3 2.31 0.0557 .
## Residuals 2535 462441 182.4
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(aov(formula = Age~Rueckenschmerz_3Monate, data = ship_valid_backpain))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 2 1.69 0.009 0.923
## Residuals 2532 462204 182.55
summary(aov(formula = Age~Rueckenschmerz_3Monate, data = ship_age))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 2 47 23.44 0.728 0.483
## Residuals 823 26494 32.19
summary(aov(formula = Age~Rueckenschmerz_3Monate, data = ship_age_valid_backpain))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 0 0.23 0.007 0.933
## Residuals 821 26419 32.18
Neither of the features are suitable to confirm the alternative hypothesis. Help with the interpretation can be found here:
Now we further calculate the Odds Ratio for back pain and age over 60.
# Create Tabs
tab_age_backpain_over60 <- xtabs(~Rueckenschmerz_3Monate + AgeOver60, data = ship_valid_backpain)
tab_age_backpain_over70 <- xtabs(~Rueckenschmerz_3Monate + AgeOver70, data = ship_valid_backpain)
tab_age_backpain_over80 <- xtabs(~Rueckenschmerz_3Monate + AgeOver80, data = ship_valid_backpain)
print(tab_age_backpain_over60)
## AgeOver60
## Rueckenschmerz_3Monate FALSE TRUE
## 1 1028 481
## 2 683 342
print(tab_age_backpain_over70)
## AgeOver70
## Rueckenschmerz_3Monate FALSE TRUE
## 1 1345 164
## 2 918 107
print(tab_age_backpain_over80)
## AgeOver80
## Rueckenschmerz_3Monate FALSE TRUE
## 1 1495 14
## 2 1013 12
# Calculate the inverse Odds ratio, since "false" is the first entry in the table
print(calculate_odds_inverse(tab_age_backpain_over60))
## [1] 0.9344295
print(calculate_odds_inverse(tab_age_backpain_over70))
## [1] 1.046117
print(calculate_odds_inverse(tab_age_backpain_over80))
## [1] 0.790524
The Odds for having back pain is therefore nearly equal for subjects older or junger than 60 years and 70 years. The odds ratio drops for subjects older than 80 years, but this may be due to the rather low sample size of only 26 subjects older than 80 years.
Back Pain
and Body Fat
At first, plot again the means as well as create the boxplots.
par(mfrow=c(2,2), oma=c(1,1,2,1), mar=c(2,2,2,2))
plotmeans(ship_valid_backpain$BIA_KOERPERFETT_KORR_IN_PROZ ~ ship_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of body fat by back pain", xlab="back pain", ylab="body fat")
boxplot(ship_valid_backpain$BIA_KOERPERFETT_KORR_IN_PROZ ~ ship_valid_backpain$Rueckenschmerz_3Monate, main="back pain by body fat (mean is black dot)", xlab="back pain", ylab="body fat", col=rainbow(7))
plotmeans(ship_age_valid_backpain$BIA_KOERPERFETT_KORR_IN_PROZ ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of body fat by back pain", xlab="back pain", ylab="body fat")
boxplot(ship_age_valid_backpain$BIA_KOERPERFETT_KORR_IN_PROZ ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, main="back pain by body fat (mean is black dot)", xlab="back pain", ylab="body fat", col=rainbow(7))
title(main = "Top: Age by Body Fat; Bottom: Subjects older than 60 years", outer=TRUE)
The boxplot shows that there are most likely error codes still in the body fat
group, which are therefore removed.
ship_valid_backpain_bodyfat <- filter(.data = ship_valid_backpain, BIA_KOERPERFETT_KORR_IN_PROZ < 90000)
ship_age_valid_backpain_bodyfat <- filter(.data = ship_age_valid_backpain, BIA_KOERPERFETT_KORR_IN_PROZ < 90000)
par(mfrow=c(1,2), oma=c(1,1,2,1), mar=c(2,2,2,2))
boxplot(ship_valid_backpain_bodyfat$BIA_KOERPERFETT_KORR_IN_PROZ ~ ship_valid_backpain_bodyfat$Rueckenschmerz_3Monate, main="back pain by body fat (mean is black dot)", xlab="back pain", ylab="body fat", col=rainbow(7))
boxplot(ship_age_valid_backpain_bodyfat$BIA_KOERPERFETT_KORR_IN_PROZ ~ ship_age_valid_backpain_bodyfat$Rueckenschmerz_3Monate, main="back pain by body fat (mean is black dot)", xlab="back pain", ylab="body fat", col=rainbow(7))
summary(aov(formula = BIA_KOERPERFETT_KORR_IN_PROZ~Rueckenschmerz_3Monate, data = ship_valid_backpain_bodyfat))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 1483 1482.9 24.33 8.64e-07 ***
## Residuals 2494 151991 60.9
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(aov(formula = BIA_KOERPERFETT_KORR_IN_PROZ~Rueckenschmerz_3Monate, data = ship_age_valid_backpain_bodyfat))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 341 340.7 5.699 0.0172 *
## Residuals 811 48479 59.8
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The p value is very low with a high F value, therefore we can accept the alternative hypothesis.
Now we look at the Odds ratios for subjects with high body fat percentages. The WHO does not depict clear cutoff values for obesity levels w.r.t. body fat percentage. Therefore, we use cutoff values from a peer reviewed clinical paper correlating obesity to cardiometabolic dysregulation and cardiovascular mortality.
# Calculate Odds Ratios for Males and Females
ship_valid_backpain_bodyfat <- mutate(ship_valid_backpain_bodyfat, FatPercenteageOver23 = BIA_KOERPERFETT_KORR_IN_PROZ > 23.15)
ship_valid_backpain_bodyfat <- mutate(ship_valid_backpain_bodyfat, FatPercenteageOver33 = BIA_KOERPERFETT_KORR_IN_PROZ > 33.3)
# SEX == 1 is Male and SEX == 2 is Female
tab_bodyfat_backpain_females <- xtabs(~Rueckenschmerz_3Monate + FatPercenteageOver33, data = filter(ship_valid_backpain_bodyfat, SEX == 2))
tab_bodyfat_backpain_males <- xtabs(~Rueckenschmerz_3Monate + FatPercenteageOver23, data = filter(ship_valid_backpain_bodyfat, SEX == 1))
print(tab_bodyfat_backpain_females)
## FatPercenteageOver33
## Rueckenschmerz_3Monate FALSE TRUE
## 1 321 439
## 2 189 227
print(tab_bodyfat_backpain_males)
## FatPercenteageOver23
## Rueckenschmerz_3Monate FALSE TRUE
## 1 311 415
## 2 293 301
# Calculate the inverse Odds ratio, since "false" is the first entry in the table
odds_bodyfat_backpain_females <- calculate_odds_inverse(tab_bodyfat_backpain_females)
odds_bodyfat_backpain_males <- calculate_odds_inverse(tab_bodyfat_backpain_males)
print(odds_bodyfat_backpain_females)
## [1] 1.138664
print(odds_bodyfat_backpain_males)
## [1] 1.298939
The odds for obese women to have back pain as oposed to non-obese women are 1.1386636. For Men, this effect is even stronger, having an odds ratio of 1.2989392 to have back pain with obesity.
Back Pain
and BMI
To assess the BMI, display the histograms
par(mfrow=c(1,2), oma=c(1,1,2,1), mar=c(2,2,2,2))
hist(ship$BMI)
hist(ship_age$BMI)
title(main = "Left: Histogram of BMI; Right: Subjects older than 60 years", outer=TRUE)
Plot the means as well as create the boxplots.
par(mfrow=c(2,2), oma=c(1,1,2,1), mar=c(2,2,2,2))
plotmeans(ship_valid_backpain$BMI ~ ship_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of BMI by back pain", xlab="back pain", ylab="BMI")
boxplot(ship_valid_backpain$BMI ~ ship_valid_backpain$Rueckenschmerz_3Monate, main="back pain by BMI (mean is black dot)", xlab="back pain", ylab="BMI", col=rainbow(7))
plotmeans(ship_age_valid_backpain$BMI ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of BMI by back pain", xlab="back pain", ylab="BMI")
boxplot(ship_age_valid_backpain$BMI ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, main="back pain by BMI (mean is black dot)", xlab="back pain", ylab="BMI", col=rainbow(7))
title(main = "Top: Age by BMI; Bottom: Subjects older than 60 years", outer=TRUE)
summary(aov(formula = BMI~Rueckenschmerz_3Monate, data = ship_valid_backpain))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 64 64.17 3.354 0.0672 .
## Residuals 2532 48444 19.13
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(aov(formula = BMI~Rueckenschmerz_3Monate, data = ship_age_valid_backpain))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 0 0.242 0.014 0.906
## Residuals 821 14219 17.319
There is no correlation with BMI
and Back Pain
observable in the data. This is followed up with calculating the Odds Ratios of back pain with obese subjects according to the BMI.
# Create Obesity BMI feature
ship_valid_backpain <- mutate(ship_valid_backpain, BMIObese = BMI >= 30)
# SEX == 1 is Male and SEX == 2 is Female
tab_bmi_backpain <- xtabs(~Rueckenschmerz_3Monate + BMIObese, data = ship_valid_backpain)
print(tab_bmi_backpain)
## BMIObese
## Rueckenschmerz_3Monate FALSE TRUE
## 1 1041 468
## 2 750 275
# Calculate the inverse Odds ratio, since "false" is the first entry in the table
odds_bmi_backpain <- calculate_odds_inverse(tab_bmi_backpain)
print(odds_bmi_backpain)
## [1] 1.226094
Therefore, obese subjects show an odds ratio of 1.2260938 to have back pain.
Back Pain
and Body Weight
At first, plot again the means as well as create the boxplots.
par(mfrow=c(2,2), oma=c(1,1,2,1), mar=c(2,2,2,2))
plotmeans(ship_valid_backpain$Gewicht ~ ship_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of body fat by back pain", xlab="back pain", ylab="body fat")
boxplot(ship_valid_backpain$Gewicht ~ ship_valid_backpain$Rueckenschmerz_3Monate, main="back pain by body fat (mean is black dot)", xlab="back pain", ylab="body fat", col=rainbow(7))
plotmeans(ship_age_valid_backpain$Gewicht ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, digits=2, ccol="red", mean.labels=T, main="Plot of body fat by back pain", xlab="back pain", ylab="body fat")
boxplot(ship_age_valid_backpain$Gewicht ~ ship_age_valid_backpain$Rueckenschmerz_3Monate, main="back pain by body fat (mean is black dot)", xlab="back pain", ylab="body fat", col=rainbow(7))
title(main = "Top: Age by Body Weight; Bottom: Subjects older than 60 years", outer=TRUE)
summary(aov(formula = Gewicht~Rueckenschmerz_3Monate, data = ship_valid_backpain))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 5 4.63 0.021 0.884
## Residuals 2532 554683 219.07
summary(aov(formula = Gewicht~Rueckenschmerz_3Monate, data = ship_age_valid_backpain))
## Df Sum Sq Mean Sq F value Pr(>F)
## Rueckenschmerz_3Monate 1 716 716.1 3.72 0.0541 .
## Residuals 821 158043 192.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The ANOVA rejects the alternative hypothesis.
Back Pain
and High Blood Pressure
Since both features are categorical, the statistic of choice is Cramérs V. At first, look at the mosaic plot.
tab_standard <- xtabs(~Blutdruck_hoch + Rueckenschmerz_3Monate, data = ship_valid_backpain)
tab_age <- xtabs(~Blutdruck_hoch + Rueckenschmerz_3Monate, data = ship_age_valid_backpain)
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Blutdruck_hoch="High Blood Pressure", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Blutdruck_hoch="High Blood Pressure (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
Blood pressure
shows some error markers, which are removed before conducting the Cramérs V analysis.
ship_valid_backpain_bloodpressure <- filter(.data = ship_valid_backpain, Blutdruck_hoch < 900)
ship_age_valid_backpain_bloodpressure <- filter(.data = ship_age_valid_backpain, Blutdruck_hoch < 900)
tab_standard <- xtabs(~Blutdruck_hoch + Rueckenschmerz_3Monate, data =
ship_valid_backpain_bloodpressure)
tab_age <- xtabs(~Blutdruck_hoch + Rueckenschmerz_3Monate, data =
ship_age_valid_backpain_bloodpressure)
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Blutdruck_hoch="High Blood Pressure", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Blutdruck_hoch="High Blood Pressure (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
summary(assocstats(tab_standard))
##
## Call: xtabs(formula = ~Blutdruck_hoch + Rueckenschmerz_3Monate, data = ship_valid_backpain_bloodpressure)
## Number of cases in table: 2529
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 10.669, df = 1, p-value = 0.00109
## X^2 df P(> X^2)
## Likelihood Ratio 10.708 1 0.0010668
## Pearson 10.669 1 0.0010897
##
## Phi-Coefficient : 0.065
## Contingency Coeff.: 0.065
## Cramer's V : 0.065
summary(assocstats(tab_age))
##
## Call: xtabs(formula = ~Blutdruck_hoch + Rueckenschmerz_3Monate, data = ship_age_valid_backpain_bloodpressure)
## Number of cases in table: 821
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 4.806, df = 1, p-value = 0.02836
## X^2 df P(> X^2)
## Likelihood Ratio 4.7982 1 0.028490
## Pearson 4.8059 1 0.028363
##
## Phi-Coefficient : 0.077
## Contingency Coeff.: 0.076
## Cramer's V : 0.077
Cramérs V is very low and therefore, no correlation can be observed.
Back Pain
and Alcohol Intake in the last 12 month
Create a mosaic plot first.
# Create Tabs
tab_standard <- xtabs(~Haeufigkeit_Alkohol_12Monate + Rueckenschmerz_3Monate, data = ship_valid_backpain)
tab_age <- xtabs(~Haeufigkeit_Alkohol_12Monate + Rueckenschmerz_3Monate, data = ship_age_valid_backpain)
# Plot Mosaics
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Haeufigkeit_Alkohol_12Monate="Alcohol Intake in last 12 Month", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Haeufigkeit_Alkohol_12Monate="Alcohol Intake in last 12 Month (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
Remove the error values
# Filter Subjects
ship_valid_backpain_alcohol <- filter(.data = ship_valid_backpain, Haeufigkeit_Alkohol_12Monate < 900)
ship_age_valid_backpain_alcohol <- filter(.data = ship_age_valid_backpain, Haeufigkeit_Alkohol_12Monate < 900)
# Create Tables
tab_standard <- xtabs(~Haeufigkeit_Alkohol_12Monate + Rueckenschmerz_3Monate, data = ship_valid_backpain_alcohol)
tab_age <- xtabs(~Haeufigkeit_Alkohol_12Monate + Rueckenschmerz_3Monate, data = ship_age_valid_backpain_alcohol)
# Plot Mosaics
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Haeufigkeit_Alkohol_12Monate="Alcohol Intake in last 12 Month", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Haeufigkeit_Alkohol_12Monate="Alcohol Intake in last 12 Month (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
# Calculate Correlations
summary(assocstats(tab_standard))
##
## Call: xtabs(formula = ~Haeufigkeit_Alkohol_12Monate + Rueckenschmerz_3Monate,
## data = ship_valid_backpain_alcohol)
## Number of cases in table: 2526
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 8.596, df = 4, p-value = 0.07202
## X^2 df P(> X^2)
## Likelihood Ratio 8.5813 4 0.072462
## Pearson 8.5964 4 0.072019
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.058
## Cramer's V : 0.058
summary(assocstats(tab_age))
##
## Call: xtabs(formula = ~Haeufigkeit_Alkohol_12Monate + Rueckenschmerz_3Monate,
## data = ship_age_valid_backpain_alcohol)
## Number of cases in table: 822
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 9.744, df = 4, p-value = 0.04496
## X^2 df P(> X^2)
## Likelihood Ratio 9.6150 4 0.047437
## Pearson 9.7444 4 0.044961
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.108
## Cramer's V : 0.109
Again a very low value, no correlation found.
Back Pain
and Attentiveness Problems
Create a mosaic plot first.
# Create Tables
tab_standard <- xtabs(~Konzentrationsschwaeche + Rueckenschmerz_3Monate, data = ship_valid_backpain)
tab_age <- xtabs(~Konzentrationsschwaeche + Rueckenschmerz_3Monate, data = ship_age_valid_backpain)
# Plot Mosaics
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Konzentrationsschwaeche="Attentiveness Disorder", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Konzentrationsschwaeche="Attentiveness Disorder (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
Remove the error values
# Remove the Errors Values
ship_valid_backpain_attentive <- filter(.data = ship_valid_backpain, Konzentrationsschwaeche < 900)
ship_age_valid_backpain_attentive <- filter(.data = ship_age_valid_backpain, Konzentrationsschwaeche < 900)
# Create Tabs
tab_standard <- xtabs(~Konzentrationsschwaeche + Rueckenschmerz_3Monate, data = ship_valid_backpain_attentive)
tab_age <- xtabs(~Konzentrationsschwaeche + Rueckenschmerz_3Monate, data = ship_age_valid_backpain_attentive)
# Create Mosaics
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Konzentrationsschwaeche="Attentiveness Disorder", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Konzentrationsschwaeche="Attentiveness Disorder (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
# Calculate Correlations
summary(assocstats(tab_standard))
##
## Call: xtabs(formula = ~Konzentrationsschwaeche + Rueckenschmerz_3Monate,
## data = ship_valid_backpain_attentive)
## Number of cases in table: 2519
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 66.19, df = 3, p-value = 2.786e-14
## X^2 df P(> X^2)
## Likelihood Ratio 67.207 3 1.6875e-14
## Pearson 66.194 3 2.7867e-14
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.16
## Cramer's V : 0.162
summary(assocstats(tab_age))
##
## Call: xtabs(formula = ~Konzentrationsschwaeche + Rueckenschmerz_3Monate,
## data = ship_age_valid_backpain_attentive)
## Number of cases in table: 817
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 38.27, df = 3, p-value = 2.481e-08
## Chi-squared approximation may be incorrect
## X^2 df P(> X^2)
## Likelihood Ratio 38.651 3 2.0578e-08
## Pearson 38.268 3 2.4805e-08
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.212
## Cramer's V : 0.216
The plot actually shows a low relationship of attentiveness problems
and back pain
.
Amount of Sleep
and Back Pain
First, create the mosaic plot.
# Calculate Tabs
tab_standard <- xtabs(~Hohes_Schlafbeduerfnis + Rueckenschmerz_3Monate, data = ship_valid_backpain)
tab_age <- xtabs(~Hohes_Schlafbeduerfnis + Rueckenschmerz_3Monate, data = ship_age_valid_backpain)
# Plot Mosaics
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Hohes_Schlafbeduerfnis="High Amount of Sleep", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Hohes_Schlafbeduerfnis="High Amount of Sleep (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
Remove the error values and conduct the analysis.
# Remove Error Values
ship_valid_backpain_sleep <- filter(.data = ship_valid_backpain, Hohes_Schlafbeduerfnis < 900)
ship_age_valid_backpain_sleep <- filter(.data = ship_age_valid_backpain, Hohes_Schlafbeduerfnis < 900)
# Create Tables
tab_standard <- xtabs(~Hohes_Schlafbeduerfnis + Rueckenschmerz_3Monate, data = ship_valid_backpain_sleep)
tab_age <- xtabs(~Hohes_Schlafbeduerfnis + Rueckenschmerz_3Monate, data = ship_age_valid_backpain_sleep)
# Plot Mosaics
mosaic_standard <- grid.grabExpr(mosaic(tab_standard, shade=TRUE, legend=TRUE, set_varnames = list(Hohes_Schlafbeduerfnis="High Amount of Sleep", Rueckenschmerz_3Monate="Back Pain")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
mosaic_age <- grid.grabExpr(mosaic(tab_age, shade=TRUE, legend=TRUE, set_varnames = list(Hohes_Schlafbeduerfnis="High Amount of Sleep (Age > 60 years)", Rueckenschmerz_3Monate="Back Pain (Age > 60 years)")))
## Warning in grabDL(warn, wrap, ...): viewport overwritten (grab MAY not be
## faithful)
grid.arrange(mosaic_standard, mosaic_age, ncol=2)
# Calculate Correlations
summary(assocstats(tab_standard))
##
## Call: xtabs(formula = ~Hohes_Schlafbeduerfnis + Rueckenschmerz_3Monate,
## data = ship_valid_backpain_sleep)
## Number of cases in table: 2526
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 87.4, df = 3, p-value = 7.912e-19
## X^2 df P(> X^2)
## Likelihood Ratio 90.615 3 0
## Pearson 87.403 3 0
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.183
## Cramer's V : 0.186
summary(assocstats(tab_age))
##
## Call: xtabs(formula = ~Hohes_Schlafbeduerfnis + Rueckenschmerz_3Monate,
## data = ship_age_valid_backpain_sleep)
## Number of cases in table: 820
## Number of factors: 2
## Test for independence of all factors:
## Chisq = 34.11, df = 3, p-value = 1.881e-07
## X^2 df P(> X^2)
## Likelihood Ratio 34.785 3 1.3528e-07
## Pearson 34.106 3 1.8814e-07
##
## Phi-Coefficient : NA
## Contingency Coeff.: 0.2
## Cramer's V : 0.204