Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding Kelp Forest example

  • Loading branch information...
commit 893530ab73fe73f8b29c6bfac802edd142ca7fa4 1 parent 63118a3
jebyrnes authored
Showing with 56 additions and 0 deletions.
  1. +55 −0 arkema_et_al_2009.r
  2. +1 −0  arkema_et_al_2009_data.csv
55 arkema_et_al_2009.r
View
@@ -0,0 +1,55 @@
+###########
+#
+# Analysis of direct and indirect effects of giant kelp on the dynamics of competition between
+# sessile algae and invertebrates. from Arkema et al 2009 Ecology http://dx.doi.org/10.1890/08-1213.1
+#
+# This was a fun one, and part of one of the first things I helped out with as a postdoc at the
+# Santa Barbara Coastal LTER http://sbc.lternet.edu (all data publically available there).
+# This data, however, is a subset for non-urhcin barren transects.
+#
+# Note, slight differences in parametere estiamtes and standard errors are due
+# to differences between lavaan and the sem package.
+#
+# This work was funded by a grant from the National Science Foundation
+# Long Term Ecological Research Site program.
+#
+# last tested: 5/1/11
+# last lavaan version tested: 0.4-8
+#
+# byrnes@nceas.ucsb.edu
+###########
+
+library(lavaan)
+
+#load data
+arkData <- read.csv("./arkema_et_al_2009_data.csv")
+
+
+#get residuals from data to accound for effects of site
+arkData<-within(arkData, {
+ percent.algae <- lm(percent.algae ~ site, data=arkData)$residuals
+ percent.inverts <- lm(percent.inverts ~ site, data=arkData)$residuals
+ transect.algae <- lm(transect.algae ~ site, data=arkData)$residuals
+})
+
+##
+#Simple model where % cover of algae was affected by giant kelp and midcanopy kelps
+#while inverts were affected by giant kelp, midcanopy kelps, and other algae
+#i.e., giant kelp reduces algal cover, thus indirectly increasing invert cover
+##
+arkModel<-'
+ percent.algae ~ frond.density + transect.algae + percent.holdfasts
+ percent.inverts ~ frond.density + transect.algae + percent.holdfasts + percent.algae
+ transect.algae ~ frond.density
+ '
+
+#Note that this model was fit with Fml, but, due to multivariate non-normality
+#we scaled the test of fit and the standard errors
+arkFit <- sem(arkModel, data=arkData, estimator="MLM")
+summary(arkFit)
+
+#standardized coefficients are in Fig. 5 of the model
+standardizedSolution(arkFit)
+
+#variation explained
+inspect(arkFit, "r2")
1  arkema_et_al_2009_data.csv
View
@@ -0,0 +1 @@
+site,transect,year,frond density,percent holdfasts,transect algae,percent algae,percent inverts CARP,2,2002,0,1.26582279,0.3125,66.66666667,23.07692308 CARP,2,2003,0.05,0,3.3625,50.64935065,44.15584416 CARP,2,2004,4.975,5,2.45,43.42105263,36.84210526 CARP,2,2005,10.125,12.5,0,65.71428571,25.71428571 CARP,2,2006,13.3,13.69863014,0.725,14.28571429,50 CARP,2,2007,7.425,10,5.7,47.22222222,18.05555556 CARP,3,2003,2.9,0,0.2625,46.25,43.75 CARP,3,2004,9.7375,8.86075949,0.1375,6.944444444,50 CARP,3,2005,3.9125,2.5,0.5375,23.07692308,35.8974359 CARP,3,2006,0.025,1.25,0.2125,13.92405063,39.24050633 CARP,3,2007,0,0,0.0875,48,20 CARP,7,2002,0.15,0,0.0375,52.23880597,31.34328358 CARP,7,2003,0.6,2.5974026,0,38.66666667,45.33333333 CARP,7,2004,6.6125,6.25,1.6125,60,34.66666667 CARP,7,2005,12.2125,12.5,2.5125,1.428571429,64.28571429 CARP,7,2006,0.025,2.739726027,0.4125,32.3943662,38.02816901 CARP,7,2007,6.975,5.084745763,0.3875,19.64285714,51.78571429 MOHK,1,2001,12.8,8.82352941,0.0625,33.87096774,59.67741935 MOHK,1,2002,3.9375,1.26582279,0.8375,25.64102564,53.84615385 MOHK,1,2003,10.125,3.8961039,2.6375,16.21621622,83.78378378 MOHK,1,2004,12.45,5,2.3625,43.42105263,47.36842105 MOHK,1,2005,0.5,0,3.275,26.38888889,72.22222222 MOHK,1,2006,6.225,10.66666667,4.1375,67.1641791,28.35820896 MOHK,1,2007,6.5,7.792207792,6.4,7.042253521,66.1971831 MOHK,2,2001,7.525,6.94444444,0.05,58.20895522,34.32835821 MOHK,2,2002,18.2125,9.67741936,3.275,30.35714286,48.21428571 MOHK,2,2003,19.425,16.8831169,0.8,32.8125,53.125 MOHK,2,2004,4.8,9.21052632,1.2375,63.76811594,36.23188406 MOHK,2,2005,4.7,8,3.6,17.39130435,81.15942029 MOHK,2,2006,5.1625,6.493506494,5.175,75,19.44444444 MOHK,2,2007,15.525,11.68831169,4.7375,13.23529412,63.23529412 NAPL,1,2002,0.6,0,0,25,59.72222222 NAPL,1,2003,8.925,8.86075949,0.0875,2.777777778,95.83333333 NAPL,1,2004,8.65,5.06329114,0.1625,25.33333333,72 NAPL,1,2005,12.05,14.4736842,0.1,12.30769231,81.53846154 NAPL,1,2006,5.6375,5,6.5875,35.52631579,56.57894737 NAPL,1,2007,9.7625,5,8.4875,14.47368421,61.84210526 NAPL,2,2002,0.8625,1.42857143,0.0875,52.17391304,31.88405797 NAPL,2,2003,13.125,10,0.2875,6.944444444,81.94444444 NAPL,2,2004,9.1625,8.75,0.175,27.39726027,68.49315068 NAPL,2,2005,7.4375,5.06329114,0.25,4,86.66666667 NAPL,2,2006,10.85,3.75,5.1875,20.77922078,67.53246753 NAPL,2,2007,7.3875,11.25,6.4375,8.450704225,73.23943662 NAPL,5,2001,0.025,0,0,32.43243243,22.97297297 NAPL,5,2002,0.675,0,0,19.48051948,64.93506494 NAPL,5,2003,11.875,10.2564103,0.0625,7.142857143,78.57142857 NAPL,5,2004,1.6375,7.14285714,1.05,13.84615385,80 NAPL,5,2005,5.2,4.28571429,2.325,14.92537313,70.14925373 NAPL,5,2006,0.3,0,5.0875,21.91780822,42.46575342 NAPL,5,2007,3.4375,0,8.3625,21.33333333,40 NAPL,6,2002,0,0,7.7875,17.33333333,52 NAPL,6,2003,3.3625,2.56410256,1.375,30.26315789,51.31578947 NAPL,6,2004,3.1625,9.09090909,1.7875,25.71428571,65.71428571 NAPL,6,2005,3.825,2.81690141,4.35,21.73913043,63.76811594 NAPL,6,2006,0.25,1.428571429,6.0625,20.28985507,62.31884058 NAPL,6,2007,1.8,0,7.7625,14.1025641,58.97435897 NAPL,7,2002,0.8625,0,0.075,20.77922078,67.53246753 NAPL,7,2003,6.8625,5.06329114,0.6625,0,90.66666667 NAPL,7,2004,9.3,2.56410256,1.0125,27.63157895,61.84210526 NAPL,7,2005,8.475,10.2564103,2.2125,11.42857143,75.71428571 NAPL,7,2006,2.025,0,4.925,27.84810127,40.50632911 NAPL,7,2007,3.7,3.75,6.5875,19.48051948,64.93506494 NAPL,8,2001,0,0,0.15,19.48051948,68.83116883 NAPL,8,2002,0.1,0,0.2375,30.88235294,58.82352941 NAPL,8,2003,3.3625,1.26582279,1.4625,19.23076923,75.64102564 NAPL,8,2004,3.7,6.25,2.5875,16,72 NAPL,8,2005,4.2875,5.2631579,4.05,20.83333333,72.22222222 NAPL,8,2006,0.1625,0,6.35,27.5,63.75 NAPL,8,2007,1.6625,1.25,6.25,27.84810127,65.82278481
Please sign in to comment.
Something went wrong with that request. Please try again.