head(jobshop)
X totalcost units goal.sd weight stamp chisel detail rush labor cost lost manager room.temp music shift mach.hrs plant breakdown rework
1 1 90751.53 423 0.1 4.48 4 7 No Yes 1.47 4.71 0.8317 Alan 74.71 None 2 1.277 Old 1 0.114
2 2 100456.65 554 1.0 4.35 2 3 Yes No 1.26 4.82 0.4951 Devon 75.37 Pop 1 1.317 New 0 0.000
3 3 128574.01 607 0.5 5.00 2 4 No No 1.20 5.32 0.5584 Beatrice 75.29 None 1 1.071 Old 0 0.101
4 4 73996.67 347 1.0 5.39 2 4 No No 1.46 5.44 0.4562 Ebrahim 75.27 Soul 1 1.375 New 0 0.000
5 5 98494.52 510 1.0 4.80 2 4 No No 1.23 4.98 0.5018 Ebrahim 75.31 Soul 1 1.455 New 0 0.000
6 6 66745.85 419 0.5 3.99 2 4 No No 1.21 4.60 0.4100 Ebrahim 75.38 Soul 1 1.065 New 0 0.000
my.fit <-lm(totalcost ~ units + goal.sd + weight + stamp + chisel + detail + rush + labor + cost + lost + manager + room.temp + music + shift + mach.hrs + plant + breakdown + rework, data=jobshop)
goalfact <- as.factor(my.fit$goal.sd)
stampfact <- as.factor(my.fit$stamp)
chiselfact <- as.factor(my.fit$chisel)
detailfact <- as.factor(my.fit$detail)
rushfact <- as.factor(my.fit$rush)
mgrfact <- as.factor(my.fit$manager)
shiftfact <- as.factor(my.fit$shift)
plntfact <- as.factor(my.fit$plant)
summary(my.fit)
Call:
lm(formula = totalcost ~ units + goal.sd + weight + stamp + chisel +
detail + rush + labor + cost + lost + manager + room.temp +
music + shift + mach.hrs + plant + breakdown + rework, data = jobshop)
Residuals:
Min 1Q Median 3Q Max
-118706 -2007 286 2766 18836
Coefficients: (5 not defined because of singularities)
Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.065e+05 1.493e+04 -7.129 3.73e-12 ***
units 1.913e+02 2.579e+00 74.151 < 2e-16 ***
goal.sd -1.519e+03 1.208e+03 -1.257 0.20946
weight 6.554e+03 5.787e+02 11.326 < 2e-16 ***
stamp -1.412e+03 7.177e+02 -1.967 0.04972 *
chisel 1.120e+02 5.057e+02 0.221 0.82487
detailYes 6.880e+02 1.071e+03 0.643 0.52079
rushYes 8.511e+02 9.893e+02 0.860 0.39006
labor 1.112e+04 3.842e+03 2.894 0.00398 **
cost 5.920e+03 9.230e+02 6.413 3.40e-10 ***
lost 1.775e+04 6.871e+03 2.583 0.01010 *
managerBeatrice 1.751e+03 1.235e+03 1.417 0.15714
managerCarl -1.137e+04 1.678e+03 -6.774 3.67e-11 ***
managerDevon -1.164e+04 1.721e+03 -6.767 3.84e-11 ***
managerEbrahim -1.107e+04 1.679e+03 -6.597 1.11e-10 ***
room.temp 2.108e+01 1.817e+02 0.116 0.90765
musicPop NA NA NA NA
musicRock NA NA NA NA
musicSoul NA NA NA NA
shift NA NA NA NA
mach.hrs 2.683e+04 1.870e+03 14.353 < 2e-16 ***
plantOld NA NA NA NA
breakdown -3.701e+01 9.261e+02 -0.040 0.96814
rework -8.327e+03 1.121e+04 -0.743 0.45795
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 8361 on 481 degrees of freedom
Multiple R-squared: 0.93, Adjusted R-squared: 0.9274
F-statistic: 355.2 on 18 and 481 DF, p-value: < 2.2e-16
Hi, I am taking a first course in regression and was trying to fit the above model. I tried to factor or make dummy variables of a few of the predictors but somehow I am getting the Coefficients: (5 not defined because of singularities)
and NA
for music and breakdown.
Please tell me what I'm doing wrong. I am stuck!
NA
s, possibly some dummy variables are misspecified. What output duscor()
give for the variables? Also given the large size of some of your coefficients you might consider rescaling some of the variables. But that just a detail. $\endgroup$