Mixed Effects Random Forest Model for Maintenance Cost Estimation in Heavy-Duty Vehicles Using Diesel and Alternative Fuels

Maintenance & Repair costs in heavy-duty trucks are an important component of the total cost of ownership. Due to the very limited availability of real-time data collected from medium- and heavy-duty vehicles using alternative fuels, this topic has not been well studied resulting in a very slow diffusion of alternative fuel vehicles in the market. This study focuses on collecting maintenance data related to diesel and alternative fuels such as natural gas and propane for the school bus, delivery truck, vocational truck, refuse truck, goods movement truck, and transit bus. The novelty of this work lies in identifying the mixed effects in the maintenance data and using a mixed-effect model for developing a single prediction model on clustered longitudinal data. A mixed-effect random forest machine learning model is trained on the maintenance data for estimating the average cost per mile. The model achieved an R<sup>2</sup> of 98.96% with a mean square error of 0.0089 <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>/mile for training and an R<sup>2</sup> of 94.31% with a mean square error of 0.0312 <inline-formula> <tex-math notation="LaTeX">$\$ $ </tex-math></inline-formula>/mile for the validation dataset. The prediction model is evaluated on each cluster of data and observed to perform well capturing the variations in each cluster very well. Furthermore, the performance of the mixed-effect random forest model is compared with the XGBoost ensemble model.


I. INTRODUCTION
Maintenance and Repair (MR) costs play an important role in the total cost of ownership for companies but is not well studied due to limited/lack of data on costs associated with the maintenance of advanced powertrain systems. The maintenance and repair costs reflect the cost of parts and labor for activities such as (i) periodic maintenance activities such as tire rotation, engine oil change, coolant inspection, etc., (ii) corrective maintenance such as replacing failed components including exhaust system, brakes, transmission, etc. (iii) preventative maintenance such as replacing tires, brakes, etc. before they fail. The important economic indicator for vehicles is the operating cost which includes maintenance The associate editor coordinating the review of this manuscript and approving it for publication was Wenbing Zhao . and repair costs, fuel costs, and the decreased value of the vehicle over time [1]. Thus, the diffusion of alternative fuels is affected by the lack of understanding of the total cost of ownership (TCO) which is affected by the maintenance & repair (MR) costs and the fuel costs. The motivation for this work is to promote the usage of alternative fuel heavy-duty vehicles by estimating and comparing the cost-per-mile which impacts the total cost of ownership as the vehicle ages reducing the greenhouse gas emissions.
The maintenance & repair costs of a vehicle are associated with the duty cycle based on the activity being performed by the vehicle. Most of the studies are analytics based on an individual vehicle type or just taking the change in cost for various components. The duty cycle, region of operation, season, and frequency of maintenance greatly affect the maintenance cost impacting the total cost of ownership.
Taking these factors into consideration while modeling the maintenance and repair costs is important. However, there is limited availability of real-world data on maintenance and repair costs for heavy-duty vehicles using alternative fuels such as compressed natural gas, liquefied propane gas, battery electric, and hydrogen fuel cells, while data related to conventional diesel trucks are available in abundance. Furthermore, the maintenance and repairs (MR) need for and the patterns for different truck types and technologies differ widely, and cannot be assumed that conventional diesel truck MR costs can be used to represent other alternative fuel heavy-duty trucks.
Hence, this study intends to bridge the gap in research by developing a generalized machine learning model that can be used to estimate the average cost per mile ($/mile) for various medium-and heavy-duty trucks using diesel or an alternative fuel such as natural gas or propane. This could be an important contribution as the model can be used by the consumer to estimate the maintenance and repair costs given the activity being performed by the truck, the region of operation, the mileage that is expected to hit, and the fuel type enabling procurement decisions. Most importantly, this study uses real-time and real-world historical maintenance and repair data collected from medium-and heavy-duty vehicles such as delivery trucks, goods movement, school buses, transit buses, refuse trucks and vocational trucks operated using diesel or natural gas, or propane gas. It is important to consider the activity, fuel type, region of operation, mileage, etc. since this could be the basis for new and improved public policy and marketing for alternative fuel vehicles. The prediction model helps estimate the average cost per mile throughout operation for a vehicle emphasizing factors that influence the choice of vehicle, fuel type, and the total cost of ownership (TCO). Due to the high imbalance in the data availability and variation in patterns of data among various activities and fuel types, regular machine learning models such as random forest, XGBoost, etc. do not generalize well. Hence, the significance of this work lies in developing a single model considering the mixed and random effects within and between the clusters of vehicle data that can be used to estimate the maintenance cost for vehicles with different activities and different fuel types. This contribution of this work includes: • Collection of real-time real-world maintenance data from medium-and heavy-duty vehicles performing different activities.
• Developed a single prediction model that can be used to predict cost-per-mile for medium-and heavy-duty vehicles with different duty cycles where the patterns in maintenance vary significantly.
• To our knowledge, this is the first time the mixed effects in the maintenance data is exploited to develop a generalized model.

