我有以下代碼可以使用外部空氣溫度和TOD(96分類變量,一天中的時間)在15分鐘的時間間隔內獲得負載消耗量的日提前預測。當我運行下面的代碼時,出現以下錯誤。在R中使用GLM模型的日期提前
i = 97:192
formula = as.formula(load[i] ~ load[i-96] + oat[i])
model = glm(formula, data = train.set, family=Gamma(link=vlog()))
我得到以下錯誤的最後一行後使用GLM(),
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
而且使用預測()的最後一行後,下面的錯誤出現時,
Warning messages:
1: In if (!se.fit) { :
the condition has length > 1 and only the first element will be used
2: 'newdata' had 96 rows but variable(s) found have 1 rows
3: In predict.lm(object, newdata, se.fit, scale = residual.scale, type = ifelse(type == :
prediction from a rank-deficient fit may be misleading
4: In if (se.fit) list(fit = predictor, se.fit = se, df = df, residual.scale = sqrt(res.var)) else predictor :
the condition has length > 1 and only the first element will be used
'我'代表什麼?你是想要適合一個模型,還是(192-97 + 1)= 96模型? –
我代表15分鐘數據的間隔數。 train.set = dt.new [1:192,] test.set = dt.new [193:288,] –
因此,您想使用數據框中行的子集來擬合模型? 'link = vlog'從哪裏來? –