I believe this question is very simple, but I can't seem to google it right.
I have data on the efficiency o vehicles (Km/L) for several different routes, vehicles, models and several other categorical variables. Here some example data in R:
set.seed(1) reprexData = data.frame( "vehicleEfficiency" = rnorm(20,mean=2.5,sd=0.6), "vehicleMake" = sample(c("Volvo","Volkswagen","Audi","Mercedes"),20,replace=T), "driverClass" = sample(c("A","B",20,replace=T)), "company" = sample(c("C1","C2"),20,replace=T), "route" = sample(c("X->B","X->A","Y->C"),20,replace=T) )
I know that the routes are very different: some are uphill, some are downhill and others are flat. So I expect that the efficiency should change from route to route.
I want to test the influence of each other variable on the efficiency independently, while controlling for the different routes. Can I do something like this:
mod = lm(vehicleEfficiency ~ vehicleMake + driverClass + company + route,data=reprexData) anova(mod)
And use the p-values from
anova to determine significance? Am I already controlling for routes by including it in the model?
Or do I need to separate the data by route and test for significance on each route independently?