II. LITERATURE REVIEW
Medium and Heavy-Duty vehicles are key to global transportation for activities such as goods movement, deliveries, services, etc. accounting for about 23% of greenhouse gas (GHG) emissions in the United States [2]. The classification of medium-and heavy-duty vehicles is based on the gross vehicle weight rating (GVWR). Class 7 heavyduty vehicles with GVWR 26001 -33000 pounds include furniture trucks, towing trucks, and transit buses whereas class 8 heavy-duty trucks with GVWR of greater than 33000 pounds include heavy semi-tractors, dump trucks, fire trucks, semi-sleepers, etc. [3]. Heavy-Duty trucks with internal combustion engines (ICE) powered by diesel are predominant resulting in increased pollution, climate change, and health impacts despite the zero-emission and clean air acts [4]. Studies have highlighted the depletion of fossil fuels by introducing acts for the reduction of fossil fuel and oil usage which in turn reduces air pollution [5]. To reduce the emissions from the transportation sector, alternative fuels [6] such as natural gas [7], propane, electric vehicles [8], and hybrid-electric powertrain systems [9] using batteries [10] were introduced as lower-emission or zero-emission strategies and lower cost of maintenance for the useful life of vehicles [11]. However, only 6% of alternative fuel vehicles are currently being used by global transportation fleets [12]. Various studies have been performed to understand the factors influencing the adoption of alternative fuel vehicles (AFVs) [13]. The main barrier is promoting the use of Alternative Fuel Vehicles (AFVs) is the public knowledge, opinion, unknown upfront and fuel costs, vehicle performance, and the total cost of ownership [14]. The total cost of ownership (TCO) for internal combustion, hybrid, and electric light-duty vehicles was studied by considering vehicle components based on a few assumptions [15]. A comparative analysis of costs associated with initial purchase, fuel or energy cost, maintenance and repair costs, and external factors such as emissions and air pollution are performed. A TCO model for battery electric vehicles is studied for promoting the diffusion of Battery Electric Vehicles (BEVs) [16]. The authors compared the results of BEVs with internal combustion engine vehicles (ICEVs) and observed that though the BEVs cost more than ICEVs, the energy and maintenance costs of BEVs are less than ICEVs. The maintenance cost for transit buses involving various maintenance costs was studied by California Air Resources Board (CARB) [17]. The paper addresses several questions associated with the total cost of ownership for buses that could be helpful for manufacturers. The TCO calculation for different-sized vehicles and powertrains was formulated based on the vehicle cost, fuel cost, maintenance and repair costs, depreciation, etc. [18]. Data analysis and review have been performed by authors for each of the factors such as vehicle depreciation, insurance premium, maintenance and repairs, taxes and fees, etc. attributing to the total cost of ownership for different size vehicle classes. Theoretical frameworks have been developed for promoting the diffusion of alternative fuel vehicles [19]. Factors affecting the adoption of alternative fuel vehicles based on qualitative and quantitative techniques based on factors such as economic VOLUME 11, 2023 considerations, technology, infrastructure, policies, environmental concerns, etc. are studied. Despite these studies, the adoption of alternative fuel vehicles has not reached the mark expected. Most of the studies till now rely on simulations or theoretical frameworks taking assumptions or a vehicle type into account. Development of a model based on the historical maintenance and repair data to estimate the maintenance cost which highly influences the TCO would be a feasible solution that can be used by consumers and policymakers.
With Industry 4.0 technologies, Artificial Intelligence (AI) has gained success in a wide range of applications in the automotive and transportation sector. These technologies enable the collection of vast data and making use of the data for studying difficult tasks or time-consuming to perform using existing methods. Studies have applied machine learning algorithms for predictive maintenance [20], [21], failure of components in trucks [22], [23], estimating remaining useful life [24], [25], emissions and fuel efficiency [26], and anomaly detection [27]. Studies using analytical models are used to estimate the maintenance and repair costs at the component level for heavy-duty trucks using battery electric and fuel cells [28]. An initial study of this has been performed using data-based machine learning methods to compare the cost-per-mile in delivery trucks using diesel and natural gas fuels [29]. The goal of this work is to use the data-based machine learning approach to estimate the cost-per-mile for medium-and heavy-duty vehicles with different duty cycles and fuel types.

