diff --git a/articles/dynamic_factor_analysis.html b/articles/dynamic_factor_analysis.html index ed4ab03..171dc28 100644 --- a/articles/dynamic_factor_analysis.html +++ b/articles/dynamic_factor_analysis.html @@ -62,7 +62,7 @@

James Thorson

- Source: vignettes/dynamic_factor_analysis.Rmd + Source: vignettes/dynamic_factor_analysis.Rmd
dynamic_factor_analysis.Rmd
diff --git a/articles/vignette.html b/articles/vignette.html index 467889e..97f27b7 100644 --- a/articles/vignette.html +++ b/articles/vignette.html @@ -62,7 +62,7 @@

James Thorson

- Source: vignettes/vignette.Rmd + Source: vignettes/vignette.Rmd
vignette.Rmd
@@ -80,64 +80,12 @@

James specification of simultaneous and lagged effects in a non-recursive structure. We here highlight a few features in particular.

-

Comparison with linear models -

-

We first show that dsem is identical to a linear model. -To do so, we simulate data with a single response and single -predictor:

-
-# simulate normal distribution
-x = rnorm(100)
-y = 1 + 0.5 * x + rnorm(100)
-data = data.frame(x=x, y=y)
-
-# Fit as linear model
-Lm = lm( y ~ x, data=data )
-
-# Fit as DSEM
-fit = dsem( sem = "x -> y, 0, beta",
-            tsdata = ts(data),
-            control = dsem_control(quiet=TRUE) )
-#> 1 regions found.
-#> Using 1 threads
-#> 1 regions found.
-#> Using 1 threads
-
-# Display output
-m1 = rbind(
-  "lm" = summary(Lm)$coef[2,1:2],
-  "dsem" = summary(fit)[1,9:10]
-)
-knitr::kable( m1, digits=3)
- - - - - - - - - - - - - - - - - - -
EstimateStd_Error
lm0.4740.097
dsem0.4740.097
-

This shows that linear and dynamic structural equation models give -identical estimates of the single path coefficient.

-
-

Comparison with dynamic linear models

We first demonstrate that dsem gives identical results to dynlm for a well-known econometric model, the Klein-1 model.

-
+
 data(KleinI, package="AER")
 TS = ts(data.frame(KleinI, "time"=time(KleinI) - 1931))
 
@@ -170,6 +118,10 @@ 

Comparison with dynamic linear mo control = dsem_control( quiet = TRUE, newton_loops = 0) ) +#> 1 regions found. +#> Using 1 threads +#> 1 regions found. +#> Using 1 threads # Compile m1 = rbind( summary(fm_cons)$coef[-1,], @@ -201,13 +153,13 @@

Comparison with dynamic linear mo expand_limits(x = c(-0.2,1), y = c(-0.2,0) ) p1

-

-
+

+
 p2
-

-
+

+
 grid.arrange( arrangeGrob(p3, p4, nrow=2) )
-

+

Results show that both packages provide (almost) identical estimates and standard errors.

We can also compare results using the Laplace approximation against @@ -216,13 +168,13 @@

Comparison with dynamic linear mo variance parameters (presumably because those follow a chi-squared distribution with positive skewness), but otherwise the two produce similar estimates.

-
+
 library(tmbstan)
 
 # MCMC for both fixed and random effects
 mcmc = tmbstan( fit$obj, init="last.par.best" )
 summary_mcmc = summary(mcmc)
-
+
 # long-form data frame
 m1 = summary_mcmc$summary[1:17,c('mean','sd')]
 rownames(m1) = paste0( "b", seq_len(nrow(m1)) )
@@ -239,7 +191,7 @@ 

Comparison with dynamic linear mo geom_point( position=position_dodge(0.9) ) + geom_errorbar( aes(ymax=as.numeric(upper),ymin=as.numeric(lower)), width=0.25, position=position_dodge(0.9)) #

-

+

Comparison with vector autoregressive models @@ -259,7 +211,7 @@

Comparison with vector aut

Here, we compare fits using dsem with dynlm, as well as a vector autoregressive model package vars, and finally with MARSS.

-
+
 data(isle_royale)
 data = ts( log(isle_royale[,2:3]), start=1959)
 
@@ -377,7 +329,7 @@ 

