thej022214 / OUwie

Estimates and compares rate differences of continuous character evolution under Brownian motion and a new set of Ornstein-Uhlenbeck (OU) models that allow the strength of selection and drift to vary across selective regimes.
8 stars 3 forks source link

object 'theta' not found when diagn=TRUE in OUwie #11

Closed mpnelsen closed 3 years ago

mpnelsen commented 3 years ago

Hey OUwie Team,

I've been switching over to using OUwie 2+ and am running into some problems with the OUwie function when fitting various models (BMS illustrated below) and using the diagn=TRUE argument. It throws an error (object 'theta' not found") late in the process. Example w/ diagn=TRUE and diagn=FALSE below. Would you happen to have any ideas on what is happening? Thx for your help!

-Matt.

require(OUwie) Loading required package: OUwie Loading required package: ape Loading required package: corpcor Loading required package: nloptr Loading required package: geiger Loading required package: RColorBrewer sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-conda-linux-gnu (64-bit) Running under: Ubuntu 18.04.4 LTS

Matrix products: default BLAS/LAPACK: /home/.../anaconda3/envs/R4.0.3/lib/libopenblasp-r0.3.12.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] OUwie_2.5 RColorBrewer_1.1-2 geiger_2.0.7 nloptr_1.2.2.2 [5] corpcor_1.6.9 ape_5.4-1

loaded via a namespace (and not attached): [1] Rcpp_1.0.5 compiler_4.0.3 tools_4.0.3 [4] lhs_1.1.1 phytools_0.7-70 bitops_1.0-6 [7] digest_0.6.27 jsonlite_1.7.1 nlme_3.1-150 [10] lattice_0.20-41 pkgconfig_2.0.3 png_0.1-7 [13] Matrix_1.2-18 fastmatch_1.1-0 igraph_1.2.6 [16] parallel_4.0.3 phylolm_2.6.2 mvtnorm_1.1-1 [19] expm_0.999-5 interp_1.0-33 coda_0.19-4 [22] globals_0.13.1 gtools_3.8.2 maps_3.3.0 [25] combinat_0.0-8 grid_4.0.3 scatterplot3d_0.3-41 [28] deSolve_1.28 paleotree_3.3.25 listenv_0.8.0 [31] plotrix_3.7-8 parallelly_1.21.0 future.apply_1.6.0 [34] phangorn_2.5.5 deldir_0.2-3 magrittr_2.0.1 [37] codetools_0.2-18 MASS_7.3-53 mnormt_2.0.2 [40] future_1.20.1 numDeriv_2016.8-1.1 quadprog_1.5-8 [43] subplex_1.6 RCurl_1.98-1.2 tmvnsim_1.0-2 [46] clusterGeneration_1.3.5

data(tworegime) fit<-OUwie(tree,trait,model="BMS",simmap.tree=FALSE,root.station=FALSE,get.root.theta=FALSE,check.identify=TRUE,algorithm="three.point",diagn=TRUE) Warning: The supplied regime painting may be unidentifiable for the regime painting. All regimes form connected subtrees. Initializing... Finished. Begin thorough search... Finished. Summarizing results. Error in OUwie(tree, trait, model = "BMS", simmap.tree = FALSE, root.station = FALSE, : object 'theta' not found traceback() 1: OUwie(tree, trait, model = "BMS", simmap.tree = FALSE, root.station = FALSE, get.root.theta = FALSE, check.identify = TRUE, algorithm = "three.point", diagn = TRUE) fit<-OUwie(tree,trait,model="BMS",simmap.tree=FALSE,root.station=FALSE,get.root.theta=FALSE,check.identify=TRUE,algorithm="three.point",diagn=FALSE) Warning: The supplied regime painting may be unidentifiable for the regime painting. All regimes form connected subtrees. Initializing... Finished. Begin thorough search... Finished. Summarizing results.

khaosn commented 3 years ago

Having similar problem when passing diagn=TRUE to OUwie when model is set to either 'BM1' or 'BMS' (OU models work fine). This throws an error ('Error in rbind(rates, weights) : number of columns of matrices must match (see arg 2)') Any idea what is going on? Thanks!

OUmod1<-OUwie(phy=stree1[[1]],data=tab,model='BM1',mserr='known',simmap.tree=TRUE,algorithm='invert', root.station=FALSE,quiet=TRUE,warn=FALSE,diagn=TRUE) Error in rbind(rates, weights) : number of columns of matrices must match (see arg 2)

OUmod2<-OUwie(phy=stree1[[1]],data=tab,model='BMS',mserr='known',simmap.tree=TRUE,algorithm='invert', root.station=FALSE,quiet=TRUE,warn=FALSE,diagn=TRUE) Error in rbind(rates, weights) : number of columns of matrices must match (see arg 2)

OUmod3<-OUwie(phy=stree1[[1]],data=tab,model='OU1',mserr='known',simmap.tree=TRUE,algorithm='invert', root.station=FALSE,quiet=TRUE,warn=FALSE,diagn=TRUE)

jboyko commented 3 years ago

This looks to be fixed in the most recent github version (waiting on some final bug testing before pushing to CRAN). I'd recommend trying to install the github version: library(devtools) install_github("thej022214/OUwie")

Additionally, it is not recommended to set diagn=TRUE. For an estimate of precision bootstrapping is a better method. (see details of the OUwie function).

khaosn commented 3 years ago

@jboyko, thank you that is very helpful. I set diagn=T to be able to inspect the eigenvalues of the decomposition of the Hessian (OUwie output doesn't include them otherwise). I found nothing in the details of the OUwie function that advised against this. Will look into the bootstrapped OUwie.