We will now make use of the fact that the variables in
nlsdata are organized in three temporal tiers,
corresponding to the survey round in which they were measured:
r1, r6, and r12.
Run the temporal PC algorithm:
# Define temporal background knowledge
tempoinfo <- knowledge(nlsdata,
tier(r1 ~ r1_mcollege + r1_urban + r1_hhchildren,
r6 ~ r6_depressed + r6_docvisits + r6_exercise,
r12 ~ r12_depressed + r12_docvisits + r12_health))
# Run temporal PC algorithm
tpcres <- disco(nlsdata, tpc(engine = "causalDisco",
test = "reg",
alpha = 0.05),
knowledge = tempoinfo)
Plot the result (plot(tpcres)) and compare it with what
you found in exercise 1.2 (ordinary PC algorithm):
pcres and tpcres,
do you find to be overall most plausible?We will now make three alternative versions of the temporal background knowledge where variables are assigned differently to tiers:
# new temporal background knowledge where mcollege is assigned to its own
# (first) tier named r0:
tempoinfo_4tiers <-knowledge(nlsdata,
tier(r0 ~ r1_mcollege,
r1 ~ r1_urban + r1_hhchildren,
r6 ~ r6_depressed + r6_docvisits + r6_exercise,
r12 ~ r12_depressed + r12_docvisits + r12_health))
# new temporal background knowledge where r1 and r6 are collapsed into one
# (named r1_r6)
tempoinfo_bigearly <-knowledge(nlsdata,
tier(r1_r6 ~ r1_mcollege + r1_urban + r1_hhchildren +
r6_depressed + r6_docvisits + r6_exercise,
r12 ~ r12_depressed + r12_docvisits + r12_health))
# new temporal background knowledge where r6 and r12 are collapsed into one
# (named r6_r12)
tempoinfo_biglate <-knowledge(nlsdata,
tier(r1 ~ r1_mcollege + r1_urban + r1_hhchildren,
r6_r12 ~ r6_depressed + r6_docvisits +
r6_exercise + r12_depressed +
r12_docvisits + r12_health))
Run the TPC algorithm with each of these new knowledge objects using this code:
tpcres_4tiers <- disco(nlsdata, tpc(engine = "causalDisco",
test = "reg", alpha = 0.05),
knowledge = tempoinfo_4tiers)
tpcres_bigearly <- disco(nlsdata, tpc(engine = "causalDisco",
test = "reg", alpha = 0.05),
knowledge = tempoinfo_bigearly)
tpcres_biglate <- disco(nlsdata, tpc(engine = "causalDisco",
test = "reg", alpha = 0.05),
knowledge = tempoinfo_biglate)
Look at each of the models, and compare them with each other and the results from 3.1 and 2.1. Which version of tiered information seems to be most useful for the algorithm?
Now, consider whether you want to change any parts of our first attempt at an expert CPDAG for these data, based on what you found using TPC.
Go back to exercises 2.1, or 2.4 and rerun them using the TPC algorithm instead of the PC algorithm.