Git Product home page Git Product logo

lavaan.graph's Introduction

lavaan.graph

This takes a model statement of a lavaan model in R and renders it in dot code (part of graphviz), uses dot to compile it to a jpg and used the jpeg package to display it on the active R display device. It also leave a copy in the working directory.

Prerequisites

This function requires that graphviz (http://www.graphviz.org) is installed on your machine and has been added to the PATH

Description

creates and displays a directed graph from fitted lavaan object. Significant paths are show with bolded edges. Non-significant edges shown as dashed edges.

Usage

lavaan.graph(fit.sem,outfile="outfile",coeff=FALSE,stand=FALSE,show.corr=TRUE,sig.fig=2,out.format=NULL,dpi=300,dot.code=NULL,categorical=NULL)

fit.sem a lavaan fit object

outfile a string of the name for the output (the .dot file, the .jpg and other optional formats)

coeff an option to include parameter estimates on edges. Default is coeff=FALSE

stand an option to indicate if parameter estimates should be shown as standardized

show.corr an option to indicate if double-headed arrows should be shown. Default is show.corr=TRUE

sig.fig an integer to indicate the number of places after decimal to round estimates

out.format a string indicating optional addition format to have graph rendered. options include('pdf','png','tiff'...see http://www.graphviz.org/doc/info/output.html for full list.

dpi dpi of the jpg output

dot.code optional lines of dot code to be added to top of output dot file

categorical optional list of categorical variables and their levels in form list(c1=c('l1','l2',...),c2=c('l3','l4'))

Value

a .dot file containing the description of the lavaan model in the dot language and a rendered jpg of the model

Examples

#simulate data x<-rnorm(500,0,3)
w<-2x + rnorm(500,0,2)
z<-1
w + rnorm(500,0,3)
y<-2z + 4w + rnorm(500,0,2)

#write lavaan model mod1<-'w~x
z~w
y~z+w'

#fit model

fit.mod1<-sem(mod1,data=data.frame(x,w,z,y))

#show graph lavaan.graph(fit.mod1)

Authors

  • Donald R. Schoolmaster Jr - Initial work

lavaan.graph's People

Contributors

dschoolmaster avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.