data(hue)
## Second degree polynomial model with random intercept, slope and
## quadratic term
fm1 <- lcc(data = hue, subject = "Fruit", resp = "H_mean",
method = "Method", time = "Time", qf = 2, qr = 2)
print(fm1)
summary(fm1)
summary(fm1, type = "model")
lccPlot(fm1) +
ylim(0, 1) +
geom_hline(yintercept = 1, linetype = "dashed") +
scale_x_continuous(breaks = seq(1, max(hue$Time), 2))
## Estimating longitudinal Pearson correlation and longitudinal
## accuracy
fm2 <- update(fm1, components = TRUE)
summary(fm2)
lccPlot(fm2) +
ylim(0, 1) +
geom_hline(yintercept = 1, linetype = "dashed") +
scale_x_continuous(breaks = seq(1, max(hue$Time), 2)) +
theme_bw()
if (FALSE) {
## A grid of points as the Time variable for prediction
fm3 <- update(
fm2,
time_lcc = list(
from = min(hue$Time),
to = max(hue$Time),
n = 40
)
)
summary(fm3)
lccPlot(fm3) +
ylim(0, 1) +
geom_hline(yintercept = 1, linetype = "dashed") +
scale_x_continuous(breaks = seq(1, max(hue$Time), 2)) +
theme_bw()
}
## Including an exponential variance function using time as a
## covariate
fm4 <- update(
fm2,
time_lcc = list(from = min(hue$Time),
to = max(hue$Time),
n = 30),
var.class = varExp,
weights.form = "time"
)
summary(fm4, type = "model")
fitted(fm4)
fitted(fm4, type = "lpc")
fitted(fm4, type = "la")
lccPlot(fm4) +
geom_hline(yintercept = 1, linetype = "dashed")
lccPlot(fm4, type = "lpc") +
geom_hline(yintercept = 1, linetype = "dashed")
lccPlot(fm4, type = "la") +
geom_hline(yintercept = 1, linetype = "dashed")
if (FALSE) {
## Non-parametric confidence interval with 500 bootstrap samples
fm5 <- update(fm1, ci = TRUE, nboot = 500)
summary(fm5)
lccPlot(fm5) +
geom_hline(yintercept = 1, linetype = "dashed")
}
## Considering three methods of colour evaluation
if (FALSE) {
data(simulated_hue)
attach(simulated_hue)
fm6 <- lcc(
data = simulated_hue,
subject = "Fruit",
resp = "Hue",
method = "Method",
time = "Time",
qf = 2,
qr = 1,
components = TRUE,
time_lcc = list(
n = 50,
from = min(Time),
to = max(Time)
)
)
summary(fm6)
lccPlot(fm6, scales = "free")
lccPlot(fm6, type = "lpc", scales = "free")
lccPlot(fm6, type = "la", scales = "free")
detach(simulated_hue)
}
## Including an additional covariate in the linear predictor
## (randomised block design)
if (FALSE) {
data(simulated_hue_block)
attach(simulated_hue_block)
fm7 <- lcc(
data = simulated_hue_block,
subject = "Fruit",
resp = "Hue",
method = "Method",
time = "Time",
qf = 2,
qr = 1,
components = TRUE,
covar = c("Block"),
time_lcc = list(
n = 50,
from = min(Time),
to = max(Time)
)
)
summary(fm7)
lccPlot(fm7, scales = "free")
detach(simulated_hue_block)
}
## Testing the interaction effect between time and method
fm8 <- update(fm1, interaction = FALSE)
anova(fm1, fm8)
if (FALSE) {
## Using parallel computing with 3 cores, and set.seed(123) to
## verify model reproducibility
set.seed(123)
fm9 <- lcc(
data = hue,
subject = "Fruit",
resp = "H_mean",
method = "Method",
time = "Time",
qf = 2,
qr = 2,
ci = TRUE,
nboot = 30,
numCore = 3
)
## Repeating the same model with the same seed
set.seed(123)
fm10 <- lcc(
data = hue,
subject = "Fruit",
resp = "H_mean",
method = "Method",
time = "Time",
qf = 2,
qr = 2,
ci = TRUE,
nboot = 30,
numCore = 3
)
## Verifying that fitted values and confidence intervals are
## identical
identical(fm9$Summary.lcc$fitted, fm10$Summary.lcc$fitted)
}
Run the code above in your browser using DataLab