20210823_dFF-prediction-BMD_TV_v3.Rmd 2.47 KB
Newer Older
Keene's avatar
Keene committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
title: "Predicting change in FF in Becker"
author: "Thom TJ Veeger"
date: "23/08/2021"
output: 
  html_document:
    toc: true
---

# Preamble

Set options, read the data.

```{r set-options, echo=FALSE, cache=FALSE}
options(width=200)
```

```{r loading data, warning=FALSE, message=FALSE}

library(foreign)
library(visreg)
library(ggplot2)
library(nlme)
library(lme4)     # for the mixed model
library(lmerTest)
library(bootpredictlme4) # for confidence intervals visreg lmer
library(lattice)

Keene's avatar
Keene committed
29
30
dataset=read.spss("~",to.data.frame=TRUE)
dataset2=read.spss("~",to.data.frame=TRUE)
Keene's avatar
Keene committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
```


# Linear mixed model FFbase to predict FF (upper and lower leg data)

```{r simple regression with only FFbase and upperleg, warning=FALSE, message=FALSE}
model = lmer(dFF ~ poly(FFbase,4) + (1|Subject) + (1|Muscle),data=dataset2, control=lmerControl(optCtrl=list(maxfun=1e8)),REML=FALSE)

summary(model)
CI=confint(model)
CI

tmp=visreg(model,plot=FALSE)
fig3 <- plot(tmp, gg=TRUE,ylab="∆FF",xlab="FFbase",fill.par=list(fill="#ADD8E6"),points.par = list(size = 0.3))+theme(axis.text=element_text(size=10),axis.title=element_text(size=10, face = 'bold'))

```

# Linear mixed effects model FFbase, stdT2, PDE/ATP to predict FF (lower leg data)

```{r linear mixed effects model, warning=FALSE, message=FALSE}

# Check for outliers and influential points
plot(cooks.distance(model1))
dataset$stdT2_Z = dataset %>% mutate(zscore = (stdT2 - mean(stdT2))/sd(stdT2))
plot(dataset$stdT2_Z$stdT2)


# Removal of datapoint 8 and running the model
dataset_filt = dataset[-c(8),]
model1 = lmer(dFF ~ poly(FFbase,4) + stdT2 + PDE_ATP + (1|Subject) + (1|Muscle),data=dataset_filt, control=lmerControl(optCtrl=list(maxfun=1e8)),REML=FALSE)
summary(model1)
r.squaredGLMM(model1)

CI=confint(model1)
CI

options(bootnsim=1000)
tmp2=visreg(model1,plot=FALSE)

fig4_1 <- plot(tmp2[[1]],gg=TRUE,ylab="∆FF",xlab="FFbase",fill.par=list(fill="#ADD8E6"),points.par = list(size = 0.3))+theme(axis.text=element_text(size=10),axis.title=element_text(size=10,face="bold"))
fig4_1

fig4_2 <- plot(tmp2[[2]],gg=TRUE,ylab="∆FF",xlab=expression(bold(paste(stdT[2],phantom(l),'[ms]'))),fill.par=list(fill="#ADD8E6"),points.par = list(size = 0.3))+theme(axis.text=element_text(size=10),axis.title=element_text(size=10,face="bold"))
fig4_2

fig4_3 <- plot(tmp2[[3]],gg=TRUE,ylab="∆FF",xlab="PDE/ATP",fill.par=list(fill="#ADD8E6"),points.par = list(size = 0.3))+theme(axis.text=element_text(size=10),axis.title=element_text(size=10,face="bold"))
fig4_3

```