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

« back to all changes in this revision

Viewing changes to man/nbolf.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:
8
8
 
9
9
}
10
10
\usage{
11
 
nbolf(theta, earg = stop("'earg' must be given"), inverse = FALSE,
12
 
      deriv = 0, short = TRUE, tag = FALSE)
 
11
nbolf(theta, earg = stop("argument 'earg' must be given"),
 
12
      inverse = FALSE, deriv = 0, short = TRUE, tag = FALSE)
13
13
}
14
14
%- maybe also 'usage' for other objects documented here.
15
15
\arguments{
27
27
  The cutpoints should be non-negative integers.
28
28
  If \code{nbolf()} is used as the link function in
29
29
  \code{\link{cumulative}} then one should choose
30
 
  \code{reverse=TRUE, parallel=TRUE, intercept.apply=TRUE}.
 
30
  \code{reverse = TRUE, parallel = TRUE, intercept.apply = TRUE}.
31
31
 
32
32
  }
33
33
  \item{inverse}{
57
57
  an ordinal response coming from an underlying negative binomial
58
58
  distribution.
59
59
 
 
60
 
60
61
  The arguments \code{short} and \code{tag} are used only if
61
62
  \code{theta} is character.
62
63
 
 
64
 
63
65
  See \code{\link{Links}} for general information about \pkg{VGAM}
64
66
  link functions.
65
67
 
 
68
 
66
69
}
67
70
\value{
68
 
  See Yee (2007) for details.
 
71
  See Yee (2011) for details.
 
72
 
69
73
 
70
74
}
71
75
\references{
72
 
  Yee, T. W. (2007)
 
76
  Yee, T. W. (2011)
73
77
  \emph{Ordinal ordination with normalizing link functions for count data}, 
74
78
  (in preparation).
75
79
 
 
80
 
76
81
}
77
82
\author{ Thomas W. Yee }
78
83
 
84
89
  \code{theta} is too close to 1 or 0,
85
90
  numerical instabilities may still arise.
86
91
 
 
92
 
87
93
  In terms of the threshold approach with cumulative probabilities for
88
94
  an ordinal response this link function corresponds to the negative
89
95
  binomial distribution (see \code{\link{negbinomial}}) that has been
90
96
  recorded as an ordinal response using known cutpoints.
91
97
 
 
98
 
92
99
}
93
100
\section{Warning }{
94
101
  Prediction may not work on \code{\link{vglm}} or
95
102
  \code{\link{vgam}} etc. objects if this link function is used.
96
103
 
 
104
 
97
105
}
98
106
 
99
107
\seealso{ 
104
112
  \code{nbolf2},
105
113
  \code{\link{cumulative}}.
106
114
 
 
115
 
107
116
}
108
117
\examples{
109
 
earg = list(cutpoint=2, k=1)
110
 
nbolf("p", earg=earg, short=FALSE)
111
 
nbolf("p", earg=earg, tag=TRUE)
112
 
 
113
 
p = seq(0.02, 0.98, by=0.01)
114
 
y = nbolf(p, earg=earg)
115
 
y. = nbolf(p, earg=earg, deriv=1)
116
 
max(abs(nbolf(y, earg=earg, inv=TRUE) - p)) # Should be 0
117
 
 
118
 
\dontrun{
119
 
par(mfrow=c(2,1), las=1)
120
 
plot(p, y, type="l", col="blue", main="nbolf()")
121
 
abline(h=0, v=0.5, col="red", lty="dashed")
122
 
 
123
 
plot(p, y., type="l", col="blue",
124
 
     main="(Reciprocal of) first NBOLF derivative")
125
 
}
 
118
earg = list(cutpoint = 2, k = 1)
 
119
nbolf("p", earg = earg, short = FALSE)
 
120
nbolf("p", earg = earg, tag = TRUE)
 
121
 
 
122
p = seq(0.02, 0.98, by = 0.01)
 
123
y = nbolf(p, earg = earg)
 
124
y. = nbolf(p, earg = earg, deriv = 1)
 
125
max(abs(nbolf(y, earg = earg, inv = TRUE) - p)) # Should be 0
 
126
 
 
127
\dontrun{ par(mfrow = c(2, 1), las = 1)
 
128
plot(p, y, type = "l", col = "blue", main = "nbolf()")
 
129
abline(h = 0, v = 0.5, col = "red", lty = "dashed")
 
130
 
 
131
plot(p, y., type = "l", col = "blue",
 
132
     main = "(Reciprocal of) first NBOLF derivative") }
126
133
 
127
134
# Another example
128
135
nn = 1000
130
137
x3 = runif(nn)
131
138
mymu = exp( 3 + 1 * x2 - 2 * x3)
132
139
k = 4
133
 
y1 = rnbinom(nn, mu=mymu, size=k)
 
140
y1 = rnbinom(nn, mu = mymu, size = k)
134
141
cutpoints = c(-Inf, 10, 20, Inf)
135
 
cuty = Cut(y1, breaks=cutpoints)
136
 
\dontrun{
137
 
plot(x2, x3, col=cuty, pch=as.character(cuty))
138
 
}
 
142
cuty = Cut(y1, breaks = cutpoints)
 
143
\dontrun{ plot(x2, x3, col = cuty, pch = as.character(cuty)) }
139
144
table(cuty) / sum(table(cuty))
140
 
fit = vglm(cuty ~ x2 + x3, fam = cumulative(link="nbolf",
141
 
           reverse=TRUE, parallel=TRUE, intercept.apply=TRUE,
142
 
           mv=TRUE, earg=list(cutpoint=cutpoints[2:3], k=k)),
143
 
           trace=TRUE)
 
145
fit = vglm(cuty ~ x2 + x3, fam = cumulative(link = "nbolf",
 
146
           reverse = TRUE, parallel = TRUE, intercept.apply = TRUE,
 
147
           mv = TRUE, earg = list(cutpoint = cutpoints[2:3], k = k)),
 
148
           trace = TRUE)
144
149
head(fit@y)
145
150
head(fitted(fit))
146
151
head(predict(fit))
147
152
coef(fit)
148
 
coef(fit, matrix=TRUE)
 
153
coef(fit, matrix = TRUE)
149
154
constraints(fit)
150
155
fit@misc$earg
151
156
}