III. METHODOLOGY
The duty cycle of heavy-duty vehicles affects the maintenance cost associated. This study utilizes a large volume of data collected from different medium-and heavy-duty trucks using different fuel types such as diesel, natural gas, propane, and electric vehicles with different duty cycles performing activities such as goods movement, delivery, school bus, refuse, and vocational trucks. The data collection has been performed following the technical proposal by the West Virginia University Center for Alternative Fuels Engines and Emissions (WVU CAFEE) and the United States Department of Energy (US DOE). The data is collected in partnership with Clean City Coalitions to reach fleet companies that operate AFVs. The distribution of data grouped by fuel type and the activity performed is shown in Figure 1.
The data has been pre-processed to remove duplicate records and missing values. A Z-Score method is used to calculate the interquartile range (IQR) for the target variable. Based on the box plots for IQR, a careful inspection of data points outside the whiskers is performed to determine whether the data points should be considered an outlier. The feature correlation is then performed on the pre-processed data to determine the association between features. The data used for modeling has the features mentioned in Table 1.
The maintenance and repair data are categorized into 3 maintenance types: periodic, preventative, and corrective  • Periodic maintenance is planned or regularly scheduled maintenance such as engine oil change, tire rotation, engine inspection, and other routine work. These are essential to have a longer lifetime for vehicle components.
• Preventative maintenance is unanticipated repairs such as minor fixings, replacing small parts such as headlights, etc.
• Corrective maintenance is a significant portion of overall maintenance and repair costs. These are major fixings such as the replacement of transmission, and fuel system which cost significantly over the lifetime of the vehicle.
The total cost for maintenance and repair includes the cost of parts and the labor cost. Hence the cost-per-mile is calculated as The data being used for this analysis is clustered longitudinally where random effects exist between subgroups of activity and fuel types. Furthermore, the maintenance of each vehicle is performed at different intervals of time varying in the total miles of operation for vehicles. For example, a few fleet managers might perform more periodic maintenance whereas a few companies might not perform regular maintenance resulting in more corrective maintenance. Hence the time interval between maintenance for a given vehicle is not regular resulting in repeated or longitudinal clustered data. By carefully analyzing the data, fixed and random effect features are identified. The features varying within a cluster such as Mileage, TBM, VAge, and MilesPerDay are identified to be random effect features whereas MaintenanceYear and Region are considered as both fixed and random effect features as they tend to have a constant value for some clusters. Along with the input features a cluster id is passed as input for each cluster.

