Learn R Programming

lava.tobit (version 0.4-6)

plotres: Plot distribution of standardized residuals

Description

Plot empirical (KM) and model-specific cumulative distribution function of standardized residuals

Usage

plotres(x,var=endogenous(x),
                    ylab="Cumulative Distribution Function",
                    xlab="Standardized residuals",
                    main,
                    ...)

Arguments

x
Model, lvmfit object
var
Character vector of (endogenous) variable names
ylab
Label of x-axis
xlab
Label of y-axis
main
Title of plot
...
Additional argument

Examples

Run this code
## Simulate data where (y01,y2)
## follows conditional bivariate normal distribution
## given covariate x. Instead of y01 we observe
## right censored version y2
n <- 200
m <- lvm(c(y01,y2) ~ x)
covariance(m) <- y01~y2
set.seed(1)
d <- sim(m,n)
d$cens1 <- rexp(n)
d$status1 <- with(d,y01<cens1)
d$y1 <- with(d, pmin(y01,cens1))

## Estimate model parameters
d$S1 <- with(d, Surv(y1,status1))
m <- lvm(c(S1,y2)~x); covariance(m) <- S1~y2
e <- estimate(m,d,control=list(trace=1))

## Plot cumulative distribution functions
par(mfrow=c(2,2)); plotres(e); plot(e)

Run the code above in your browser using DataLab