使用coded.data时,我将序列号作为R中的代码

时间:2018-03-09 00:07:21

标签: r rsm

以下是我用来重新编码数据的代码:

results$Taxis<-as.factor(results$Taxis)
results$ShiftType<-as.factor(results$ShiftType)
results$Sharing<-as.factor(results$Sharing)
results$Mode<-as.factor(results$Mode)
plot(results) 
anova<-aov(Service.Level~Taxis+ShiftType+Sharing+Mode,data = results)
summary(anova)
results.coded<-coded.data(results,x1~(Taxis-4500)/3000,x3~(Sharing-50)/50,x4~(Mode-0.5)/0.5)
results.coded

它给我序列号作为代码(1,2,3,4,5 ..) 如果我更改公式,这些代码不会改变。他们保持原样。看起来像一些默认编码。 请帮帮我!

1 个答案:

答案 0 :(得分:1)

Data coding is used with continuous predictors, not factors. If interpretation requires those predictors to be factors, don’t try to code them. If they are on a numerical scale and you want to interpret them as such, then you may code them. Take away those as.factor() calls and it will work.

The advantage of coding is to scale all the variables so are treated more equitably in such methods as steepest ascent. If you’re just trying to fit an equation to the data and don’t plan to do additional experimentation to find an optimum, it really isn’t necessary to code the data.