Package dalmatian. January 29, 2018

Similar documents
Package datasets.load

Package bsam. July 1, 2017

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package ECctmc. May 1, 2018

Package svalues. July 15, 2018

Package mfa. R topics documented: July 11, 2018

Package bisect. April 16, 2018

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package gppm. July 5, 2018

Package ggmcmc. August 29, 2016

Package GFD. January 4, 2018

Package lucid. August 24, 2018

Package weco. May 4, 2018

Package fastdummies. January 8, 2018

Package calpassapi. August 25, 2018

Package tuts. June 12, 2018

Package OLScurve. August 29, 2016

Package reval. May 26, 2015

Package lcc. November 16, 2018

Package CausalImpact

Package quickreg. R topics documented:

Package vinereg. August 10, 2018

Package PCADSC. April 19, 2017

Package QCAtools. January 3, 2017

Package canvasxpress

Package tidylpa. March 28, 2018

Package dgo. July 17, 2018

Package kirby21.base

Package cosinor. February 19, 2015

Package gtrendsr. October 19, 2017

Package fitbitscraper

Package catenary. May 4, 2018

Package robotstxt. November 12, 2017

rjags Introduction Parameters: How to determine the parameters of a statistical model

Package WordR. September 7, 2017

Package barcoder. October 26, 2018

Package modmarg. R topics documented:

Package docxtools. July 6, 2018

Package RNAseqNet. May 16, 2017

Package GetITRData. October 22, 2017

Package editdata. October 7, 2017

Package rsurfer. October 30, 2017

Package gtrendsr. August 4, 2018

Package simr. April 30, 2018

Package validara. October 19, 2017

Package preprosim. July 26, 2016

Package ClusterBootstrap

Package queuecomputer

Package rfsa. R topics documented: January 10, Type Package

Package SEMrushR. November 3, 2018

Package bayesdp. July 10, 2018

Package colf. October 9, 2017

Package shinyfeedback

Package rjags. R topics documented: October 19, 2018

Package jagsui. December 12, 2017

Package smapr. October 20, 2017

Package embed. November 19, 2018

Package TrafficBDE. March 1, 2018

Package effectr. January 17, 2018

Package gridgraphics

Package BiDimRegression

Package geneslope. October 26, 2016

Package qualmap. R topics documented: September 12, Type Package

Package ggseas. June 12, 2018

Package internetarchive

Package palmtree. January 16, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package TANDEM. R topics documented: June 15, Type Package

Package ASICS. January 23, 2018

Package messaging. May 27, 2018

Package jpmesh. December 4, 2017

Package ezsummary. August 29, 2016

Package profvis. R topics documented:

Package interplot. R topics documented: June 30, 2018

Package benchmarkme. R topics documented: February 26, Type Package Title Crowd Sourced System Benchmarks Version 0.2.

Package postgistools

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package pcr. November 20, 2017

Package bife. May 7, 2017

Package reghelper. April 8, 2017

ST440/540: Applied Bayesian Analysis. (5) Multi-parameter models - Initial values and convergence diagn

Package splithalf. March 17, 2018

Package citools. October 20, 2018

Package fastqcr. April 11, 2017

Package epitab. July 4, 2018

Package breakdown. June 14, 2018

Package RWildbook. April 6, 2018

Package rubias. February 2, 2019

Package frequencyconnectedness

Package rzeit2. January 7, 2019

Package climber. R topics documented:

Package confidence. July 2, 2017

Package caretensemble

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package strat. November 23, 2016

Package opencage. January 16, 2018

Package PDN. November 4, 2017

Package IATScore. January 10, 2018

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package forecasthybrid

Transcription:

Package dalmatian January 29, 2018 Title Automating the Fitting of Double Linear Mixed Models in 'JAGS' Version 0.3.0 Date 2018-01-19 Automates fitting of double GLM in 'JAGS'. Includes automatic generation of 'JAGS' scripts, running 'JAGS' via 'rjags', and summarizing the resulting output. Depends R (>= 3.0.0) License GPL-2 LazyData true VignetteBuilder knitr Imports rjags, coda, gdata, ggmcmc, dglm Suggests knitr, ggplot2, dplyr RoxygenNote 6.0.1 NeedsCompilation no Author Simon Bonner [aut, cre], Hanna Kim [aut] Maintainer Simon Bonner <sbonner6@uwo.ca> Repository CRAN Date/Publication 2018-01-29 12:44:05 UTC R topics documented: caterpillar.......................................... 2 caterpillar.dalmatian..................................... 2 convergence......................................... 3 convergence.dalmatian................................... 4 dalmatian.......................................... 5 fitted.dalmatian....................................... 7 pfdata............................................ 8 print.dalmatian.summary.................................. 8 ranef............................................. 9 1

