# Replicate the fit plot that was obtained in
# Case study 1 of Chapter 7 in Van der Elst (2023)
# ------------------------------------------------
library(NormData) # load the NormData package
data(Substitution) # load the Substitution dataset
head(Substitution) # have a look at the first datalines in
# the Substitution dataset
# Final Stage 1 model
Substitution$Age.C <- Substitution$Age - 50
# Add Age_Group (that discretizes the quantitative variable Age
# into 6 groups with a span of 10 years in the dataset for use
# by the CheckFit() function later on)
Substitution$Age_Group <- cut(Substitution$Age,
breaks=seq(from=20, to=80, by=10))
Substitution.Model.9 <- Stage.1(Dataset=Substitution,
Alpha=0.005, Model=LDST~Age.C+LE, Order.Poly.Var=1)
# Examine fit
Fit.LDST <- CheckFit(Stage.1.Model=Substitution.Model.9,
Means=LDST~Age_Group+LE)
summary(Fit.LDST)
plot(Fit.LDST)
# Replicate the fit plot that was obtained in
# Case study 2 of Chapter 7 in Van der Elst (2023)
# ------------------------------------------------
library(NormData) # load the NormData package
data(VLT) # load the VLT dataset
head(VLT) # have a look at the first datalines in
# the VLT dataset
# Fit the final Stage 1 model
VLT$Age.C <- VLT$Age - 50
VLT$Age.C2 <- (VLT$Age - 50)**2
# Add Age_Group (that discretizes the quantitative variable Age
# into 6 groups with a span of 10 years in the dataset for use
# by the CheckFit() function later on)
VLT$Age_Group <- cut(VLT$Age, breaks=seq(from=20, to=80, by=10))
VLT.Model.4 <- Stage.1(Dataset = VLT, Alpha = .005,
Model = Total.Recall ~ Age.C+Age.C2+Gender+LE+Age.C:Gender)
# Examine fit using fit plots for the Age Group by
# LE by Gender subgroups
Fit.Means.Total.Recall <- CheckFit(Stage.1.Model=VLT.Model.4,
Means=Total.Recall~Age_Group+LE+Gender)
summary(Fit.Means.Total.Recall)
plot(Fit.Means.Total.Recall)
Run the code above in your browser using DataLab