r - CFA nice path plots -
when efa package psych can generate nice path plots correlations , loadings , such this:
using fa.diagram
function following code:
library(psych) covariances <- ability.cov$cov correlations <- cov2cor(covariances) fa.promax <- fa(correlations, nfactors=2, rotate="promax", fm="pa") fa.diagram(fa.promax, simple=false)
i tend use cfa more efa , able plot model correlations in same way. use sem package. have tried pathdiagram
function produces code can paste gvedit graphviz. , correlations , between factor correlations aren't there. additionally don't cutting , pasting program (though file sem pathdiagram reads: "to obtain graphics output directly, dot program must on system search path."; don't know put in path make happen , if have correlations anyway?)
i'd able make path diagram similar fa.diagram psych efa. i'd able in r , not cut , paste. don't care package use think people agree simpler better , if can done within r give great freedom of choice of graphics device.
here sample code cfa model work with:
dat3 <- read.table(url("http://dl.dropbox.com/u/61803503/proj_2b.dat"), header=t, strip.white = t, as.is=false, na.strings= c("999", "na", " ")) nhsda.cov <- cov(dat3) ete.mod <- specifymodel() f1 -> item3, lam1, na f1 -> item5, lam2, na f1 -> item9, lam3, na f1 -> item10, lam4, na f2 -> item4, lam5, na f2 -> item13, lam6, na f2 -> item14, lam7, na f2 -> item15, lam8, na f3 -> item1, lam9, na f3 -> item6, lam10, na f3 -> item7, lam11, na f3 -> item11, lam12, na f3 -> item12, lam13, na f4 -> item2, lam14, na f4 -> item8, lam15, na f4 -> item16, lam16, na f4 -> item17, lam17, na item1 <-> item1, e1, na item2 <-> item2, e2, na item3 <-> item3, e3, na item4 <-> item4, e4, na item5 <-> item5, e5, na item6 <-> item6, e6, na item7 <-> item7, e7, na item8 <-> item8, e8, na item9 <-> item9, e9, na item10 <-> item10, e10, na item11 <-> item11, e11, na item12 <-> item12, e12, na item13 <-> item13, e13, na item14 <-> item14, e14, na item15 <-> item15, e15, na item16 <-> item16, e16, na item17 <-> item17, e17, na f1 <-> f1, na, 1 f2 <-> f2, na, 1 f3 <-> f3, na, 1 f4 <-> f4, na, 1 f2 <-> f1, rf1f2 #1 f3 <-> f1, rf1f3 #2 f4 <-> f1, rf1f4 #3 f3 <-> f2, rf2f3 #4 f4 <-> f2, rf2f4 #5 f4 <-> f3, rf3f4 #6 ete.sem <- sem(ete.mod, nhsda.cov, nrow(dat3)) (ete.sum <- summary(ete.sem)) pathdiagram(ete.sem) #the attempt far
running r 2.14.2 on win 7
try this:
pathdiagram( model=ete.sem , file="pathdiagram" , max.rank=paste("item", 1:17, sep="") , ignore.double=false , edge.labels="values" , size=c(8, 8) , node.font=c("helvetica", 10) , edge.font=c("helvetica", 10) , rank.direction="lr" , digits=3 , standardize=true , graphics.fmt="pdf" )
this generate pathdiagram.pdf
in working directory. don't know anyway display graph in r.
Comments
Post a Comment