2 caterpillar.dalmatian ranef.dalmatian....................................... 10 setjagsinits......................................... 10 summary.dalmatian..................................... 12 traceplots.......................................... 13 traceplots.dalmatian..................................... 13 weights.df.......................................... 14 Index 15 caterpillar Caterpillar (Generic) Caterpillar (Generic) caterpillar(object,...) object Object to assess. ## Generate caterpillar pfcaterpillar <- caterpillar(pfresults,plot = FALSE) caterpillar.dalmatian Caterpillar (dalmatian) Construct caterpillar plots for key (or selected) parameters in a dalmatian object. ## S3 method for class 'dalmatian' caterpillar(object, family = NULL, nstart = start(object$coda), nend = end(object$coda), nthin = thin(object$coda), plot = TRUE,...)

convergence 3 object family nstart nend nthin plot Object of class dalmatian created by dalmatian(). String defining selected family of variables (see help for ggs()). Start point for computing summary statistics (relative to true start of chain). End point for computing summary statistics (relative to true start of chain). Thinning factor for computing summary statsitics (relative to full chain and not previously thinned output). If TRUE then generate plots. Otherwise, a list of ggplot objects will be returned. A list of ggplot objects that can be used to later reproduce the plots via print. ## Generate caterpillar pfcaterpillar <- caterpillar(pfresults,plot = FALSE) convergence Convergence Diagnostics (S3 Generic) Generic function for computing convergence diagnostics. convergence(object,...) object Object to asses.

4 convergence.dalmatian ## Compute convergence diagnostics pfconvergence <- convergence(pfresults) convergence.dalmatian Convergence Compute convergence diagnostics for a dalmatian object. ## S3 method for class 'dalmatian' convergence(object, pars = NULL, nstart = start(object$coda), nend = end(object$coda), nthin = coda::thin(object$coda), raftery = NULL,...) object pars nstart nend nthin raftery Object of class dalmatian created by dalmatian(). List of parameters to assess. If NULL (default) then diagnostics are computed for the fixed effects and random effects standard deviations in both the mean and variance models. Start point for computing summary statistics (relative to true start of chain). End point for computing summary statistics (relative to true start of chain). Thinning factor for computing summary statsitics (relative to full chain and not previously thinned output). List of arguments to be passed to raftery.diag(). Any values not provided will be set to their defaults (see help(raftery.diag()) for details). List containing Gelman-Rubin and Raftery convergence diagnostics and effective sampel sizes for the selected parameters.

dalmatian 5 ## Compute convergence diagnostics pfconvergence <- convergence(pfresults) dalmatian Run DGLM in JAGS via rjags The primary function which automates the running of JAGS. dalmatian(df, mean.model, variance.model, jags.model.args, coda.samples.args, response = NULL, rounding = FALSE, lower = NULL, upper = NULL, parameters = NULL, svd = TRUE, residuals = FALSE, gencode = NULL, drop.levels = TRUE, drop.missing = TRUE, overwrite = FALSE, debug = FALSE, savejagsinput = NULL) df mean.model Data frame containing the response and predictor values for each individual. (data.frame) Model list specifying the structure of the mean. (list) variance.model Model list specifying the structure of the variance. (list) jags.model.args List containing named arguments of jags.model. (list) coda.samples.args List containing named arguments of coda.samples. (list) response rounding lower upper parameters svd Name of variable in the data frame representing the response. (character) Specifies that response has been rounded if TRUE. (logical) Name of variable in the data frame representing the lower bound on the response if rounded. (character) Name of variable in the data frame representing the upper bound on the response if rounded. (character) Names of parameters to monitor. If NULL then default values are selected. (character) Compute Singular Variable Decomposition of model matrices to improve convergence. (logical)