A. MIXED EFFECT MODELS
The goal of this research is to develop a generalized model to capture the mixed effects of heavy-duty vehicle maintenance data. Most of the machine learning algorithms assume the training data to be i.i.d., which is commonly violated in longitudinal data where there is a high correlation between subgroups. The activity-based data analysis and graphical analysis have been performed previously on the data collected using an Excel worksheet and MATLAB [30]. The distribution of residual and random effects matters for the accurate and unbiased estimation of the model. The fixed-effect model works well when studies include analysis of identical data, and the goal is to model the identified population rather than generalize for other populations. On the other hand, the random effects are performed on data from a series of experiments where the subjects differ impacting the results to generalize well for various scenarios [31]. Mixed-effects regression models estimate fixed and random effects in a single model.
Mixed effects regression models are used to model data that has group-level and global trends in data. Linear Mixed Effect Models are extended linear models introduced to capture the dependencies using random effects and effects between covariates and using fixed effects with correlated multilevel longitudinal data [32]. The typical linear model is represented as y = X β + e, where X β represents fixed term and e represents error. An incorrect specification of random effects in linear models has consequences on the maximum likelihood estimator [33]. The mixed effects model takes into account a few assumptions such as the validity of the model, linear relationship between predictor and response, independent data points, and missing data randomly [32].
In longitudinal clustered data, the variability within the group or between groups affects the outcome. One way of handling such data is to aggregate the individual group data, which then becomes independent. However, this approach doesn't consider all data missing the key patterns within the group. Another approach is analyzing each group at a time resulting in an individual model for each group and does not take information from the global population. Linear Mixed Effect Models are in between making the tradeoff between the two alternative approaches. The key idea of the mixed model is to take into consideration both the fixed and random effects. Fixed effects are represented by a parameter that is fixed without variation whereas random effects are parameters that are random variables like noise in linear regression.
Assume that the true population β is modeled as a normal random variable with mean µ and standard deviation σ , that is, β ∼ N (µ, σ ). Then linear mixed models are represented as where y i is n i ×1 vector containing responses for n i observations in cluster i, X i is n i ×p matrix of fixed-effects covariates, β is an unknown vector of fixed effects with dimensions p×1, Z i is n i ×q matrix of random-effects covariates, b i is q×1 unknown vector of random effects for the cluster i, and e i is n i ×1 vector of errors. The total number of observations is N = n i=1 n i . The random part, b i Z i , is assumed linear. The vectors b i and e i are assumed to be independent and normally distributed with zero mean and covariance matrices are represented by D and R i , respectively.
In this work, mixed-model regression analysis is performed which deals with longitudinal data having within and between group variances. The approach includes both fixed effects which define overall change over time and random effects accounting for variability among clusters. The Expectation Maximization (EM) algorithm is used to iteratively learn the maximum likelihood and the random effect coefficients. However, this requires the functional form to be specified, which is especially difficult for complex longitudinal clustering. To address this using a tree-based method, a semiparametric mixed model with fixed effects non-parametric tree model, and a random effects part is proposed [34]. A similar approach named mixed effect regression trees (MERT) is introduced in [35].
Random forests are an ensemble model that combines individual decision trees [36] to improve the predictive capability of the model and reduces the variance [37]. The idea of bagging [38] is applied to the random forest for bootstrap aggregation on de-correlated trees controlled by several trees and the number of variables per split. Each de-correlated tree in the forest aims to minimize the prediction mean square error (MSE) resulting in the random forest regression function in minimizing the point-wise mean square error (MSE). For a regression model, the squared error loss is the conditional mean of the target variable given the data. However, the random forest model builds on the assumption that observations are independent and ignores the underlying assumptions such as linearity and distribution of data. Ignoring the correlation in data results in lower pointwise predictions. Therefore, the fixed effects part of MERT was replaced with random forests to develop mixed effects random forests (MERF) [39]. The advantages of random forest and linear random effects have been combined to develop a mixed-effects random forest model given by the form: where all the quantities are defined as in Eq.2 except the fixed effect part X i β in Linear Mixed Effect Model is replaced by the random forest estimated function f (X i ). An expectationmaximization (EM) algorithm [40], [41] is used to iteratively fit the MERF by optimizing one parameter while keeping others fixed until convergence is reached. The EM algorithm for fitting MERF is as follows: 1) Start with default values for variance (σ i ), random effects coefficient (b i ), and the diagonal matrix of unknown variance (D). 2) Calculate the response variable (y * i(r) ), the estimated function (f (x ij ), and the random effects coefficient (b i(r) ). a) Calculate response variable, y * i(r) = y i − Z ibi . b) Estimate fixed effects by taking bootstrap samples (y * ij , x ij ) using the random forest. c) Find the random effects coefficientb i at the cluster, i using the estimatedf (x ij ) from the random forest. 3) Compute varianceσ 2 andD from estimated residuals and random effects respectively. 4) Repeat steps 2 and 3 until convergence. The convergence of the MERF algorithm is monitored using generalized log-likelihood (GLL) given by: The MERF assumes the random effects term to be correct for estimating the forest function and assumes out-of-bag predictions from the forest to be correct for estimating the random effects part [42]. The unused observations from the forests sub-tree are used in Out-of-Bag predictions [37]. The typical implementation workflow is shown in Figure 2. Once the model is fitted into data, it can be used to make predictions on known clusters as well as new clusters that are not seen during training. For the known cluster data, the predictions are given by:ŷ = f (X i ) + b i Z i where for new clusters the predictions only include fixed effects given by: y = f (X i ).

