# Example 1.
data(pneumo)
pneumo = transform(pneumo, let=log(exposure.time))
vglm(cbind(normal,mild,severe) ~ let, multinomial, pneumo,
crit="coef", step=0.5, trace=TRUE, eps=1e-8, maxit=40)
# Example 2. The use of the xij argument
set.seed(111)
n = 1000
ymat = rdiric(n, shape=c(4,7,3,1))
mydat = data.frame(x1=runif(n), x2=runif(n), x3=runif(n), x4=runif(n),
z1=runif(n), z2=runif(n), z3=runif(n), z4=runif(n))
mydat = round(mydat, dig=2)
fit = vglm(ymat ~ x1 + x2 + x3 + x4 + z1 + z2 + z3 + z4,
fam = dirichlet, data=mydat, crit="c",
xij = list(z ~ z1 + z2 + z3 + z4,
x ~ x1 + x2 + x3 + x4))
model.matrix(fit, type="lm")[1:7,] # LM model matrix
model.matrix(fit, type="vlm")[1:7,] # Big VLM model matrix
coef(fit)
coef(fit, matrix=TRUE)
coef(fit, matrix=TRUE, compress=FALSE)
max(abs(predict(fit)-predict(fit, new=mydat))) # Predicts correctly
summary(fit)
Run the code above in your browser using DataLab