library(ggplot2)
A company with a fleet of trucks faces increasing maintenance costs as the age and mileage of the trucks increases.
It is obvious that the cost of maintaining the truck will increase with age and mileage. But I would beneficial if we could set a maintenance cost as a boundary to determine the time for the disposal of the truck where its operation dosn’t meet desire revenue. Therefore, let’s take the assumption that maintenance cost of trucks is consist of some fixed cost and some variable cost.
variable cost: Load, mpg, age, and repairs, Fixed cost: routine Services.
Since mpg and repairs are indicators of aging, and operation cost we could neglect the following variables: load, and age.
Which might be considered as constants initially? Price of the truck
Can you identify any submodels you would want to study in detail?
One of the submodel would be finding the maintenance cost based on repairs per mileage as variable cost and routine services as fixed cost MC=f(repairs cost/mileage + routine services cost)
Repairs coat, mpg, routine services cost, and revenue.
In problems 7-12, determine whether the data set supports the stated proportionality model.
To determine whether y and x^3 are proportional the relationship between the two variable must produce a straight line.
Since the relationship between y and x^3 is not and ideal relationship, taking two points on the line will not produce a very accurate slope that reproduce the function of y accurately and precisely.
We could use different techniques to find the best fits of y, but for this simple problem we could use the linear regression model build in r to solve for k.
df <- data.frame(x=c(1,2,3,4,5,6,7,8,9,10),y=c(0,1,2,6,14,24,37,58,82,114))
df$x3<-df$x^3
fits <- lm(y ~ x3, data = df)
summary(fits)
##
## Call:
## lm(formula = y ~ x3, data = df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.4200 -0.4326 0.1844 0.5571 0.7949
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.7074611 0.3196464 -2.213 0.0578 .
## x3 0.1140743 0.0007186 158.736 2.78e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7411 on 8 degrees of freedom
## Multiple R-squared: 0.9997, Adjusted R-squared: 0.9996
## F-statistic: 2.52e+04 on 1 and 8 DF, p-value: 2.775e-15
plot(df$x3,df$y)
abline(fits)
As shown above the scatter point form a straight line graph.
Let’s test the model using the K and y intercept from the modle and then plot the result.
k=summary(fits)[4]$coefficients[2][1]
y_intercept<-summary(fits)[4]$coefficients[1][1]
df$y2<-k*df$x3 + y_intercept
fy=paste0("y_pre = ",round(k,4),"x^3")
ggplot() +
geom_line(data = df, aes(x = x, y = y, colour = "red")) +
geom_line(data = df, aes(x = x, y = y2, colour ="green"))+
xlab('x') +
ylab('y & y_prediction')+
ggtitle(fy)+
scale_color_discrete(name = "Y series", labels = c("Y", "Y_pre"))
Visually, by observing the graph, we could determine that the k value and the y intercept are accurate and precise and the model prediction is reproduced the actual data points.