Skip to content

Commit

Permalink
Update vignette.Rmd
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Thorson committed Sep 12, 2024
1 parent 6fb7010 commit ac0718e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions vignettes/vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,34 @@ library(phylopath)

`dsem` is an R package for fitting dynamic structural equation models (DSEMs) with a simple user-interface and generic 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:

```{r, echo=TRUE, message=FALSE, fig.width=7, fig.height=7}
# 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) )
# Display output
m1 = rbind(
"lm" = summary(Lm)$coef[2,1:2],
"dsem" = summary(fit)[1,9:10]
)
knitr::kable( m1, digits=3)
```

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.
Expand Down

0 comments on commit ac0718e

Please sign in to comment.