在R中预测glm的错误是什么?

时间:2018-04-26 13:57:30

标签: r glm predict poisson

我运行了负二项模型。我正在尝试使用我的最终模型进行预制:

> # prediction and GOF
>     str(epilepsy_reduced)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   58 obs. of  4 variables:
 $ treatment   : num  0 0 0 0 0 0 0 0 0 0 ...
 $ age         : int  31 30 25 36 22 29 31 42 37 28 ...
 $ seizure.rate: int  3 3 5 4 21 7 2 12 5 0 ...
 $ ID          : int  1 2 3 4 5 6 7 8 9 10 ...
>     
>     placebo_patient <- data.frame(treatment=as.numeric(0), age=as.integer(30))
>     progabide_patient <- data.frame(treatment=as.numeric(1), age=as.integer(30))
>     
>     str(placebo_patient)
'data.frame':   1 obs. of  2 variables:
 $ treatment: num 0
 $ age      : int 30
>     str(progabide_patient)
'data.frame':   1 obs. of  2 variables:
 $ treatment: num 1
 $ age      : int 30
>     
>     age30 <- predict(epilepsy_reduced, newdata=placebo_patient, type="response")
Error in UseMethod("predict") : 
  no applicable method for 'predict' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"
>     age30
Error: object 'age30' not found

导致此错误的原因是什么?

0 个答案:

没有答案