Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Thorson-NOAA committed Aug 16, 2023
1 parent a09cc04 commit 19ecb5d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: phylosem
Type: Package
Title: Phyloenetic structural equation model
Title: Phylogenetic Structural Equation Model
Version: 1.0.0
Date: 2023-08-15
Authors@R:
Expand Down
2 changes: 1 addition & 1 deletion R/fit_tmb.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#' @return the standard output from \code{\link[stats]{nlminb}}, except with additional diagnostics and timing info,
#' and a new slot containing the output from \code{\link[TMB]{sdreport}}
#'
#' @references For more details see \url{https://doi.org/10.1016/j.fishres.2015.11.016}
#' @references For more details see \doi{10.1016/j.fishres.2015.11.016}
#' @export
fit_tmb <-
function( obj,
Expand Down
17 changes: 9 additions & 8 deletions R/phylosem.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#' @param estimate_ou Boolean indicating whether to estimate an autoregressive (Ornstein-Uhlenbeck)
#' process using additional parameter \code{lnalpha},
#' corresponding to the \code{model="OUrandomRoot"} parameterization from \pkg{phylolm}
#' as listed in \url{https://doi.org/10.1093/sysbio/syu005}
#' as listed in \doi{10.1093/sysbio/syu005}
#' @param estimate_lambda Boolean indicating whether to estimate additional branch lengths for
#' phylogenetic tips (a.k.a. the Pagel-lambda term) using additional parameter \code{logitlambda}
#' @param estimate_kappa Boolean indicating whether to estimate a nonlinear scaling of branch
Expand Down Expand Up @@ -337,15 +337,16 @@ print.phylosem <- function(x, ...)
#' Extract path coefficients.
#'
#' @title Extract path coefficients
#' @param x Output from \code{\link{phylosem}}
#' @param object Output from \code{\link{phylosem}}
#' @param standardized Whether to standardize regression coefficients
#' @param ... Not used
#' @return NULL
#' @method coef phylosem
#' @export
coef.phylosem = function( x, standardized=FALSE ){
beta_z = x$opt$par[names(x$opt$par)=="beta_z"]
RAM = x$obj$env$data$RAM
if(nrow(RAM) != nrow(x$SEM_model)) stop("Check assumptions")
coef.phylosem = function( object, standardized=FALSE, ... ){
beta_z = object$opt$par[names(object$opt$par)=="beta_z"]
RAM = object$obj$env$data$RAM
if(nrow(RAM) != nrow(object$SEM_model)) stop("Check assumptions")
for( i in which(RAM[,1]==1) ){
if( standardized==TRUE ){
beta_z[i] = beta_z[i] * abs(beta_z[which( RAM[,'from']==RAM[i,'from'] & RAM[,'to']==RAM[i,'from'] )])
Expand All @@ -359,8 +360,8 @@ coef.phylosem = function( x, standardized=FALSE ){
}
}
SEM_params = beta_z[ifelse(RAM[,4]==0, NA, RAM[,4])]
SEM_params = ifelse( is.na(SEM_params), as.numeric(x$SEM_model[,3]), SEM_params )
return( data.frame(Path=x$SEM_model[,1], Parameter=x$SEM_model[,2], Estimate=SEM_params ) )
SEM_params = ifelse( is.na(SEM_params), as.numeric(object$SEM_model[,3]), SEM_params )
return( data.frame(Path=object$SEM_model[,1], Parameter=object$SEM_model[,2], Estimate=SEM_params ) )
}

#' Calculate AIC
Expand Down
6 changes: 4 additions & 2 deletions man/coef.phylosem.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/compare_phylosem.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fit_tmb.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/phylosem.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 19ecb5d

Please sign in to comment.