Moving away from Linear-Gaussian assumptions Cons: Some things become much harder. No baked-in test of global fit Non-recursive models Error correlations and Latent variables harder to deal with How do we label an arrow? Pros: Flexibility to model nodes with whatever statistical assumption we want to make. Better inference Better predictions
Causal Effects in Non-linear models: How big is the effect? firesev age
The Logic of Graphs: Conditional Independences, Missing link & Testable implications How do we test structure of the model without Var-Cov matrix? x y1 y2 y3 For directed, acyclic models where all nodes are observed, V i ⏊ Non-Child(V j )|Pa(V i,V j ) The residuals of each pair of nodes not connected by a link should be independent. Each missing link represents a local test of the model structure Individual test results can be combined using Fisher’s C to give a global test of structure.
The Logic of Graphs: Conditional Independences, Missing link & Testable implications How do we test structure of the model without Var-Cov matrix? x y1 y2 y3 How many implied CI there? N(N-1)/2-L Where N= number of nodes L=number of links
Strategy for local estimation analysis 1.Create a causal graph 2.Model all nodes as functions of variables given by graph (using model selection of pick functional form) 3.Evaluate all conditional independences implied by graph using model residuals 4.If conditional independence test fails modify graph and goto 2
Generalized Linear Models – 3 components A probability distribution from the exponential family Normal, Log-Normal, Gamma, beta, binomial, Poisson, geometric A Linear predictor A Link function g such that Identity, Log, Logit, Inverse
7 California wildfires example age firesevcover distance abio hetero rich
8 California wildfires example age firesevcover distance abio hetero rich
Causal Assumptions: dist age age firesev firesev cover cover rich dist rich Implied Conditional Independences: firesev ⏊ dist | (age) cover ⏊ dist | (firesev) cover ⏊ age | (firesev) rich ⏊ age | (cover,dist) rich ⏊ firesev | (cover,dist) A. Submodel – it’s causal assumptions and testable implications.
A. Functional Specification I – Models of Uncertainty Variable Potential values Prob. Dist. age{0,1,2,3,…} Negative Binom rich{0,1,2,3,…} Negative Binom firesev (0, ∞) Gamma cover (0, ∞) Gamma
A. Functional Specification II – Models for Expected Values
B. Modeling the Nodes - Age age dist >library(MASS) >a1.lin<-glm.nb(age~distance,data=dat) >a1.q<-glm.nb(age~distance+I(distance^2),…) > AICtab(a1.lin,a1.q,weights=T) dAIC df weight a1.q a1.lin >curve(exp(p.l[1]+p.1[2]*x),from=0,to=100,add=T) >curve(exp(p.q[1]+p.q[2]*x+p.q[3]*x^2),from=0,to=100,add=T,lty=2)
firesev age >f.lin<-glm(firesev~age,family=Gamma(link="log"),…) B. Modeling the Nodes - Firesev >curve(exp(p.f.lin[1]+p.f.lin[2]*x),from=0,to=100,add=T)
Aside- Linearization of a saturating function
firesev age >f.sat<-glm(firesev~I(1/age),family=Gamma(link="inverse"),…) >curve(1/p.f.sat[2]*x/(1+1/p.f.sat[2]*p.f.sat[1]*x),from=0, to=65,add=T,lty=2) B. Modeling the Nodes - Firesev
firesev age B. Modeling the Nodes - Firesev > AICtab(f.lin,f.sat,weights=T) dAIC df weight f.sat f.lin <0.001
B. Modeling the Nodes - Cover cover firesev >c.lin<-glm(cover~firesev,family=Gamma(link=log),…) >curve(exp(p.c[1]+p.c[2]*x),from=0,to=9,add=T,lwd=2)
B. Modeling the Nodes - Richness cover firesev dist >r.lin<-glm.nb(rich~distance+cover,data=dat) >r.q<-glm.nb(rich~distance+I(distance^2)+cover,…) > AICtab(r.lin,r.q,weights=T) dAIC df weight r.q r.lin
C. Testing the conditional independences Implied Conditional Independences: firesev ⏊ dist | (age) cover ⏊ dist | (firesev) cover ⏊ age | (firesev) rich ⏊ age | (cover,dist) rich ⏊ firesev | (cover,dist) Method for testing conditional indepedences: For each implied conditional independence statement: 1. Hypothesize that a link between the variables exists 2.Quantify the evidence that the link explains residual variation in the variable chosen as the response.
C. Testing the conditional independences
What we need: 1.List of all implied conditional independences 2.Residuals for all fitted nodes >source(‘glmsem.r') >fits=c("a1.q","f.sat","c.lin","r.q") >stuff<-get.stuff.glm(fits,dat) get.stuff.glm returns: 1.R^2 for each node ($R.sq) 2.Estimated Causal Effect*(over obs. range) ($est.causal.effects) 3.Graph implied condition independences ($miss.links) 4.Predicted values for each node ($predictions) 5.Residuals for each node ($residuals) 6.Matrix of links in the graph ($links) 7.Matrix of prediction equations ($pred.eqns)
C. Testing the conditional independences >nl.detect3(dat,stuff$residuals,stuff$miss.links) $p.vals distance-firesev distance-cover age-cover age-rich firesev-rich $fisher.c [1] $d.f [1] 10 $fisher.c.p.val [1]
D. Check Model - Residuals >pairs(stuff$residuals)
D. Check Model- Parameter Estimates >sapply(fits,function(x)summary(get(x))$coefficients) $a1.q Estimate Std. Error z value Pr(>|z|) (Intercept) e distance e I(distance^2) e $f.sat Estimate Std. Error t value Pr(>|t|) (Intercept) e-19 I(1/age) e-07 $c.lin Estimate Std. Error t value Pr(>|t|) (Intercept) e-01 firesev e-05 $r.q Estimate Std. Error z value Pr(>|z|) (Intercept) e e+00 distance e e-07 I(distance^2) e e-05 cover e e-03
D. Check Model- Print Resulting Graph #requires graphviz and {PNG} >glmsem.graph(stuff)
E. Run a Query (intervention) new.dat<-dat new.dat[,'age']<-2 dat.int<-calc.intervention.glm(fits,stuff$links,"age",new.dat)
Discussion Get glmsem.r and these slides and R code for exmpl at: