diff --git a/404.html b/404.html index 80671ba..fddf9e4 100644 --- a/404.html +++ b/404.html @@ -24,7 +24,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -53,7 +53,14 @@ - + + + + + + + + diff --git a/articles/comparison.html b/articles/comparison.html index c7cf947..de71fe1 100644 --- a/articles/comparison.html +++ b/articles/comparison.html @@ -26,7 +26,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -55,7 +55,14 @@ - + + + + + + + + @@ -72,7 +79,7 @@ James T. Thorson and Wouter van der Bijl - + Source: vignettes/comparison.Rmd comparison.Rmd @@ -159,7 +166,7 @@ Comparison with phylolmstart_time = Sys.time() plm_bm = phylolm::phylolm(y ~ 1 + x, data=Data, phy=tree, model="BM" ) Sys.time() - start_time -#> Time difference of 0.00622654 secs +#> Time difference of 0.00464797 secs knitr::kable(summary(plm_bm)$coefficients, digits=3) @@ -192,9 +199,9 @@ Comparison with phylolmpsem_bm = phylosem( sem = "x -> y, p", data = Data, tree = tree, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.1971586 secs +#> Time difference of 0.09037399 secs knitr::kable(summary(psem_bm)$coefficients, digits=3) @@ -254,16 +261,16 @@ Comparison with phylolmstart_time = Sys.time() plm_ou = phylolm::phylolm(y ~ 1 + x, data=Data, phy=tree, model="OUrandomRoot" ) Sys.time() - start_time -#> Time difference of 0.0199275 secs +#> Time difference of 0.008813143 secs start_time = Sys.time() psem_ou = phylosem( sem = "x -> y, p", data = Data, tree = tree, estimate_ou = TRUE, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.2294426 secs +#> Time difference of 0.1400571 secs knitr::kable(summary(psem_ou)$coefficients, digits=3) @@ -370,16 +377,16 @@ Comparison with phylolmstart_time = Sys.time() plm_lambda = phylolm::phylolm(y ~ 1 + x, data=Data, phy=tree, model="lambda" ) Sys.time() - start_time -#> Time difference of 0.04079676 secs +#> Time difference of 0.01395488 secs start_time = Sys.time() psem_lambda = phylosem( sem = "x -> y, p", data = Data, tree = tree, estimate_lambda = TRUE, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.1857631 secs +#> Time difference of 0.07518101 secs knitr::kable(summary(psem_lambda)$coefficients, digits=3) @@ -486,16 +493,16 @@ Comparison with phylolmstart_time = Sys.time() plm_kappa = phylolm::phylolm(y ~ 1 + x, data=Data, phy=tree, model="kappa", lower.bound = 0, upper.bound = 3 ) Sys.time() - start_time -#> Time difference of 0.01002622 secs +#> Time difference of 0.1530089 secs start_time = Sys.time() psem_kappa = phylosem( sem = "x -> y, p", data = Data, tree = tree, estimate_kappa = TRUE, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.1860392 secs +#> Time difference of 0.07159591 secs knitr::kable(summary(psem_kappa)$coefficients, digits=3) @@ -692,7 +699,7 @@ Poisson-distributed response= Data, family = c("fixed","poisson"), tree = tree, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) knitr::kable(summary(pgsem)$coefficients, digits=3) @@ -755,20 +762,20 @@ Poisson-distributed responselibrary(brms) Amat <- ape::vcv.phylo(tree) Data$tips <- rownames(Data) -mcmc <- brm( - y ~ 1 + x + (1 | gr(tips, cov = A)), +mcmc <- brm( + y ~ 1 + x + (1 | gr(tips, cov = A)), data = Data, data2 = list(A = Amat), family = 'poisson', cores = 4 ) -knitr::kable(fixef(mcmc), digits = 3) +knitr::kable(fixef(mcmc), digits = 3) # Plot them together library(ggplot2) pdat <- rbind.data.frame( coef(summary(pglm))[, 1:2], data.frame(Estimate = pglmm$B, StdErr = pglmm$B.se), - setNames(as.data.frame(fixef(mcmc))[1:2], c('Estimate', 'StdErr')), + setNames(as.data.frame(fixef(mcmc))[1:2], c('Estimate', 'StdErr')), setNames(summary(pgsem)$coefficients[2:3, 3:4], c('Estimate', 'StdErr')) ) pdat$Param <- rep(c('Intercept', 'Slope'), 4) @@ -846,7 +853,7 @@ Binomial regression= Data, family = c("fixed","binomial"), tree = tree, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) knitr::kable(summary(pgsem)$coefficients, digits=3) @@ -940,7 +947,7 @@ Compare with phylopath model = "BM", measurement_error = FALSE ) Sys.time() - start_time -#> Time difference of 0.01152086 secs +#> Time difference of 0.00779891 secs plot(result) @@ -956,9 +963,9 @@ Compare with phylopathpsem = phylosem( sem = model, data = rhino_scaled[,c("BM","NL","DD","RS","LS")], tree = rhino_tree, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.4174633 secs +#> Time difference of 0.1682889 secs plot( as_fitted_DAG(psem) ) @@ -1012,7 +1019,7 @@ Comparison with semstart_time = Sys.time() Sem <- sem(model, data=Data) Sys.time() - start_time -#> Time difference of 0.01753688 secs +#> Time difference of 0.01031017 secs # Specify star phylogeny tree_null = TreeTools::StarTree(n_obs) @@ -1024,9 +1031,9 @@ Comparison with sempsem = phylosem( data = Data, sem = equations, tree = tree_null, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.07997537 secs +#> Time difference of 0.02785897 secs We then compare estimated values for standardized coefficients @@ -1162,7 +1169,7 @@ Comparison with Rphylopars phylo_correlated = TRUE, pheno_correlated = FALSE) Sys.time() - start_time -#> Time difference of 0.1094489 secs +#> Time difference of 0.0825429 secs # Display estimates for missing values knitr::kable(cbind( "Estimate"=pars$anc_recon["t1",], "Var"=pars$anc_var["t1",] ), digits=3) @@ -1208,14 +1215,14 @@ Comparison with Rphylopars tree = tree, sem = "", covs = "BM, NL, DD, RS, LS", - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.6932356 secs +#> Time difference of 0.2777879 secs # Display estimates for missing values knitr::kable(cbind( - "Estimate"=as.list(psem$opt$SD,"Estimate")$x_vj[ match("t1",tree$tip.label), ], - "Var"=as.list(psem$opt$SD,"Std. Error")$x_vj[ match("t1",tree$tip.label), ]^2 + "Estimate"=as.list(psem$sdrep,"Estimate")$x_vj[ match("t1",tree$tip.label), ], + "Var"=as.list(psem$sdrep,"Std. Error")$x_vj[ match("t1",tree$tip.label), ]^2 ), digits=3) diff --git a/articles/comparison_files/figure-html/unnamed-chunk-5-1.png b/articles/comparison_files/figure-html/unnamed-chunk-5-1.png deleted file mode 100644 index f1a77fd..0000000 Binary files a/articles/comparison_files/figure-html/unnamed-chunk-5-1.png and /dev/null differ diff --git a/articles/comparison_files/figure-html/unnamed-chunk-6-1.png b/articles/comparison_files/figure-html/unnamed-chunk-6-1.png index a1fe9bb..2e2e97b 100644 Binary files a/articles/comparison_files/figure-html/unnamed-chunk-6-1.png and b/articles/comparison_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/articles/comparison_files/figure-html/unnamed-chunk-7-1.png b/articles/comparison_files/figure-html/unnamed-chunk-7-1.png deleted file mode 100644 index 11cd16a..0000000 Binary files a/articles/comparison_files/figure-html/unnamed-chunk-7-1.png and /dev/null differ diff --git a/articles/comparison_files/figure-html/unnamed-chunk-7-2.png b/articles/comparison_files/figure-html/unnamed-chunk-7-2.png deleted file mode 100644 index 11cd16a..0000000 Binary files a/articles/comparison_files/figure-html/unnamed-chunk-7-2.png and /dev/null differ diff --git a/articles/comparison_files/figure-html/unnamed-chunk-8-1.png b/articles/comparison_files/figure-html/unnamed-chunk-8-1.png index 11cd16a..73076aa 100644 Binary files a/articles/comparison_files/figure-html/unnamed-chunk-8-1.png and b/articles/comparison_files/figure-html/unnamed-chunk-8-1.png differ diff --git a/articles/comparison_files/figure-html/unnamed-chunk-8-2.png b/articles/comparison_files/figure-html/unnamed-chunk-8-2.png index 11cd16a..73076aa 100644 Binary files a/articles/comparison_files/figure-html/unnamed-chunk-8-2.png and b/articles/comparison_files/figure-html/unnamed-chunk-8-2.png differ diff --git a/articles/demonstration.html b/articles/demonstration.html index ce2bb82..c6bc20b 100644 --- a/articles/demonstration.html +++ b/articles/demonstration.html @@ -26,7 +26,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -55,7 +55,14 @@ - + + + + + + + + @@ -72,7 +79,7 @@ James T. Thorson - + Source: vignettes/demonstration.Rmd demonstration.Rmd @@ -117,15 +124,16 @@ Estimability for m estimate_lambda = TRUE, estimate_kappa = TRUE, tree = rhino_tree, - getJointPrecision = TRUE, - quiet = TRUE ) + control = phylosem_control( + getJointPrecision = TRUE, + quiet = TRUE) ) # -V = psem$opt$SD$cov.fixed +V = psem$sdrep$cov.fixed Rsub = cov2cor(V)[c('lnalpha','logitlambda','lnkappa'),c('lnalpha','logitlambda','lnkappa')] -knitr::kable(c("minimum_eigenvalue"=min(eigen(psem$opt$SD$jointPrecision)$values), - "maximum_eigenvalue"=max(eigen(psem$opt$SD$jointPrecision)$values)), digits=3) +knitr::kable(c("minimum_eigenvalue"=min(eigen(psem$sdrep$jointPrecision)$values), + "maximum_eigenvalue"=max(eigen(psem$sdrep$jointPrecision)$values)), digits=3) @@ -194,7 +202,7 @@ Estimability for m library(ggplot2) # Compile estimates and SEs -pdat = data.frame( "Estimate" = psem$opt$SD$par.fixed[c('lnalpha','logitlambda','lnkappa')], +pdat = data.frame( "Estimate" = psem$sdrep$par.fixed[c('lnalpha','logitlambda','lnkappa')], "StdErr" = sqrt(diag(V)[c('lnalpha','logitlambda','lnkappa')]) ) pdat = cbind( pdat, "Param" = rownames(pdat)) @@ -263,9 +271,10 @@ Scaling of runtime with inc psem_bm = phylosem( sem = "x -> y, p", data = Data, tree = tree, - quiet = TRUE, - newtonsteps = 0, - getsd = FALSE ) + control = phylosem_control( + quiet = TRUE, + newton_loops = 0, + getsd = FALSE) ) Time_rcz[rI,cI,"phylosem"] = Sys.time() - start_time }} diff --git a/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png b/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png index 4e82929..6de4306 100644 Binary files a/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png and b/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png differ diff --git a/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png b/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png index c55e1bd..e296735 100644 Binary files a/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png and b/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/articles/fisheries.html b/articles/fisheries.html index 71b310f..7e8ae79 100644 --- a/articles/fisheries.html +++ b/articles/fisheries.html @@ -26,7 +26,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -55,7 +55,14 @@ - + + + + + + + + @@ -72,7 +79,7 @@ James T. Thorson - + Source: vignettes/fisheries.Rmd fisheries.Rmd @@ -90,7 +97,7 @@ James T. Preparing the Then et al. mortality database To demonstrate the potential role for PCM in fisheries science, we -re-analyze a foundational dataset compiled by Then +re-analyze a foundational dataset compiled by Then et al.. We specifically download the file “Mlifehist_ver1.0.csv” and then include a copy as a data object in package phylosem to simplify the following demonstration. This demonstration then provides @@ -179,11 +186,11 @@ Fit estimate_ou = Grid[i,'OU'], estimate_lambda = Grid[i,'lambda'], estimate_kappa = Grid[i,'kappa'], - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) } # Extract AIC for each model and rank-order by parsimony -Grid$AIC = sapply( psem_grid, \(m) m$opt$AIC ) +Grid$AIC = sapply( psem_grid, \(m) AIC(m) ) Grid = Grid[order(Grid$AIC,decreasing=FALSE),] # Select model with lowest AIC @@ -440,7 +447,7 @@ Sensitivity to using taxonomic tree tree = tree, sem = sem_structure, estimate_ou = TRUE, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) # Plot path diagram my_fitted_DAG = as_fitted_DAG(psem_taxon) diff --git a/articles/fisheries_files/figure-html/unnamed-chunk-5-1.png b/articles/fisheries_files/figure-html/unnamed-chunk-5-1.png index e9936bb..c14530f 100644 Binary files a/articles/fisheries_files/figure-html/unnamed-chunk-5-1.png and b/articles/fisheries_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/articles/fisheries_files/figure-html/unnamed-chunk-6-1.png b/articles/fisheries_files/figure-html/unnamed-chunk-6-1.png index ff4e186..f578bf1 100644 Binary files a/articles/fisheries_files/figure-html/unnamed-chunk-6-1.png and b/articles/fisheries_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/articles/fisheries_files/figure-html/unnamed-chunk-7-1.png b/articles/fisheries_files/figure-html/unnamed-chunk-7-1.png index ccb77a6..6f2b214 100644 Binary files a/articles/fisheries_files/figure-html/unnamed-chunk-7-1.png and b/articles/fisheries_files/figure-html/unnamed-chunk-7-1.png differ diff --git a/articles/index.html b/articles/index.html index 36b7c6c..f9ec811 100644 --- a/articles/index.html +++ b/articles/index.html @@ -10,7 +10,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -36,7 +36,13 @@ - + + + + + + + diff --git a/articles/phylopath.html b/articles/phylopath.html index a5d9fb3..5027dcf 100644 --- a/articles/phylopath.html +++ b/articles/phylopath.html @@ -26,7 +26,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -55,7 +55,14 @@ - + + + + + + + + @@ -72,7 +79,7 @@ Wouter van der Bijl - + Source: vignettes/phylopath.Rmd phylopath.Rmd diff --git a/articles/phylopath_files/figure-html/unnamed-chunk-10-1.png b/articles/phylopath_files/figure-html/unnamed-chunk-10-1.png index 8d40e96..c57ba9d 100644 Binary files a/articles/phylopath_files/figure-html/unnamed-chunk-10-1.png and b/articles/phylopath_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/articles/phylopath_files/figure-html/unnamed-chunk-10-2.png b/articles/phylopath_files/figure-html/unnamed-chunk-10-2.png index 299e78a..c823481 100644 Binary files a/articles/phylopath_files/figure-html/unnamed-chunk-10-2.png and b/articles/phylopath_files/figure-html/unnamed-chunk-10-2.png differ diff --git a/articles/phylopath_files/figure-html/unnamed-chunk-9-1.png b/articles/phylopath_files/figure-html/unnamed-chunk-9-1.png index 0e5acd0..9c22c69 100644 Binary files a/articles/phylopath_files/figure-html/unnamed-chunk-9-1.png and b/articles/phylopath_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/articles/phylopath_files/figure-html/unnamed-chunk-9-2.png b/articles/phylopath_files/figure-html/unnamed-chunk-9-2.png index 0e5acd0..9c22c69 100644 Binary files a/articles/phylopath_files/figure-html/unnamed-chunk-9-2.png and b/articles/phylopath_files/figure-html/unnamed-chunk-9-2.png differ diff --git a/authors.html b/authors.html index 1994c9b..85fa80d 100644 --- a/authors.html +++ b/authors.html @@ -10,7 +10,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -36,7 +36,13 @@ - + + + + + + + @@ -61,7 +67,7 @@ Authors Citation - + Source: inst/CITATION Thorson, J. T., Maureaud, A. A., Frelat, R., Mérigot, B., Bigman, J. S., Friedman, S. T., Palomares, M. L. D., Pinsky, M. L., Price, S. A., & Wainwright, P. (2023). Identifying direct and indirect associations among traits by merging phylogenetic comparative methods and structural equation models. Methods in Ecology and Evolution, 14(5), 1259–1275. https://doi.org/10.1111/2041-210X.14076 @Article{, diff --git a/index.html b/index.html index 7df95e1..932cac1 100644 --- a/index.html +++ b/index.html @@ -38,7 +38,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -67,7 +67,14 @@ - + + + + + + + + @@ -104,13 +111,14 @@ Phylogenetic structural equatio Please see package vignettes for more details regarding syntax and features. - - +
vignettes/comparison.Rmd
comparison.Rmd
@@ -956,9 +963,9 @@ Compare with phylopathpsem = phylosem( sem = model, data = rhino_scaled[,c("BM","NL","DD","RS","LS")], tree = rhino_tree, - quiet = TRUE ) + control = phylosem_control(quiet = TRUE) ) Sys.time() - start_time -#> Time difference of 0.4174633 secs +#> Time difference of 0.1682889 secs plot( as_fitted_DAG(psem) )
We then compare estimated values for standardized coefficients
vignettes/demonstration.Rmd
demonstration.Rmd
library(ggplot2) # Compile estimates and SEs -pdat = data.frame( "Estimate" = psem$opt$SD$par.fixed[c('lnalpha','logitlambda','lnkappa')], +pdat = data.frame( "Estimate" = psem$sdrep$par.fixed[c('lnalpha','logitlambda','lnkappa')], "StdErr" = sqrt(diag(V)[c('lnalpha','logitlambda','lnkappa')]) ) pdat = cbind( pdat, "Param" = rownames(pdat)) @@ -263,9 +271,10 @@ Scaling of runtime with inc psem_bm = phylosem( sem = "x -> y, p", data = Data, tree = tree, - quiet = TRUE, - newtonsteps = 0, - getsd = FALSE ) + control = phylosem_control( + quiet = TRUE, + newton_loops = 0, + getsd = FALSE) ) Time_rcz[rI,cI,"phylosem"] = Sys.time() - start_time }} diff --git a/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png b/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png index 4e82929..6de4306 100644 Binary files a/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png and b/articles/demonstration_files/figure-html/unnamed-chunk-3-1.png differ diff --git a/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png b/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png index c55e1bd..e296735 100644 Binary files a/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png and b/articles/demonstration_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/articles/fisheries.html b/articles/fisheries.html index 71b310f..7e8ae79 100644 --- a/articles/fisheries.html +++ b/articles/fisheries.html @@ -26,7 +26,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -55,7 +55,14 @@ - + + + + + + + +
vignettes/fisheries.Rmd
fisheries.Rmd
To demonstrate the potential role for PCM in fisheries science, we -re-analyze a foundational dataset compiled by Then +re-analyze a foundational dataset compiled by Then et al.. We specifically download the file “Mlifehist_ver1.0.csv” and then include a copy as a data object in package phylosem to simplify the following demonstration. This demonstration then provides @@ -179,11 +186,11 @@
vignettes/phylopath.Rmd
phylopath.Rmd
Source: inst/CITATION
inst/CITATION
Thorson, J. T., Maureaud, A. A., Frelat, R., Mérigot, B., Bigman, J. S., Friedman, S. T., Palomares, M. L. D., Pinsky, M. L., Price, S. A., & Wainwright, P. (2023). Identifying direct and indirect associations among traits by merging phylogenetic comparative methods and structural equation models. Methods in Ecology and Evolution, 14(5), 1259–1275. https://doi.org/10.1111/2041-210X.14076
@Article{, diff --git a/index.html b/index.html index 7df95e1..932cac1 100644 --- a/index.html +++ b/index.html @@ -38,7 +38,7 @@ phylosem - 1.1.2 + 1.1.3 @@ -67,7 +67,14 @@ - + + + + + + + +
Please see package vignettes for more details regarding syntax and features.