| stepfit {stepR} | R Documentation | 
Fitted step function
Description
Constructs an object containing a step function fitted to some data.
Usage
stepfit(cost, family, value, param = NULL, leftEnd, rightEnd, x0,
  leftIndex = leftEnd, rightIndex = rightEnd)
## S3 method for class 'stepfit'
x[i, j, drop = if(missing(i)) TRUE else
  if(missing(j)) FALSE else length(j) == 1, refit = FALSE] 
## S3 method for class 'stepfit'
print(x, ...)
## S3 method for class 'stepfit'
plot(x, dataspace = TRUE, ...)
## S3 method for class 'stepfit'
lines(x, dataspace = TRUE, ...)
## S3 method for class 'stepfit'
fitted(object, ...)
## S3 method for class 'stepfit'
residuals(object, y, ...)
## S3 method for class 'stepfit'
logLik(object, df = NULL, nobs = object$rightIndex[nrow(object)], ...)
Arguments
| cost | the value of the cost-functional used for the fit: RSS for family  | 
| family | distribution of the errors, either  | 
| value | a numeric vector containing the fitted values for each block; its length gives the number of blocks | 
| param | additional paramters specifying the distribution of the errors, the number of trials for family  | 
| 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  | 
| leftIndex | a numeric vector of the same length as  | 
| rightIndex | a numeric vector of the same length as  | 
| x,object | the object | 
| y | a numeric vector containing the data with which to compare the fit | 
| df | the number of estimated parameters: by default the number of blocks for families  | 
| nobs | the number of observations used for estimating | 
| ... | for generic methods only | 
| i,j,drop | see  | 
| refit | 
 | 
| dataspace | 
 | 
Value
| stepfit | an object of class  | 
| [.stepfit | an object of class  | 
| fitted.stepfit | a numeric vector of length  | 
| residuals.stepfit | a numeric vector of length  | 
| logLik.stepfit | an object of class  | 
| plot.stepfit,plot.stepfit | the corresponding functions for  | 
See Also
stepblock, stepbound, steppath, stepsel, family, "[.data.frame", fitted, residuals, logLik, AIC
Examples
# simulate 5 blocks (4 jumps) within a total of 100 data points
b <- c(sort(sample(1:99, 4)), 100)
p <- rep(runif(5), c(b[1], diff(b))) # success probabilities
# binomial observations, each with 10 trials
y <- rbinom(100, 10, p)
# find solution with 5 blocks
fit <- steppath(y, family = "binomial", param = 10)[[5]]
plot(y, ylim = c(0, 10))
lines(fit, col = "red")
# residual diagnostics for Gaussian data
yg <- rnorm(100, qnorm(p), 1)
fitg <- steppath(yg)[[5]]
plot(yg, ylim = c(0, 10))
lines(fitg, col = "red")
plot(resid(fitg, yg))
qqnorm(resid(fitg, yg))