# NOT RUN {
# load data
data("Eredivisie")
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)
# squared values of age
Eredivisie$AgeSq <- Eredivisie$Age^2
# simple regression model of log market value on age
fit1 <- regression(logMarketValue ~ Age, data = Eredivisie)
fit1 # print LaTeX table
plot(fit1, which = "scatter") # diagnostic plot
# add a squared effect for age
fit2 <- regression(logMarketValue ~ Age + AgeSq,
data = Eredivisie, labels = 2)
fit2 # print LaTeX table
plot(fit2, which = "scatter") # diagnostic plot
# more complex models with model comparison
fit3 <- regression(logMarketValue ~ Age + AgeSq,
logMarketValue ~ Age + AgeSq + Contract +
Foreign,
logMarketValue ~ Age + AgeSq + Contract +
Foreign + Position,
data = Eredivisie, labels = 2:4)
print(fit3, change = TRUE) # print LaTeX table
plot(fit3, which = "histogram") # diagnostic plot
# }
Run the code above in your browser using DataLab