IV. RESULTS AND DISCUSSION
The qualitative data collected from different fleet management companies are used for building a MERF model. The number of vehicles per activity per fuel type in the data collected is shown in Table 2. The entire dataset is divided into the train, validation, and test datasets. Data related to one vehicle per cluster is randomly selected based on the cluster id to form a test dataset. This test dataset is not seen by the model during the training process and is used to evaluate the model performance once the model is trained completely. To test the model on a new cluster that has not been presented for training, transit bus data is used. There are only two transit buses with very few data points, hence the transit bus cluster has not been used for training. The remaining data are split into 70% and 30% randomly based on the vehicle unit number to form train and validation datasets respectively. The training dataset is used to fit the model and the validation dataset is used to evaluate the model performance at every iteration. The cost-per-mile continuous feature is the target variable with the remaining features being input variables. The MERF model is trained for 50 iterations with the number of trees being 50 in the random forest. The generalized log-likelihood during the training of the MERF model over each iteration is shown in Figure 3. From the plot, the model converges by the 50th iteration.
Along with the GLL, the mean square error on the validation dataset is shown in Figure 4. Figure 3 shows the maximization of likelihood where the probability of observing the target value is increased by adjusting the parameters of the MERF model. As the likelihood increases, the error in the prediction decreases by identifying the parameters that make a good fit for the model based on the data correlation  The trained model also holds the distribution of b i learned over iterations. The b i is different for each cluster but is drawn from the prior data distribution. The distribution of learned b i is shown in Figure 5.
Once the model is trained, the random forest model f (X )along with learned b i is used to predict the cost-permile for the test dataset. The evaluation metrics coefficient of determination (R 2 ), mean absolute error (MAE) and mean square error (MSE) for each cluster in the test dataset are presented in Table 3. Sample data from each cluster are used to test the model performance. The results indicate that the MERF model generalized well for all clusters in the test dataset. For a few clusters such as diesel -school bus, and propane -vocational the model performed reasonably due to very few data points and large variations of data within the cluster. For a natural gas-transit bus cluster that has

A. SCHOOL BUS
The summary of test data for a diesel and natural gas school bus operated in California and a propane school bus operated in Colorado is presented in Table 4. The diesel school bus had more periodic maintenance performed with few preventative maintenance and one corrective maintenance related to the engine and transmission performed. The natural gas school bus vehicle has recorded preventative and corrective maintenance related to chassis, engine and transmission, exhaust and aftertreatment, and a few periodic maintenances. The engine and transmission corrective maintenance in the natural gas vehicle has incurred high maintenance costs after 125,000 mileage. The propane school bus underwent more corrective maintenance and preventative maintenance related to the engine and transmission after 30,000 miles with frequent periodic maintenance. The corrective and periodic maintenance of the engine and transmission involved higher VOLUME 11, 2023   maintenance costs but lower than the cost incurred for tire and break.
The comparison of average cost per mile over the duration for diesel, natural gas, and propane school bus data is shown in Figure 6. The diesel vehicle showed the highest average cost per mile with just one corrective maintenance related to the engine & transmission at around 70000 miles as the periodic maintenance of the engine & transmission, fuel system was costly. Natural gas vehicles showed an increasing trend in the average cost per mile as the duration of operation increased. However, the observed values are for mileage ranging from 101,000 -160,000 miles. Although propane vehicles underwent several preventative and corrective maintenance before hitting 52000 miles, the average cost-per-mile is observed to be lower than diesel and natural gas vehicles.

B. DELIVERY TRUCK
The summary of test data for a diesel and propane delivery truck operated in South Carolina and a natural gas delivery truck operated in Pennsylvania has been presented in Table 5. The diesel delivery truck underwent a similar number of periodic and corrective maintenances with a couple of preventative maintenances performed throughout the operation. The corrective maintenance on the chassis had a total cost much higher after the vehicle recorded mileage greater than 104k miles with one major engine & transmission maintenance at a mileage of around 68k. Engine & transmission preventative maintenance has a total cost of 10 times more than tire & brake preventative maintenance. The cost of periodic maintenance for tire & brake is 2 to 3 times higher than chassis whereas the periodic maintenance cost for engine & transmission is lower than all. Since the natural gas delivery truck has operated for a very high mileage of 460k, it has recorded a high number of corrective and periodic maintenance with few preventative maintenances. The chassis has less periodic maintenance costs followed by engine & transmission and then tire & brake. But the preventative maintenance costs for engine & transmission are higher than tire & brake. The fuel system has the lowest corrective maintenance costs among all parts. The tire & brake components have seen corrective maintenance costs more than double after 113k miles whereas exhaust & emissions corrective maintenance at 160k miles is higher than the cost above 330k miles. The engine & transmission went through much corrective maintenance with one maintenance at 360k miles incurring 10 times higher cost than the maximum of other corrective maintenance costs on the same part. The corrective maintenance cost for the chassis has been observed to be more than doubled every 100k miles after 100k miles. The periodic maintenance for the chassis had constant costs throughout the operations. For tire & brake, the periodic maintenance costs have increased and for engine & transmission, the mileage below 13k and above 74k had a higher value. One-third of the corrective maintenance for the engine & transmission had higher costs at various mileages. The preventative maintenance for this vehicle was only performed for the engine & transmission with increasing maintenance costs.
The comparison of average cost per mile over the duration for diesel, natural gas, and propane delivery data is shown in Figure 7. The natural gas delivery truck showed the lower average cost per mile even with the highest mileage accumulated in 5 years. The trend shows an increase in value throughout the operation. A similar increasing trend is observed for diesel delivery trucks but with a higher average cost per mile. The propane vehicle projected a nearly similar average cost per mile every year except the first year.

