~ubuntu-branches/ubuntu/trusty/r-cran-vgam/trusty

« back to all changes in this revision

Viewing changes to man/vglm.control.Rd

  • Committer: Package Import Robot
  • Author(s): Chris Lawrence
  • Date: 2011-11-04 13:13:06 UTC
  • mfrom: (1.2.9)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: package-import@ubuntu.com-20111104131306-w9fd83i51rw60gxf
Tags: upstream-0.8-4
ImportĀ upstreamĀ versionĀ 0.8-4

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
 
185
185
 
186
186
# Example 2. The use of the xij argument (simple case).
187
 
ymat = rdiric(n <- 1000, shape=rep(exp(2), len=4))
188
 
mydat = data.frame(x1=runif(n), x2=runif(n), x3=runif(n), x4=runif(n),
189
 
                   z1=runif(n), z2=runif(n), z3=runif(n), z4=runif(n))
190
 
mydat = transform(mydat, X=x1, Z=z1)
191
 
mydat = round(mydat, dig=2)
 
187
ymat = rdiric(n <- 1000, shape = rep(exp(2), len = 4))
 
188
mydat = data.frame(x1 = runif(n), x2 = runif(n), x3 = runif(n), x4 = runif(n),
 
189
                   z1 = runif(n), z2 = runif(n), z3 = runif(n), z4 = runif(n))
 
190
mydat = transform(mydat, X = x1, Z = z1)
 
191
mydat = round(mydat, dig = 2)
192
192
fit2 = vglm(ymat ~ X + Z,
193
 
            dirichlet(parallel=TRUE), data=mydat, trace=TRUE,
 
193
            dirichlet(parallel = TRUE), data = mydat, trace = TRUE,
194
194
            xij = list(Z ~ z1 + z2 + z3 + z4,
195
195
                       X ~ x1 + x2 + x3 + x4),
196
196
            form2 = ~  Z + z1 + z2 + z3 + z4 +
197
197
                       X + x1 + x2 + x3 + x4)
198
 
head(model.matrix(fit2, type="lm"))   # LM model matrix
199
 
head(model.matrix(fit2, type="vlm"))  # Big VLM model matrix
 
198
head(model.matrix(fit2, type = "lm"))   # LM model matrix
 
199
head(model.matrix(fit2, type = "vlm"))  # Big VLM model matrix
200
200
coef(fit2)
201
 
coef(fit2, matrix=TRUE)
202
 
max(abs(predict(fit2)-predict(fit2, new=mydat))) # Predicts correctly
 
201
coef(fit2, matrix = TRUE)
 
202
max(abs(predict(fit2)-predict(fit2, new = mydat))) # Predicts correctly
203
203
summary(fit2)
204
204
\dontrun{
205
 
# plotvgam(fit2, se=TRUE, xlab="x1", which.term=1) # Bug!
206
 
# plotvgam(fit2, se=TRUE, xlab="z1", which.term=2) # Bug!
207
 
plotvgam(fit2, xlab="x1") # Correct
208
 
plotvgam(fit2, xlab="z1") # Correct
 
205
# plotvgam(fit2, se = TRUE, xlab = "x1", which.term = 1) # Bug!
 
206
# plotvgam(fit2, se = TRUE, xlab = "z1", which.term = 2) # Bug!
 
207
plotvgam(fit2, xlab = "x1") # Correct
 
208
plotvgam(fit2, xlab = "z1") # Correct
209
209
}
210
210
 
211
211
 
215
215
set.seed(123)
216
216
coalminers = transform(coalminers,
217
217
                       Age = (age - 42) / 5,
218
 
                       dum1 = round(runif(nrow(coalminers)), dig=2),
219
 
                       dum2 = round(runif(nrow(coalminers)), dig=2),
220
 
                       dum3 = round(runif(nrow(coalminers)), dig=2),
221
 
                       dumm = round(runif(nrow(coalminers)), dig=2))
222
 
BS = function(x, ..., df=3) bs(c(x,...), df=df)[1:length(x),,drop=FALSE]
223
 
NS = function(x, ..., df=3) ns(c(x,...), df=df)[1:length(x),,drop=FALSE]
 
218
                       dum1 = round(runif(nrow(coalminers)), dig = 2),
 
219
                       dum2 = round(runif(nrow(coalminers)), dig = 2),
 
220
                       dum3 = round(runif(nrow(coalminers)), dig = 2),
 
221
                       dumm = round(runif(nrow(coalminers)), dig = 2))
 
222
BS = function(x, ..., df = 3) bs(c(x,...), df = df)[1:length(x),,drop = FALSE]
 
223
NS = function(x, ..., df = 3) ns(c(x,...), df = df)[1:length(x),,drop = FALSE]
224
224
 
225
225
# Equivalently...
226
 
BS = function(x, ..., df=3) head(bs(c(x,...), df=df), length(x), drop=FALSE)
227
 
NS = function(x, ..., df=3) head(ns(c(x,...), df=df), length(x), drop=FALSE)
 
226
BS = function(x, ..., df = 3) head(bs(c(x,...), df = df), length(x), drop = FALSE)
 
227
NS = function(x, ..., df = 3) head(ns(c(x,...), df = df), length(x), drop = FALSE)
228
228
 
229
229
fit3 = vglm(cbind(nBnW,nBW,BnW,BW) ~ Age + NS(dum1,dum2),
230
 
            fam = binom2.or(exchang=TRUE, zero=3),
 
230
            fam = binom2.or(exchang = TRUE, zero = 3),
231
231
            xij = list(NS(dum1,dum2) ~ NS(dum1,dum2) +
232
232
                                       NS(dum2,dum1) +
233
233
                                       fill(NS(dum1))),
234
234
            form2 = ~  NS(dum1,dum2) + NS(dum2,dum1) + fill(NS(dum1)) +
235
235
                       dum1 + dum2 + dum3 + Age + age + dumm,
236
 
            data = coalminers, trace=TRUE)
237
 
head(model.matrix(fit3, type="lm"))   # LM model matrix
238
 
head(model.matrix(fit3, type="vlm"))  # Big VLM model matrix
 
236
            data = coalminers, trace = TRUE)
 
237
head(model.matrix(fit3, type = "lm"))   # LM model matrix
 
238
head(model.matrix(fit3, type = "vlm"))  # Big VLM model matrix
239
239
coef(fit3)
240
 
coef(fit3, matrix=TRUE)
241
 
\dontrun{
242
 
plotvgam(fit3, se=TRUE, lcol="red", scol="blue", xlab="dum1")
243
 
}
 
240
coef(fit3, matrix = TRUE)
 
241
\dontrun{ plotvgam(fit3, se = TRUE, lcol = "red", scol = "blue", xlab = "dum1") }
244
242
}
245
243
\keyword{models}
246
244
\keyword{regression}