This file contains hidden or 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
# A species list, which ecologies often have, but may not know the family names, or if they do, | |
# they (meaning me) may spell the names wrong from time to time | |
> splist <- c("annona_cherimola", 'annona_muricata', "quercus_robur", | |
"shorea_robusta", "pandanus_patina", "oryza_sativa", "durio_zibethinus", | |
"rubus_ulmifolius", "asclepias_curassavica", "pistacia_lentiscus") | |
# Get the Taxonomic Serial Number for each species, which are unique (note that there could be many TSN's within a species | |
# for each subspecies for example. So you may want to query for you species using get_itis_xml in the demos on the github | |
# site and then make sure you get the TSN for the right subspecies or species | |
> tsns <- laply(splist, get_tsn, searchtype = "sciname", by_ = "name", |
This file contains hidden or 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
> berkey98 | |
trial pubyear npat PD AL var_PD cov_PD_AL var_AL | |
1 Pihlstrom1983 1983 14 0.47 -0.32 0.0075 0.0030 0.0077 | |
2 Lindhe1982 1982 15 0.20 -0.60 0.0057 0.0009 0.0008 | |
3 Knowles1979 1979 78 0.40 -0.12 0.0021 0.0007 0.0014 | |
4 Ramfjord1987 1987 89 0.26 -0.31 0.0029 0.0009 0.0015 | |
5 Becker1988 1988 16 0.56 -0.39 0.0148 0.0072 0.0304 | |
> model <- mvmeta(cbind(PD,AL),S=berkey98[6:8],data=berkey98,lab=list(mlab=trial)) |
This file contains hidden or 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
# Intro Tutorial to R | |
# Scott Chamberlain <[email protected]> | |
# w/ code edited from Nathan Kraft and Dan Bunker | |
########## HELP ########## | |
# Getting Help with R on listserves online, etc. | |
# Go here for correct way to make reproducible examples to submit to help lists: | |
# https://github.com/hadley/devtools/wiki/Reproducibility | |
# Code writing style: |
This file contains hidden or 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
ezLev=function(x,new_order){ | |
for(i in rev(new_order)){ | |
x=relevel(x,ref=i) | |
} | |
return(x) | |
} | |
ggcorplot = function(data,var_text_size,cor_text_limits){ | |
# normalize data | |
for(i in 1:length(data)){ |
This file contains hidden or 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
####################################################### | |
#### Created by Rolf Lohaus, EEB Dept., Rice University | |
#### | |
#### Part of the code modified and extended from | |
#### Robert I. Kabacoff's Quick-R website | |
#### (http://www.statmethods.net) | |
####################################################### | |
############### HIGH-LEVEL PLOTTING FUNCTIONS ############### |
This file contains hidden or 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
###################################### | |
## Function that organizes the data so that PGLMM can be fit | |
## Created by Matthew Helmus | |
###################################### | |
PGLMM.data<-function(modelflag=1,sim.dat=NULL,samp=NULL,tree=NULL,traits=NULL,env=NULL,Vcomp=NULL) | |
{ | |
if (!require(ape)) | |
{ | |
stop("The 'ape' package is required") |
This file contains hidden or 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
###################################### | |
## Function calls a PGLMM for logistic regression | |
## Created by Matthew Helmus | |
###################################### | |
PGLMM.fit<-function(dat=NULL,Y=NULL,X=NULL,VV=NULL,sp.init=0.5,maxit=25,exitcountermax=50) # [B,B0,s,S95int,LL,flag]=PGLMM_nosparse_funct(Y,X,VV,s) | |
{ | |
if (!require(corpcor)) | |
{ | |
stop("The 'corpcor' package is required") |
This file contains hidden or 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
###################################### | |
## Created by Matthew Helmus | |
###################################### | |
PGLMM.reml<-function(sp) | |
{ | |
#global tH tinvW tVV tX | |
sp<-abs(Re(sp)) |
This file contains hidden or 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
# library(plotrix) | |
# library(ape) | |
# PGLMM_model_simulations.m | |
# Simulates models used to test the PGLMM models | |
# 23 June 2010 MATLAB CODE | |
# 6 September 2011 R CODE TRANSLATION - HELMUS |
This file contains hidden or 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
# Example Code | |
# Load functions | |
source("/path/where/you/have/this/file/PGLMM.data.R") | |
source("/path/where/you/have/this/file/PGLMM.fit.R") | |
source("/path/where/you/have/this/file/PGLMM.reml.R") | |
source("/path/where/you/have/this/file/PGLMM.sim.R") | |
# Simulate a dataset for the example | |
modelflag <- 1 |