| stepblock | R Documentation |
Constructs an object containing a step function sampled over finitely many values.
stepblock(value, leftEnd = c(1, rightEnd[-length(rightEnd)] + 1), rightEnd, x0 = 0)
## S3 method for class 'stepblock'
x[i, j, drop = if(missing(i)) TRUE else if(missing(j)) FALSE else length(j) == 1, ...]
## S3 method for class 'stepblock'
print(x, ...)
## S3 method for class 'stepblock'
plot(x, type = "c", xlab = "x", ylab = "y", main = "Step function", sub = NULL, ...)
## S3 method for class 'stepblock'
lines(x, type = "c", ...)
value |
a numeric vector containing the fitted values for each block; its length gives the number of blocks |
leftEnd |
a numeric vector of the same length as |
rightEnd |
a numeric vector of the same length as |
x0 |
a single numeric giving the last unobserved sample point directly before sampling started, i.e. before |
x |
the object |
i, j, drop |
see |
type |
|
xlab, ylab, main, sub |
see |
... |
for generic methods only |
For stepblock an object of class stepblock, i.e. a data.frame with columns value, leftEnd and rightEnd and attribute x0.
For the purposes of this package step functions are taken to be left-continuous, i.e. the function jumps after the rightEnd of a block.
However, step functions are usually sampled at a discrete set of points so that the exact position of the jump is unknown, except that it has to occur before the next sampling point; this is expressed in the implementation by the specification of a leftEnd within the block so that every rightEnd and leftEnd is a sampling point (or the boundary of the observation window), there is no sampling point between one block's rightEnd and the following block's leftEnd, while the step function is constant at least on the closed interval with boundary leftEnd, rightEnd.
step, stepfit, family, [.data.frame, plot, lines
# step function consisting of 3 blocks: 1 on (0, 3]; 2 on (3, 6], 0 on (6, 8]
# sampled on the integers 1:10
f <- stepblock(value = c(1, 2, 0), rightEnd = c(3, 6, 8))
f
# show different plot types
plot(f, type = "C")
lines(f, type = "E", lty = 2, col = "red")
lines(f, type = "B", lty = 3, col = "blue")
legend("bottomleft", legend = c("C", "E", "B"), lty = 1:3, col = c("black", "red", "blue"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.