Skip to content

Commit 3d89732

Browse files
committed
Improve documentation + examples of gmo function
Clean up imports, exports; Add long description
1 parent 572797f commit 3d89732

File tree

10 files changed

+75
-27
lines changed

10 files changed

+75
-27
lines changed

DESCRIPTION

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ Title: Overdispersion Models using Generalized Estimating Equations
44
Version: 1.0
55
Author: Victoria Landsman, David Landsman
66
Maintainer: David Landsman <david.landsman@mail.utoronto.ca>
7-
Description: More about what it does (maybe more than one line)
8-
Use four spaces when indenting paragraphs within the Description.
7+
Description: Provides an implementation of a GEE solver for estimating
8+
the parameters of an overdispersion model. The solver supports data with
9+
both an independence and exchangeable correlation model.
910
License: MIT + file LICENSE
1011
Encoding: UTF-8
1112
LazyData: true
1213
RoxygenNote: 6.1.1
13-
Imports:
14-
base,
15-
stats,
16-
psych,
14+
Imports:
1715
rootSolve

NAMESPACE

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
exportPattern("^[[:alpha:]]+")
1+
# Generated by roxygen2: do not edit by hand
2+
3+
S3method(print,gmo.glogit)
4+
S3method(print,gmo.ident)
25
export(gmo)
36

4-
importFrom("psych", "tr")
57
importFrom("rootSolve", "multiroot")
6-
importFrom("stats", "uniroot")
8+
importFrom("stats", "uniroot")

R/gmo.r

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
#' GMO - General Multinomial Overdisperion Model
22
#'
3-
#' Creates an General Multinomial Overdispersion Model for the given data
3+
#' Creates an General Multinomial Overdispersion Model for the given data matrix.
4+
#' The data passed in should be in the form of multinomial clusters.
45
#'
6+
#' The `corstr` option specifies the intra-cluster correlation structure:
7+
#' - `independence` is used when there is no intra-cluster correlation (i.e.: rho = 0) (default)
8+
#' - `exchangebale` is used when there is intra-cluster correlation
9+
#'
10+
#' The `link` option specifies the format of the output:
11+
#' - `glogit` option gives the estimates and variance matrix in terms of beta (real-valued) (default)
12+
#' - `identity` option gives the estimates and variance matrix in terms of pi's in [0, 1]
513
#'
614
#' @param dat matrix of multinomial clusters
715
#' @param corstr one of: independence, exchangeable
816
#' @param link one of: glogit, identity
9-
#' @param ... parameters to be passed on to \code{iterative_function}
17+
#'
18+
#' @examples
19+
#' dat <- matrix(c(6, 4, 4, 3, 1, 2, 2, 2, 1, 3, 15, 6, 5, 8, 4, 2, 2, 1, 13, 10, 8, 1, 3, 2, 10, 22, 11, 31, 10, 14), nrow=10, ncol=3, byrow=TRUE)
20+
#' gmo(dat, link='identity')
1021
#'
1122
#' @return a GMO object
1223
#' @export
13-
gmo <- function (dat, corstr = "independence", link = "glogit", ...) {
24+
gmo <- function (dat, corstr = "independence", link = "glogit") {
1425
if (!is.matrix(dat))
1526
stop("dat must be a matrix")
1627
if (!(corstr %in% c("independence", "exchangeable")))
@@ -50,7 +61,7 @@ gmo <- function (dat, corstr = "independence", link = "glogit", ...) {
5061

5162
#' Print GMO glogit
5263
#'
53-
#' Prints GMO glogit object
64+
#' Prints GMO glogit object.
5465
#'
5566
#' @param x gom glogit object
5667
#' @param ... additional params to \code{print(x, ...)}
@@ -75,7 +86,7 @@ print.gmo.glogit <- function(x, ...) {
7586

7687
#' Print GMO identity
7788
#'
78-
#' Prints GMO identity object
89+
#' Prints GMO identity object.
7990
#'
8091
#' @param x gom identity object
8192
#' @param ... additional params to \code{print(x, ...)}
@@ -96,7 +107,4 @@ print.gmo.ident <- function(x, ...) {
96107

97108
cat('\nVar-Covar Matrix: \n')
98109
print(round(x$var.mat, 6), ...)
99-
}
100-
101-
registerS3method("print", "gmo.glogit", "print.gmo.glogit")
102-
registerS3method("print", "gmo.ident", "print.gmo.ident")
110+
}

R/helpers.r

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#' Compute trace of a square matrix, that is, the sum
2+
#' of its diagonal elements.
3+
#'
4+
#' @param m a square matrix
5+
#'
6+
#' @return trace of input matrix
7+
tr <- function(m) {
8+
sum(diag(m))
9+
}

R/iterative.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
library(rootSolve)
2+
13
#' Iterative GEE Function
24
#'
35
#' Iteratively finds coefficients and overdispersion parameter using
@@ -9,7 +11,6 @@
911
#' @param thresholds vector of thresholds for betas and rho
1012
#'
1113
#' @return list containing estimates (probabilities and rho) and number of iterations
12-
#' @export
1314
iterative_function <- function(dat, RHO = FALSE, max.iter = 10, thresholds = NULL) {
1415
n <- dim(dat)[[2]]
1516
if (is.null(thresholds)) thresholds <- rep(0.00000001, n)

R/variance.r

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#' @param dat matrix of multinomial clusters
88
#'
99
#' @return matrix of covariance
10-
#' @export
1110
get_var_ident <- function (p.vec, rho, dat) {
1211
n <- dim(dat)[[2]] # dimensions of multinom
1312
m <- n - 1 # order of multinom
@@ -47,7 +46,6 @@ get_var_ident <- function (p.vec, rho, dat) {
4746
#' @param dat matrix of multinomial clusters
4847
#'
4948
#' @return matrix of covariance
50-
#' @export
5149
get_var_glogit <- function(betas, rho, dat) {
5250
n <- dim(dat)[[2]] # dimensions of multinom
5351
m <- n - 1 # order of multinom

man/gmo.Rd

Lines changed: 17 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.gmo.glogit.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.gmo.ident.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tr.Rd

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)