Comparison with vector aut ggarrange( p1, p2, p3, labels = c("Time-series data", "Estimated effects", "Fitted path digram"), ncol = 1, nrow = 3)

-

+

Results again show that dsem can estimate parameters for a vector autoregressive model (VAM), and it exactly matches results from vars, using dynlm, or using @@ -388,7 +340,7 @@

Multi-causal ecosystem synthesis

We next replicate an analysis involving climate, forage fishes, stomach contents, and recruitment of a predatory fish.

-
+
 data(bering_sea)
 Z = ts( bering_sea )
 family = rep('fixed', ncol(bering_sea))
@@ -422,7 +374,7 @@ 

Multi-causal ecosystem synthesis control = dsem_control(use_REML=FALSE, quiet=TRUE) ) ParHat = fit$obj$env$parList() # summary( fit )

-
+
 # Timeseries plot
 oldpar <- par(no.readonly = TRUE)
 par( mfcol=c(3,3), mar=c(2,2,2,0), mgp=c(2,0.5,0), tck=-0.02 )
@@ -441,8 +393,8 @@ 

Multi-causal ecosystem synthesis y=c(tmp[,3],rev(tmp[,4])), col=rgb(0,0,1,0.2), border=NA ) } par(oldpar)

-

-
+

+
 #
 library(phylopath)
 library(ggplot2)
@@ -471,7 +423,7 @@ 

Multi-causal ecosystem synthesis# p2+ggtitle("Estimated p-values"), nrow=2), ncol=2 ) ) ggarrange(p1, p2, labels = c("Simultaneous effects", "Two-sided p-value"), ncol = 1, nrow = 2)

-

+

These results are further discussed in the paper describing dsem.

@@ -480,7 +432,7 @@

Site-replicated trophic cascadeFinally, we replicate an analysis involving a trophic cascade involving sea stars predators, sea urchin consumers, and kelp producers.

-
+
 data(sea_otter)
 Z = ts( sea_otter[,-1] )
 
@@ -634,7 +586,7 @@ 

Site-replicated trophic cascade p2 + scale_x_continuous(expand = c(0.3, 0)), labels = c("Simultaneous effects", "Two-sided p-value"), ncol = 1, nrow = 2)

-

+

Again, these results are further discussed in the paper describing dsem.

diff --git a/articles/vignette_files/figure-html/unnamed-chunk-10-1.png b/articles/vignette_files/figure-html/unnamed-chunk-10-1.png index 0a30248..a9cb2dc 100644 Binary files a/articles/vignette_files/figure-html/unnamed-chunk-10-1.png and b/articles/vignette_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/articles/vignette_files/figure-html/unnamed-chunk-11-1.png b/articles/vignette_files/figure-html/unnamed-chunk-11-1.png index a9cb2dc..bd5ea2c 100644 Binary files a/articles/vignette_files/figure-html/unnamed-chunk-11-1.png and b/articles/vignette_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/articles/vignette_files/figure-html/unnamed-chunk-7-1.png b/articles/vignette_files/figure-html/unnamed-chunk-7-1.png index 2c25d64..832a3a1 100644 Binary files a/articles/vignette_files/figure-html/unnamed-chunk-7-1.png and b/articles/vignette_files/figure-html/unnamed-chunk-7-1.png differ diff --git a/authors.html b/authors.html index 7666d9a..b6c303d 100644 --- a/authors.html +++ b/authors.html @@ -47,7 +47,7 @@

Authors

Citation

-

Source: inst/CITATION

+

Source: inst/CITATION

Thorson, J. T., Andrews, A. G., Essington, T., & Large, S. (2024). Dynamic structural equation models synthesize ecosystem dynamics constrained by ecological mechanisms. Methods in Ecology and Evolution.

@Article{,
diff --git a/index.html b/index.html
index f1acfdb..77d370e 100644
--- a/index.html
+++ b/index.html
@@ -83,6 +83,11 @@ 

Dynamic structural equation models

Please see package vignettes for more details regarding syntax and features.

+
+

Citation +

+

Thorson, J. T., Andrews, A. G., Essington, T., & Large, S. (2024). Dynamic structural equation models synthesize ecosystem dynamics constrained by ecological mechanisms. Methods in Ecology and Evolution 15(4): 744-755. https://doi.org/10.1111/2041-210X.14289

+