-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b9bcc4
commit 8818b8c
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
|
||
name: R-CMD-check | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
R_KEEP_PKG_SOURCE: yes | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::rcmdcheck | ||
needs: check | ||
|
||
- uses: r-lib/actions/check-r-package@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
|
||
library(testthat) | ||
library(dsem) | ||
|
||
# Run tests | ||
testthat::test_check("dsem") | ||
|
||
# Run from local directory | ||
# testthat::test_dir( "C:/Users/James.Thorson/Desktop/Git/dsem/tests/testthat/", reporter="check" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
|
||
context("Testing cross platform and R version compatibility") | ||
|
||
# Eastern Bering Sea pollcok | ||
test_that("dsem example is working ", { | ||
#skip_on_ci() | ||
sem = " | ||
Profits -> Consumption, 0, a2 | ||
Profits -> Consumption, -1, a3 | ||
Priv_wage -> Consumption, 0, a4 | ||
Gov_wage -> Consumption, 0, a4 | ||
Consumption <-> Consumption, 0, v1 | ||
Consumption -> Consumption, -1, ar1 | ||
Consumption -> Consumption, -2, ar2 | ||
Profits -> Investment, 0, b2 | ||
Profits -> Investment, -1, b3 | ||
Capital_stock -> Investment, -1, b4 | ||
Investment <-> Investment, 0, v2 | ||
neg_Gov_wage <-> neg_Gov_wage, 0, v3 | ||
GNP -> Priv_wage, 0, c2 | ||
Taxes -> Priv_wage, 0, c2 | ||
neg_Gov_wage -> Priv_wage, 0, c2 | ||
GNP -> Priv_wage, -1, c3 | ||
Taxes -> Priv_wage, -1, c3 | ||
neg_Gov_wage -> Priv_wage, -1, c3 | ||
Time -> Priv_wage, 0, c4 | ||
Priv_wage <-> Priv_wage, 0, v4 | ||
GNP <-> GNP, 0, v5 | ||
Profits <-> Profits, 0, v6 | ||
Capital_stock <-> Capital_stock, 0, v7 | ||
Taxes <-> Taxes, 0, v8 | ||
Time <-> Time, 0, v9 | ||
Gov_wage <-> Gov_wage, 0, v10 | ||
Gov_expense <-> Gov_expense, 0, v11 | ||
" | ||
|
||
# Load data | ||
data(KleinI, package="AER") | ||
Data = as.data.frame(KleinI) | ||
Data = cbind( Data, "time" = seq(1,22)-11 ) | ||
colnames(Data) = sapply( colnames(Data), FUN=switch, | ||
"consumption"="Consumption", "invest"="Investment", | ||
"cprofits"="Profits", "capital"="Capital_stock", "gwage"="Gov_wage", | ||
"pwage"="Priv_wage", "gexpenditure"="Gov_expense", "taxes"="Taxes", | ||
"time"="Time", "gnp"="GNP") | ||
Z = ts( cbind(Data, "neg_Gov_wage"=-1*Data[,'Gov_wage']) ) | ||
|
||
# Fit model | ||
fit = dsem( sem=sem, tsdata=Z ) | ||
# Check objective function | ||
expect_equal( as.numeric(fit$opt$obj), 587.4755, tolerance=1e-2 ) | ||
|
||
# Convert and plot using phylopath | ||
as_fitted_DAG(fit) | ||
}) | ||
|