Skip to content

Commit

Permalink
help files and import fixes for overdispersion functions
Browse files Browse the repository at this point in the history
  • Loading branch information
colinpmillar committed Aug 1, 2016
1 parent 19ff627 commit e240238
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 49 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ importFrom(mgcv,gam)
importFrom(mgcv,smooth.construct)
importFrom(rstan,optimizing)
importFrom(stats,AIC)
importFrom(stats,aggregate)
importFrom(stats,as.formula)
importFrom(stats,binomial)
importFrom(stats,deviance)
importFrom(stats,drop.scope)
importFrom(stats,fitted)
importFrom(stats,formula)
importFrom(stats,model.matrix)
importFrom(stats,pchisq)
importFrom(stats,qlogis)
importFrom(stats,simulate)
importFrom(stats,update.formula)
importFrom(utils,capture.output)
86 changes: 37 additions & 49 deletions R/Overdispersion_function_annotated_complete.R
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
###########################################
#
# ESTIMATING OVERDISPERSION
#
###########################################

# Complete function for returning overdispersion estimates


# DEPENDENCIES
# ef
# dplyr


# NOTE - ensure column names in function call are in inverted
# commas


# REQUIRED FIELDS:
# data = dataframe containing EF data
# siteID = site name or unique ID
# visitID = a number identifying each unique visit
# count = count of fish (defaults to "count")
# pass = the EF pass number(defaults to "pass")
# pass12 = categorical variable with 2 levels where the 1st pass
# and subsequent passes are treated separately (defaults to "pass12")
# id = sample ID
# largemodel = the large model that captures most of the systematic
# variation in the data - this is specified before
# running the overdispersion function


#' Estimating overdispersion
#'
#' Complete function for returning overdispersion estimates
#'
#'
#' @param data dataframe containing EF data
#' @param siteID site name or unique ID
#' @param visitID a number identifying each unique visit
#' @param count count of fish (defaults to "count")
#' @param pass the EF pass number (defaults to "pass")
#' @param lifestage the lifestage (defaults to "lifestage")
#' @param pass12 categorical variable with 2 levels where the 1st pass
#' and subsequent passes are treated separately (defaults to "pass12")
#' @param id sample ID
#' @param largemodel the large model that captures most of the systematic
#' variation in the data - this is specified before
#' running the overdispersion function
#' @return a data.frame summarising overdispersion
#'
#' @note ensure column names in function call are in inverted commas
#'
#' @export
overdispersion <- function(data, siteID, visitID, count = "count",
pass = "pass", lifestage = "lifestage",
Expand Down Expand Up @@ -315,27 +305,25 @@ overdispersion <- function(data, siteID, visitID, count = "count",
}


#################################################################################################
#################################################################################################
#################################################################################################
#################################################################################################
#################################################################################################
#################################################################################################
#################################################################################################
#################################################################################################

####################
#
# ADJUSTED BIC FUNCTION
#
####################

# When calling the function, you need to specify the data source for
# the model so that the number of site visits can be determined.
# You also need to specify the output from the overdispersion model
# to get the measure
#' Adjusted BIC function
#'
#' Complete function for returning overdispersion estimates
#'
#'
#' @param model a fitted ef model
#' @param data the data used to fit the model
#' @param overdispersion.output output form the function \link{overdispersion}
#' @return the adjusted BIC
#'
#' @note When calling the function, you need to specify the data source for
#' the model so that the number of site visits can be determined.
#' You also need to specify the output from the overdispersion model
#' to get the measure
#'
#' @export
BICadj <- function(model, data, overdispersion.output){
BICadj <- function(model, data, overdispersion.output) {

# The adjusted BIC value is calculated in a similar way to BIC, however the
# loglikelihood of the model is divided by the measure of between sample
Expand Down
1 change: 1 addition & 0 deletions R/Package.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @importFrom utils capture.output
#' @importFrom stats simulate AIC fitted as.formula formula binomial deviance
#' @importFrom stats update.formula drop.scope model.matrix
#' @importFrom stats aggregate pchisq qlogis
#' @importFrom mgcv gam smooth.construct Predict.matrix
#' @importFrom rstan optimizing
#' @importFrom dplyr left_join
Expand Down
28 changes: 28 additions & 0 deletions man/BICadj.Rd

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

41 changes: 41 additions & 0 deletions man/overdispersion.Rd

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

0 comments on commit e240238

Please sign in to comment.