binToBinom: Convert Bernoulli observations to Binomial

Description Usage Arguments Value Author(s) Examples

View source: R/binToBinom.R

Description

Combines multiple Bernoulli observations with the same covariates into one Binomial response

Usage

1
binToBinom(obs, covariates)

Arguments

obs

logical vector of observations

covariates

Data frame or matrix of covariates

Value

A data frame with one row for each unique value for the covariates, including the covariates and the following additional columns:

y

Number of positive observations for the corresponding covariate values

N

Total number of observations for these covariates

Author(s)

Patrick Brown

Examples

1
2
3
4
5
  thedata = data.frame(sex = rep(c("m", "f"), 10), age=rep(c(20,30), c(10, 10)))
  y = rbinom(dim(thedata)[1], 1, 0.5)
  bindata = binToBinom(y, thedata)
  bindata$zeros = bindata$N - bindata$y
  glm(as.matrix(bindata[,c("y", "zeros")]) ~ sex, data=bindata, family=binomial)

glmmBUGS documentation built on May 2, 2018, 1:03 a.m.