6 dalmatian residuals gencode drop.levels drop.missing overwrite debug savejagsinput If TRUE then compute residuals in output. (logical) If TRUE then generate code potentially overwriting existing model file. By default generate code if the file does not exist and prompt user if it does. (logical) If TRUE then drop unused levels from all factors in df. (logical) If TRUE then remove records with missing response variable. (logical) If TRUE then overwrite existing JAGS files (non-interactive sessions only). (logical) If TRUE then enter debug model. (logical) Directory to which jags.model input is saved prior to calling jags.model(). This is useful for debugging. No files saved if NULL. (character) Details The primary function in the package, dalmatian automates the generation of code, data, and initial values. These are then passed as arguments to function from the rjags package which automates the generation of samplse from the posterior. samples (mcmc.list) Author(s) Simon Bonner ## Not run: ## Load pied flycatcher data data(pied_flycatchers_1) ## Create variables bounding the true load pfdata$lower=ifelse(pfdata$load==0,log(.001),log(pfdata$load-.049)) pfdata$upper=log(pfdata$load+.05) ## Mean model mymean=list(fixed=list(name="alpha", formula=~ log(ivi) + broodsize + sex, priors=list(c("dnorm",0,.001)))) ## Variance model myvar=list(fixed=list(name="psi", link="log", formula=~broodsize + sex, priors=list(c("dnorm",0,.001)))) ## Set working directory ## By default uses a system temp directory. You probably want to change this. workingdir <- tempdir()

fitted.dalmatian 7 ## Define list of arguments for jags.model() jm.args <- list(file=file.path(workingdir,"pied_flycatcher_1_jags.r"),n.adapt=1000) ## Define list of arguments for coda.samples() cs.args <- list(n.iter=5000) ## Run the model using dalmatian pfresults <- dalmatian(df=pfdata, mean.model=mymean, variance.model=myvar, jags.model.args=jm.args, coda.samples.args=cs.args, rounding=true, lower="lower", upper="upper", debug=false) ## End(Not run) fitted.dalmatian Prediction method for dalmatian Fitted Objects Prediction method for dalmatian Fitted Objects ## S3 method for class 'dalmatian' fitted(object, df = object$df, method = "mean", ci = TRUE, level = 0.95,...) object df method ci level predictions (list) Object of class dalmatian created by dalmatian(). data frame containing predictor values to predict response variables. Defaults to data in object if not supplied. (data.frame) Method to construct the fitted model. Either "mean" or "mode" (character) returning credible intervals for predictions if TRUE (logical) level of credible intervals for predictions (numeric)

8 print.dalmatian.summary ## Load pied flycatcher data data(pied_flycatchers_1) ## Create variables bounding the true load pfdata$lower=ifelse(pfdata$load==0,log(.001),log(pfdata$load-.049)) pfdata$upper=log(pfdata$load+.05) ## Add 'log(ivi)' variable in pfdata pfdata$'log(ivi)' <- log(pfdata$ivi) ## Compute fitted values pred.pfresults <- fitted(object = pfresults, df = pfdata, method = "mean", ci = TRUE, level = 0.95) pfdata Pied flycatcher feeding data Dataset containing 5795 records of 60 pied flycatchers from 33 nest boxes feeding their nestlings during a brood manipulation experiment. pfdata Format A data frame containing 5795 rows and 17 variables print.dalmatian.summary Print Summary (dalmatian) Print Summary (dalmatian)

ranef 9 ## S3 method for class 'dalmatian.summary' print(x, digits = 2,...) x Object of class dalamtion.summary created by summary.dalmatian(). digits Number of digits to display after decimal. ## Compute numerical summaries print(summary(pfresults)) ranef Random Effects (S3 Generic) Generic function for exporting summaries of random effects. ranef(object,...) object Input object ## Compute numerical summaries ranef(pfresults)

10 setjagsinits ranef.dalmatian Random Effects (dalmatian) Compute posterior summary statistics for the individual random effects in each part of the model. ## S3 method for class 'dalmatian' ranef(object, nstart = start(object$coda), nend = end(object$coda), nthin = thin(object$coda),...) object nstart nend nthin Object of class dalmatian created by dalmatian(). Start point for computing summary statistics (relative to true start of chain). End point for computing summary statistics (relative to true start of chain). Thinning factor for computing summary statsitics (relative to full chain and not previously thinned output). output (list) ## Compute numerical summaries ranef(pfresults) setjagsinits Set initial values for dalmatian Set initial values for dalmatian

