Learn R Programming

vein (version 0.8.9)

age: Applies a survival rate to numeric new vehicles

Description

age returns survived vehicles

Usage

age(x, type = "weibull", a = 14.46, b = 4.79, agemax, verbose = FALSE)

Arguments

x

Numeric; numerical vector of sales or registrations for each year

type

Character; any of "gompertz", "double_logistic", "weibull" and "weibull2"

a

Numeric; parameter of survival equation

b

Numeric; parameter of survival equation

agemax

Integer; age of oldest vehicles for that category

verbose

Logical; message with average age and total numer of vehicles regions or streets.

Value

dataframe of age distrubution of vehicles

See Also

Other age: age_hdv(), age_ldv(), age_moto()

Examples

Run this code
# NOT RUN {
vehLIA <- rep(1, 25)
PV_Minia <- age(x = vehLIA)
PV_Minib <- age(x = vehLIA, type = "weibull2", b = 11, a = 26)
PV_Minic <- age(x = vehLIA, type = "double_logistic", b = 21, a = 0.19)
PV_Minid <- age(x = vehLIA, type = "gompertz", b = -0.137, a = 1.798)
plot(PV_Minia, type = "b", pch = 16)
lines(PV_Minib, type = "b", pch = 16, col = "red")
lines(PV_Minic, type = "b", pch = 16, col = "blue")
lines(PV_Minid, type = "b", pch = 16, col = "green")
legend(x = 20, y = 0.85,
      legend = c("weibull", "weibull2", "double_logistic", "gompertz"),
      col = c("black", "red", "blue", "green"),
      lty=c(1,1),
      lwd=c(2.5, 2.5, 2.5, 2.5))
      #lets put some numbers
vehLIA <- c(65400, 79100, 80700, 85300, 86700, 82000, 74500, 67700, 60600, 62500,
84700, 62600, 47900, 63900, 41800, 37492, 34243, 30995, 27747, 24499, 21250,
18002, 14754, 11506, 8257)
PV_Minia <- age(x = vehLIA)
PV_Minib <- age(x = vehLIA, type = "weibull2", b = 11, a = 26)
PV_Minic <- age(x = vehLIA, type = "double_logistic",  b = 21, a = 0.19)
PV_Minid <- age(x = vehLIA, type = "gompertz", b = -0.137, a = 1.798)
plot(PV_Minia, type = "b", pch = 16)
lines(PV_Minib, type = "b", pch = 16, col = "red")
lines(PV_Minic, type = "b", pch = 16, col = "blue")
lines(PV_Minid, type = "b", pch = 16, col = "green")
legend(x = 20, y = 80000,
      legend = c("weibull", "weibull2", "double_logistic", "gompertz"),
      col = c("black", "red", "blue", "green"),
      lty=c(1,1),
      lwd=c(2.5, 2.5, 2.5, 2.5))
# }

Run the code above in your browser using DataLab