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

« back to all changes in this revision

Viewing changes to man/logit.Rd

  • Committer: Package Import Robot
  • Author(s): Chris Lawrence
  • Date: 2011-11-04 13:13:06 UTC
  • mfrom: (1.1.12) (2.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111104131306-lrc3f24ev3xoev2q
Tags: 0.8-4-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
\usage{
12
12
logit(theta, earg = list(), inverse = FALSE, deriv = 0,
13
13
      short = TRUE, tag = FALSE)
14
 
elogit(theta, earg = list(min=0, max=1), inverse = FALSE, deriv = 0,
 
14
elogit(theta, earg = list(min = 0, max = 1), inverse = FALSE, deriv = 0,
15
15
      short = TRUE, tag = FALSE)
16
16
}
17
17
%- maybe also 'usage' for other objects documented here.
136
136
 
137
137
 }
138
138
\examples{
139
 
p = seq(0.01, 0.99, by=0.01)
 
139
p = seq(0.01, 0.99, by = 0.01)
140
140
logit(p)
141
 
max(abs(logit(logit(p), inverse=TRUE) - p)) # Should be 0
 
141
max(abs(logit(logit(p), inverse = TRUE) - p)) # Should be 0
142
142
 
143
 
p = c(seq(-0.02, 0.02, by=0.01), seq(0.97, 1.02, by=0.01))
 
143
p = c(seq(-0.02, 0.02, by = 0.01), seq(0.97, 1.02, by = 0.01))
144
144
logit(p)  # Has NAs
145
 
logit(p, earg=list(bvalue= .Machine$double.eps))  # Has no NAs
 
145
logit(p, earg = list(bvalue =  .Machine$double.eps))  # Has no NAs
146
146
 
147
 
p = seq(0.9, 2.2, by=0.1)
148
 
elogit(p, earg=list(min=1, max=2,
 
147
p = seq(0.9, 2.2, by = 0.1)
 
148
elogit(p, earg = list(min = 1, max = 2,
149
149
                    bminvalue = 1 + .Machine$double.eps,
150
150
                    bmaxvalue = 2 - .Machine$double.eps))  # Has no NAs
151
151
 
152
152
\dontrun{
153
 
par(mfrow=c(2,2))
154
 
y = seq(-4, 4, length=100)
155
 
p = seq(0.01, 0.99, by=0.01)
 
153
par(mfrow = c(2,2))
 
154
y = seq(-4, 4, length = 100)
 
155
p = seq(0.01, 0.99, by = 0.01)
156
156
for(d in 0:1) {
157
 
    matplot(p, cbind(logit(p, deriv=d), probit(p, deriv=d)),
158
 
            type="n", col="purple", ylab="transformation",
159
 
            lwd=2, las=1,
160
 
            main = if (d == 0) "Some probability link functions"
 
157
    matplot(p, cbind(logit(p, deriv = d), probit(p, deriv = d)),
 
158
            type = "n", col = "purple", ylab = "transformation",
 
159
            lwd = 2, las = 1,
 
160
            main = if (d ==  0) "Some probability link functions"
161
161
            else "First derivative")
162
 
    lines(p, logit(p, deriv=d), col="limegreen", lwd=2)
163
 
    lines(p, probit(p, deriv=d), col="purple", lwd=2)
164
 
    lines(p, cloglog(p, deriv=d), col="chocolate", lwd=2)
165
 
    lines(p, cauchit(p, deriv=d), col="tan", lwd=2)
166
 
    if (d == 0) {
167
 
        abline(v=0.5, h=0, lty="dashed")
 
162
    lines(p,   logit(p, deriv = d), lwd = 2, col = "limegreen")
 
163
    lines(p,  probit(p, deriv = d), lwd = 2, col = "purple")
 
164
    lines(p, cloglog(p, deriv = d), lwd = 2, col = "chocolate")
 
165
    lines(p, cauchit(p, deriv = d), lwd = 2, col = "tan")
 
166
    if (d ==  0) {
 
167
        abline(v = 0.5, h = 0, lty = "dashed")
168
168
        legend(0, 4.5, c("logit", "probit", "cloglog", "cauchit"),
169
 
               col=c("limegreen","purple","chocolate", "tan"), lwd=2)
 
169
               col = c("limegreen", "purple", "chocolate", "tan"), lwd = 2)
170
170
    } else
171
 
        abline(v=0.5, lty="dashed")
 
171
        abline(v = 0.5, lty = "dashed")
172
172
}
173
173
 
174
174
for(d in 0) {
175
 
    matplot(y, cbind(logit(y, deriv=d, inverse=TRUE),
176
 
                     probit(y, deriv=d, inverse=TRUE)),
177
 
            type="n", col="purple", xlab="transformation", ylab="p",
178
 
            lwd=2, las=1,
179
 
            main = if (d == 0) "Some inverse probability link functions"
 
175
    matplot(y, cbind(logit(y, deriv = d, inverse = TRUE),
 
176
                     probit(y, deriv = d, inverse = TRUE)),
 
177
            type = "n", col = "purple", xlab = "transformation", ylab = "p",
 
178
            lwd = 2, las = 1,
 
179
            main = if (d ==  0) "Some inverse probability link functions"
180
180
            else "First derivative")
181
 
    lines(y, logit(y, deriv=d, inverse=TRUE), col="limegreen", lwd=2)
182
 
    lines(y, probit(y, deriv=d, inverse=TRUE), col="purple", lwd=2)
183
 
    lines(y, cloglog(y, deriv=d, inverse=TRUE), col="chocolate", lwd=2)
184
 
    lines(y, cauchit(y, deriv=d, inverse=TRUE), col="tan", lwd=2)
185
 
    if (d == 0) {
186
 
        abline(h=0.5, v=0, lty="dashed")
 
181
    lines(y,   logit(y, deriv = d, inverse = TRUE), lwd = 2, col = "limegreen")
 
182
    lines(y,  probit(y, deriv = d, inverse = TRUE), lwd = 2, col = "purple")
 
183
    lines(y, cloglog(y, deriv = d, inverse = TRUE), lwd = 2, col = "chocolate")
 
184
    lines(y, cauchit(y, deriv = d, inverse = TRUE), lwd = 2, col = "tan")
 
185
    if (d ==  0) {
 
186
        abline(h = 0.5, v = 0, lty = "dashed")
187
187
        legend(-4, 1, c("logit", "probit", "cloglog", "cauchit"),
188
 
               col=c("limegreen","purple","chocolate", "tan"), lwd=2)
 
188
               col = c("limegreen", "purple", "chocolate", "tan"), lwd = 2)
189
189
    }
190
190
}
191
191
 
192
 
p = seq(0.21, 0.59, by=0.01)
193
 
plot(p, elogit(p, earg=list(min=0.2, max=0.6)), lwd=2, 
194
 
     type="l", col="black", ylab="transformation", xlim=c(0,1),
195
 
     las=1, main="elogit(p, earg=list(min=0.2, max=0.6)")
 
192
p = seq(0.21, 0.59, by = 0.01)
 
193
plot(p, elogit(p, earg = list(min = 0.2, max = 0.6)), lwd = 2, 
 
194
     type = "l", col = "black", ylab = "transformation", xlim = c(0,1),
 
195
     las = 1, main = "elogit(p, earg = list(min = 0.2, max = 0.6)")
196
196
}
197
197
}
198
198
\keyword{math}
199
199
\keyword{models}
200
200
\keyword{regression}
201
201
 
202
 
%plot(y, logit(y, inverse=TRUE), type="l", col="limegreen",
203
 
%     xlab="transformation", ylab="p",
204
 
%     lwd=2, las=1, main="Some inverse probability link functions")
205
 
%lines(y, probit(y, inverse=TRUE), col="purple", lwd=2)
206
 
%lines(y, cloglog(y, inverse=TRUE), col="chocolate", lwd=2)
207
 
%abline(h=0.5, v=0, lty="dashed")
 
202
%plot(y, logit(y, inverse = TRUE), type = "l", col = "limegreen",
 
203
%     xlab = "transformation", ylab = "p",
 
204
%     lwd = 2, las = 1, main = "Some inverse probability link functions")
 
205
%lines(y, probit(y, inverse = TRUE), col = "purple", lwd = 2)
 
206
%lines(y, cloglog(y, inverse = TRUE), col = "chocolate", lwd = 2)
 
207
%abline(h = 0.5, v = 0, lty = "dashed")
208
208
 
209
209
 
210
210