Package of functions for the path analysis summer school course by Bill Shipley and companion to the book Cause and Correlation in Biology: A User's Guide to Path Analysis, Structural Equations and Causal Inference in R, 2nd edition.
First, make sure that you have the latest version of R on your computer, or at least a very recent version. To install the package from GitHub, type the following commands in your R or RStudio console:
# install package dependencies first install.packages("lavaan") install.packages("ggm") # install and load devtools to be able to install packages from GitHub with install_github install.packages("devtools") library(devtools) # install CauseAndCorrelation from Bill's GitHub install_github("BillShipley/CauseAndCorrelation") library(CauseAndCorrelation) ?Causal.Inference
If everything worked, the last command should have opened the help file for the
If things do not work
Read the error messages and make sure all packages dependencies are installed and loaded, especially package
ggm. If a message says that a package could not be loaded, try installing it manually by typing:
# manually installing a dependencies install.packages("packagename")
until all packages are installed. A current bug in
install_github on Windows prevents the installation of package dependencies of dependencies (
Although this should not be required, for certain packages with compiled code, Rtools and MiKTeX need to be installed on Windows to be able to build source packages. For Mac users, Xcode is required and can be installed through the apple store. Here is a more detailed list of prerequisites for building source packages for Windows, Mac and Linux.
In case something goes wrong with the package installation and the previous instructions do not work, here is the code for every function in the package. The code can be copied and pasted in the R console to get the definition of all functions. However, in this case, help files won't be available.