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

« back to all changes in this revision

Viewing changes to man/ordpoisson.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
 
ordpoisson(cutpoints, countdata=FALSE, NOS=NULL,
12
 
           Levels=NULL, init.mu=NULL, parallel=FALSE,
13
 
           zero=NULL, link="loge", earg = list())
 
11
ordpoisson(cutpoints, countdata = FALSE, NOS = NULL,
 
12
           Levels = NULL, init.mu = NULL, parallel = FALSE,
 
13
           zero = NULL, link = "loge", earg = list())
14
14
}
15
15
%- maybe also 'usage' for other objects documented here.
16
16
\arguments{
30
30
    the response is expected to be in the same format as \code{fit@y}
31
31
    where \code{fit} is a fitted model with \code{ordpoisson} as the
32
32
    \pkg{VGAM} family function. That is, the response is matrix of counts
33
 
    with \code{L} columns (if \code{NOS=1}).
 
33
    with \code{L} columns (if \code{NOS = 1}).
34
34
 
35
35
  }
36
36
  \item{NOS}{
37
37
    Integer. The number of species, or more generally, the number of
38
38
    response random variates.
39
 
    This argument must be specified when \code{countdata=TRUE}.
40
 
    Usually \code{NOS=1}.
 
39
    This argument must be specified when \code{countdata = TRUE}.
 
40
    Usually \code{NOS = 1}.
41
41
 
42
42
  }
43
43
  \item{Levels}{
44
44
    Integer vector, recycled to length \code{NOS} if necessary.
45
45
    The number of levels for each response random variate.
46
46
    This argument should agree with \code{cutpoints}.
47
 
    This argument must be specified when \code{countdata=TRUE}.
 
47
    This argument must be specified when \code{countdata = TRUE}.
48
48
 
49
49
  }
50
50
  \item{init.mu}{
75
75
  The response for this family function corresponds to \eqn{Y^*} but
76
76
  we are really interested in the Poisson regression of \eqn{Y}.
77
77
 
 
78
 
78
79
  If \code{NOS=1} then
79
80
  the argument \code{cutpoints} is a vector \eqn{(K_1,K_2,\ldots,K_L)}
80
81
  where the last value (\code{Inf}) is optional. If \code{NOS>1} then
84
85
  \code{ordpoisson(cut = c(0, 5, 10, Inf, 20, 30, Inf, 0, 10, 40, Inf))}
85
86
  is valid.
86
87
 
 
88
 
87
89
}
88
90
\value{
89
91
  An object of class \code{"vglmff"} (see \code{\link{vglmff-class}}).
90
92
  The object is used by modelling functions such as \code{\link{vglm}}
91
93
  and \code{\link{vgam}}.
92
94
 
 
95
 
93
96
}
94
97
\references{
95
 
  Yee, T. W. (2007)
 
98
 
 
99
 
 
100
  Yee, T. W. (2011)
96
101
  \emph{Ordinal ordination with normalizing link functions for count data}, 
97
102
  (in preparation).
98
103
 
 
104
 
99
105
}
100
106
\author{ Thomas W. Yee }
101
107
 
104
110
  the arguments \code{Levels} and \code{NOS} need to be specified too.
105
111
  See below for an example.
106
112
 
 
113
 
107
114
}
108
115
\section{Warning }{
109
116
  The input requires care as little to no checking is done.
110
117
  If \code{fit} is the fitted object, have a look at \code{fit@extra} and
111
118
  \code{fit@y} to check.
112
119
  
 
120
 
113
121
}
114
122
 
115
123
\seealso{ 
117
125
  \code{\link{polf}},
118
126
  \code{\link[base:factor]{ordered}}.
119
127
 
 
128
 
120
129
}
121
130
\examples{
122
 
# Example 1
123
 
set.seed(123)
 
131
set.seed(123)     # Example 1
124
132
x2 = runif(n <- 1000); x3 = runif(n)
125
133
mymu = exp(3 - 1 * x2 + 2 * x3)
126
 
y1 = rpois(n, lambda=mymu)
 
134
y1 = rpois(n, lambda = mymu)
127
135
cutpts = c(-Inf, 20, 30, Inf)
128
136
fcutpts = cutpts[is.finite(cutpts)]  # finite cutpoints
129
 
ystar = cut(y1, breaks=cutpts, labels=FALSE)
 
137
ystar = cut(y1, breaks = cutpts, labels = FALSE)
130
138
\dontrun{
131
 
plot(x2, x3, col=ystar, pch=as.character(ystar))
 
139
plot(x2, x3, col = ystar, pch = as.character(ystar))
132
140
}
133
141
table(ystar) / sum(table(ystar))
134
 
fit = vglm(ystar ~ x2 + x3, fam = ordpoisson(cutpoi=fcutpts))
135
 
head(fit@y)        # This can be input if countdata=TRUE
 
142
fit = vglm(ystar ~ x2 + x3, fam = ordpoisson(cutpoi = fcutpts))
 
143
head(fit@y)        # This can be input if countdata = TRUE
136
144
head(fitted(fit))
137
145
head(predict(fit))
138
 
coef(fit, matrix=TRUE)
 
146
coef(fit, matrix = TRUE)
139
147
fit@extra
140
148
 
141
149
# Example 2: multivariate and there are no obsns between some cutpoints
142
150
cutpts2 = c(-Inf, 0, 9, 10, 20, 70, 200, 201, Inf)
143
151
fcutpts2 = cutpts2[is.finite(cutpts2)]  # finite cutpoints
144
 
y2 = rpois(n, lambda=mymu)   # Same model as y1
145
 
ystar2 = cut(y2, breaks=cutpts2, labels=FALSE)
 
152
y2 = rpois(n, lambda = mymu)   # Same model as y1
 
153
ystar2 = cut(y2, breaks = cutpts2, labels = FALSE)
146
154
table(ystar2) / sum(table(ystar2))
147
155
fit = vglm(cbind(ystar,ystar2) ~ x2 + x3, fam =
148
 
           ordpoisson(cutpoi=c(fcutpts,Inf,fcutpts2,Inf),
149
 
                      Levels=c(length(fcutpts)+1,length(fcutpts2)+1),
150
 
                      parallel=TRUE), trace=TRUE)
151
 
coef(fit, matrix=TRUE)
 
156
           ordpoisson(cutpoi = c(fcutpts,Inf,fcutpts2,Inf),
 
157
                      Levels = c(length(fcutpts)+1,length(fcutpts2)+1),
 
158
                      parallel = TRUE), trace = TRUE)
 
159
coef(fit, matrix = TRUE)
152
160
fit@extra
153
161
constraints(fit)
154
162
summary(fit@y)  # Some columns have all zeros