y *权重错误:二进制运算符的非数字参数

时间:2019-07-07 17:07:33

标签: r machine-learning regression glmnet model-fitting

我正在尝试使用glmnetcr包在具有许多分类变量的大型数据集上构建连续比率模型。

我正在尝试拟合此模型:

fit3=glmnetcr(x=trainElective2[,1:26],y=trainElective2[,27],method="forward")

这给了我以下错误:

Error in y * weights : non-numeric argument to binary operator

这是我的变量类型:

 $ Admission.Type                     : Factor w/ 3 levels "Elective - Booked",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ Treatment.Function                 : Factor w/ 7 levels "BREAST SURGERY",..: 1 3 2 3 1 3 2 3 3 1 ...
 $ Main.Health.Care.Provider.Job.Title: Factor w/ 25 levels "Colorectal Consultant",..: 7 4 15 12 18 15 8 15 4 6 ...
 $ Dominant.Procedure.OPCS.Code       : Factor w/ 373 levels "A732","A752",..: 22 219 166 329 19 152 85 159 55 24 ...
 $ Procedure.Code.Desc                : Factor w/ 373 levels "Abdominolipectomy",..: 231 325 2 50 329 339 33 340 11 261 ...
 $ Primary.Diagnosis.ICD10.Code       : Factor w/ 330 levels "A099","A419",..: 30 220 20 301 32 1 323 183 169 32 ...
 $ Primary.Diagnosis.Desc             : Factor w/ 323 levels "Abdominal aortic aneurysm, without mention of rupture",..: 196 67 161 139 197 130 31 98 89 197 ...
 $ Secondary.Diagnosis.ICD10.Code     : Factor w/ 568 levels "A047","A099",..: NA 175 NA 510 175 285 344 229 182 107 ...
 $ Secondary.Diagnosis.Desc           : Factor w/ 550 levels "Abdominal aortic aneurysm, without mention of rupture",..: NA 177 NA 465 177 157 437 116 110 521 ...
 $ ASA.Code                           : Factor w/ 5 levels "1","2","3","4",..: 1 3 2 1 1 NA 2 NA 3 3 ...
 $ Anaesthetic.Type                   : Factor w/ 11 levels "Block","Epidural Anaesthetic",..: 4 4 4 4 4 NA 3 NA 4 4 ...
 $ Was.Operation.Delayed.             : Factor w/ 2 levels "No","Yes": 1 2 2 1 1 1 2 1 2 2 ...
 $ Reason.For.Operation.Delay         : Factor w/ 56 levels "Additions / Changes to List",..: NA 30 17 NA NA NA 28 NA 30 31 ...
 $ Is.Readmission.                    : Factor w/ 2 levels "No","Yes": 1 1 1 1 1 1 1 1 1 1 ...
 $ Did.Patient.Die.                   : Factor w/ 2 levels "No","Yes": 1 1 1 1 1 1 1 1 1 1 ...
 $ Patient.Age.On.Admit               : num  51 58 60 74 83 73 61 73 77 82 ...
 $ Patient.Sex                        : Factor w/ 2 levels "Female","Male": 1 1 1 1 1 1 2 1 1 1 ...
 $ Patient.Ethnicity                  : Factor w/ 15 levels "Any Other Ethnic Group",..: 14 14 11 14 14 14 11 14 14 14 ...
 $ Patient.Deprivation.Index.Decile   : num  9 8 9 6 6 7 3 NA 1 4 ...
 $ BMI                                : num  32.1 32.4 2.81 23.8 26.7 26.3 22.1 25 25.4 29.1 ...
 $ BMI.Category                       : Factor w/ 4 levels "Healthy","Obese",..: 2 2 4 1 3 3 1 3 3 3 ...
 $ Smoking.Status                     : Factor w/ 3 levels "Current Smoker",..: 3 2 2 3 2 2 1 1 2 2 ...
 $ Drinking.Status                    : Factor w/ 2 levels "No","Yes": NA 2 2 2 2 2 NA 1 1 2 ...
 $ OperationDuration                  : num  118 111 677 78 169 NA 107 NA 337 84 ...
 $ LOS                                : Ord.factor w/ 54 levels "1"<"2"<"3"<"4"<..: 1 1 5 1 2 1 11 2 3 1 .

我遵循了RDocumentation中的示例:https://www.rdocumentation.org/packages/glmnetcr/versions/1.0.2/topics/glmnet.cr

此外,我不确定我是否使用了正确的包装。

这是我的数据集样本的链接:

https://github.com/connor20/MyProject/blob/master/trainElectiveDemo.xlsx

0 个答案:

没有答案