setjagsinits 11 setjagsinits(mean.model, variance.model, fixed.mean = NULL, fixed.variance = NULL, y = NULL, random.mean = NULL, sd.mean = NULL, random.variance = NULL, sd.variance = NULL) mean.model Model list specifying the structure of the mean. (list) variance.model Model list specifyint the structure of the variance. (list) fixed.mean Initial values for the fixed effects of the mean. (numeric) fixed.variance Initial values for the fixed effects of the variance. (numeric) y Details random.mean Inital values for the true response. This should only be specified if the rounding = TRUE in the main call to dalmatian. Initial values for the random effects of the mean. (numeric) sd.mean Initial values for the standard deviation of the random effects of the mean. (numeric) random.variance Initial values for the random effects of the variance. (numeric sd.variance Initial values for the standard deviation of the random effects of the variance. (numeric) Allows the user to set initial values for dalmatian. Any values not specified will by initialized by JAGS. inits (list) Author(s) Simon Bonner ## Load pied flycatcher data data(pied_flycatchers_1) ## Create variables bounding the true load pfdata$lower=ifelse(pfdata$load==0,log(.001),log(pfdata$load-.049)) pfdata$upper=log(pfdata$load+.05) ## Set initial values for a new run of the same model inits <- lapply(1:3,function(i){

12 summary.dalmatian setjagsinits(pfresults$mean.model, pfresults$variance.model, y = runif(nrow(pfdata),pfdata$lower,pfdata$upper), fixed.mean = tail(pfresults$coda[[i]],1)[1:4], fixed.variance = tail(pfresults$coda[[i]],1)[5:7], sd.mean = 1) }) summary.dalmatian Summary (dalmatian) Summary (dalmatian) ## S3 method for class 'dalmatian' summary(object, nstart = start(object$coda), nend = end(object$coda), nthin = thin(object$coda),...) object nstart nend nthin Object of class dalmatian created by dalmatian(). Start point for computing summary statistics (relative to true start of chain). End point for computing summary statistics (relative to true start of chain). Thinning factor for computing summary statsitics (relative to full chain and not previously thinned output). output (list) ## Compute numerical summaries summary(pfresults)

traceplots 13 traceplots Traceplots (Generic) Traceplots (Generic) traceplots(object,...) object Object to assess. ## Generate traceplots pftraceplots <- traceplots(pfresults) traceplots.dalmatian Traceplots (dalmatian) Construct traceplots for key (or selected) parameters in a dalmatian object. ## S3 method for class 'dalmatian' traceplots(object, family = NULL, nstart = start(object$coda), nend = end(object$coda), nthin = thin(object$coda), plot = TRUE,...)

14 weights.df object Object of class dalmatian created by dalmatian(). family String defining selected family of variables (see help for ggs()). nstart Start point for computing summary statistics (relative to true start of chain). nend End point for computing summary statistics (relative to true start of chain). nthin Thinning factor for computing summary statsitics (relative to full chain and not previously thinned output). plot If TRUE then generate plots. Otherwise, a list of ggplot objects will be returned. A list of ggplot objects that can be used to later reproduce the plots via print. ## Generate traceplots pftraceplots <- traceplots(pfresults) weights.df Simulated data for illustrating the use of weights Simulated data for illustrating the use of weights in the particular case when the responses are averages of observed with different denominators weights.df Format An object of class data.frame with 100 rows and 3 columns. Details @format A data frame with 100 rows and 3 columns: n The number of observations. x The common predictor value. y The mean response value.

Index Topic datasets pfdata, 8 weights.df, 14 caterpillar, 2 caterpillar.dalmatian, 2 convergence, 3 convergence.dalmatian, 4 dalmatian, 5 fitted.dalmatian, 7 pfdata, 8 print.dalmatian.summary, 8 ranef, 9 ranef.dalmatian, 10 setjagsinits, 10 summary.dalmatian, 12 traceplots, 13 traceplots.dalmatian, 13 weights.df, 14 15