C. VOCATIONAL TRUCK
The summary of test data for a diesel vocational truck operated in Ohio, a natural gas vocational truck operated in California, and a propane vocational truck operated in Rhode Island is presented in Table 6. The diesel vocational truck recorded a high number of corrective and preventative maintenance related to the chassis and engine & transmission for a total of 6000 miles over 2 years. The corrective maintenance  cost for the engine & transmission was very high at 3k miles whereas for the chassis both the corrective maintenance and preventative maintenance costs had a fluctuating trend. The natural gas vocational truck for 3 years had frequent periodic maintenance related to the chassis with corrective maintenance related to the chassis and fuel system. The corrective maintenance costs are much higher compared to periodic and preventative maintenance costs. The propane vocational had periodic maintenance every year with one corrective maintenance related to the engine & transmission which has 3.5-4 times lower maintenance cost than periodic maintenance.
The comparison of average cost per mile over the duration for diesel, natural gas, and propane vocational truck data is shown in Figure 8. The average cost-per-mile for a diesel vehicle is recorded as very high for a mileage range of 1000-6000 miles with an increasing trend. A similar increasing trend is observed in a natural gas vocational truck for mileage range 5000-9000. The propane vocation trucks have lower average cost-per-mile even with higher mileage of 13500-50000 miles.

D. REFUSE TRUCK
The summary of test data for a diesel refuse truck operated in Ohio and a natural gas refuse truck operated in California is presented in Table 7. The diesel refuse truck went through 3 corrective maintenance related to chassis, tire & brake before the truck records 7913 miles with one preventative maintenance at 2750 miles. The natural gas refuse truck  had many corrective maintenances related to chassis, tire & brake, and engine & transmission most of the corrective maintenances were observed during periodic and preventative maintenance. The maintenance cost for all types of maintenance had a fluctuating total cost with a few higher costs at some mileage.
The comparison of average cost per mile over the duration for diesel and natural gas refuse truck data is shown in Figure 9. The diesel refuse has less average cost-per-mile with mileage ranging from 5000-8000 miles with an increase in value over the years. The estimated values for natural gas, however, are very high as the vehicle has data with mileage greater than 42000 miles.

E. GOODS MOVEMENT
The summary of test data for a diesel and a natural gas goods movement truck operated in California is presented in Table 8. The diesel goods movement truck has corrective maintenance related to the engine & transmission, chassis, and exhaust & emissions after recording 114k miles observed during regular periodic maintenance. Like refuse trucks, the natural gas goods movement truck also had many corrective maintenances related to chassis, tire & brake, engine & transmission, and fuel system. The number of corrective maintenance on this vehicle is almost equal to the number of periodic and preventative maintenance together.
The comparison of average cost per mile over the duration for diesel and natural gas goods movement truck data   is shown in Figure 10. The natural gas goods movement truck had a decreasing average cost-per-mile throughout the operation as mileage increased from 30k to 152k whereas the diesel goods movement truck had similar value throughout the operation with mileage of 32.7k -296k.

F. TRANSIT BUS
Since there is no data for transit buses using diesel and propane fuels, the transit bus data is not presented for training the model during the training or validation phases. The summary of maintenance data for a natural gas transit bus operated in California is presented in Table 9. The natural gas transit bus has operated for 310k miles over 6 years.  The vehicle had comparably a smaller number of corrective maintenance due to frequent periodic and preventative maintenance performed. The total cost for periodic maintenance of the chassis was higher than the cost for the engine & transmission and tire & brake. The average corrective cost for the engine & transmission is almost equal to the average corrective cost for the tire & brake and half the corrective cost for the fuel system.
Since there is no data related to other fuels, the predicted average cost-per-mile for this vehicle is compared with the average cost-per-mile for the original test data as shown in Figure 11. This shows how well the model is generalized to unseen cluster data and the performance of the model. The higher average cost-per-mile in the initial year of operation is due to the replacement of the fuel system. The vehicle has seen an increasing trend in the average cost-per-mile for maintenance done.
Overall, most corrective maintenances are identified during periodic or preventative maintenance. The total cost incurred for maintenance based on the maintenance type, part of the truck, etc. may not always have a trend but the average cost-per-mile calculated using the total cost and the mileage of the vehicle gives interesting insights for each of the truck types. For example, though the natural gas delivery truck had much corrective maintenance, the average cost-permile is less whereas the natural gas refuse truck went through a higher number of corrective maintenance resulting in a higher average cost-per-mile. From the comparison plots, it is observed that the school buses and vocational trucks which have stop-and-go activity operated at lower speeds have lower average cost-per-mile using propane fuel compared to natural gas and diesel whereas the delivery trucks have lower average cost-per-mile using natural gas. The refuse and goods movement trucks using diesel fuel have lower average cost-per-mile.

