I am new to statistics and to categorical variables. I need to predict the cost based on several variables and it happened that all of my variables are categorical. I tried doing a linear regression between my response (actual cost $) and the following predictor variables:estimated cost($), county, month, and project type. I noticed then under the following linear model
lm = lm(actual cost ~ estimated cost)
R-squared is 97%. However, I am looking for a degree of accuracy where 50 % of the projects should be within 5% of the estimated:
sum(abs((lm$fitted.values - actual cost)/actual cost))/nrow(data) >=50%
Under the simple model, although R squared is high, but only 30% of the projects have a 5% or less level of accuracy. I started adding more predicted variables and I noticed that adj R squared does not increase much (98%), but 48% of the project satisfy the required level of accuracy under the following model:
lm = lm(actual cost ~ estimated cost + county + month + work type)
county: 78 levels month:12 levels qork type: 6 levels
summary(lm) shown that not all p-values of the levels are significant. I then did a stepwise, and the selected model contained the estimated cost, the 12 months and the 5 work types. However, on 38% accuracy was achieved.
I don't know if the linear regression is correct, or if you guys can provide me with the resources to read more about regression with categorical varaibles with large number of levels. Can I do stepwise with categorical variables? Why the R squared did not increase much? What other analysis can be performed.
I would greatly appreciate any help on this issue!!