# Example 1: simulated data
set.seed(123)
nTimePts <- 2 # Must be 2 or 3 currently (aka tau == # of sampling occasions)
nnn <- 10000 # Number of animals
pdata <- rposbern(n = nnn, nTimePts = nTimePts, pvars = 2)
dim(pdata)
head(pdata)
clist <- list("(Intercept)" = cbind(1, c(0, 0, 1)), # Capture effect is last coln
x2 = rbind(1, 1, 1))
M_tbh.1 <- vglm(cbind(y1, y2) ~ x2,
constraints = clist, trace = TRUE,
posbernoulli.tb, data = pdata)
summary(M_tbh.1)
coef(M_tbh.1)
coef(M_tbh.1, matrix = TRUE)
constraints(M_tbh.1, matrix = TRUE)
summary(M_tbh.1) # Standard errors are very approximate
head(fitted(M_tbh.1))
head(model.matrix(M_tbh.1, type = "vlm"), 21)
dim(depvar(M_tbh.1))
# Example 2: Perom subset data
Hlist <- list("(Intercept)" = cbind(1, c(0, 0, 0, 1, 1)),
sex = rbind(1, 1, 1, 1, 1),
weight = rbind(1, 1, 1, 1, 1))
Psubset <- subset(Perom, y1 + y2 + y3 > 0)
head(Psubset)
fit1 <- vglm(cbind(y1, y2, y3) ~ sex + weight, constraints = Hlist,
posbernoulli.tb, data = Psubset, trace = TRUE)
coef(fit1)
coef(fit1, matrix = TRUE)
summary(fit1) # Standard errors are very approximate
# fit1 is the same as Fit1:
Fit1 <- vglm(cbind(y1, y2, y3) ~ sex + weight, data = Psubset,
posbernoulli.tb(parallel.t = TRUE), trace = TRUE)
constraints(Fit1) # Same as Hlist
yyy <- depvar(fit1)
if (length(table(4 * yyy[, 1] + 2 * yyy[, 2] + 1 * yyy[, 3])) != 2^(ncol(yyy))-1)
warning("not every combination is represented by a row in the response matrix")
Run the code above in your browser using DataLab