G. COMPARISON OF MODELS
To understand the generalization performance of the mixed effect random forest model, an XGBoost [43] machine learning algorithm is implemented using the same set of train, validation, and test datasets. XGBoost is an optimized gradient-boosting ensemble machine learning algorithm. Based on the hyper-parameter tuning, an XGBoost model with a learning rate of 0.0001 and tree_depth of 10 is trained using train and validation datasets. The model achieved an R 2 of 97.1% with an MAE of 0.0109 $/mile and MSE of 0.0178 $/mile on the training dataset and an R 2 of 60.82% with an MAE of 0.7201 $/mile and MSE of 1.4891 $/mile on the validation dataset. The final trained model is then evaluated on the entire test dataset. The performance of mixed effect random forest on the entire dataset is compared with the performance of the XGBoost model as shown in Table 10. The lower coefficient of determination (R 2 ) and the higher error values (MAE, MSE) of XGBoost on unseen test data indicates the poor generalization of the model due to high imbalance in the dataset and the large variation in the patterns of data among clusters. This shows the ability of the mixed effect random forest model in generalizing well for clustered longitudinal data which contains inter and intra-cluster variations.

V. CONCLUSION
Maintenance cost is considered an important factor for the total cost of ownership while purchasing a vehicle as the downtime and maintenance of the fleet costs a lot for fleet companies. Recently with the clean air act, the government is promoting the use of alternative fuel vehicles as they provide soot-free emissions. However, the lack of understanding of how the maintenance cost associated with alternative fuel vehicles changes over time is making fleet companies opt for diesel vehicles as diesel vehicles are known to be robust for a long time. The studies related to maintenance costs for alternative fuel vehicles have been a challenge due to the lack of availability of data. In this study, WVU in collaboration with fleet management companies has collected large volumes of data related to diesel and alternative fuels performing various tasks such as school buses, delivery trucks, vocational trucks, refuse trucks, transit buses, and goods movement.
Regular machine learning models do not generalize well for real-world complex data involving clustered longitudinal data. The maintenance data collected is complex as the activity performed by each truck involves a different duty cycle impacting the maintenance and the performance of vehicles differently. Hence each of the diesel, natural gas, and propane fuel types has different clusters of data among them associated with the truck activity type. Furthermore, different fleet companies maintain vehicles differently further making the pattern more complex.
To address the challenge and fill the knowledge gap, a mixed effect random forest (MERF) model is developed to capture the complex patterns within the group and between groups taking the overall population distribution into account. The model is fitted using the EM algorithm, allowing us to learn fixed effects and random effects. The model is evaluated on the unseen test data from each cluster and observed to perform well giving the predicted values close to actual values for most of the cases. For scenarios where there is large variation within the cluster, the model seems to perform reasonably. The goal of this study is to develop a generalized model that could capture the random effects in data rather than having an individual model for different activity types using different fuel types for which large volumes of data may not be available. Based on the performance metric achieved by the MERF model on the test dataset indicate that the model is generalized well for clusters seen during the training process as well as for the clusters not seen during the training. Given the fuel type, activity, region of operation, etc., the model predicts the average cost per mile as the age and total miles of operation for truck increases helping the fleet management companies to make procurement decisions. In the future, this work could be extended to include the duty-cycle information based on the activity could give more robust results.