Я построил отрицательную биномиальную модель с gam
, такую как:
> nb.gam <- gam(terms(seizure.rate ~ . * age_cat , data = epilepsy_cat),
+ data = epilepsy_cat , scale=-1, family=nb(link="log"))
> summary(nb.gam)
Family: Negative Binomial(1.495)
Link function: log
Formula:
seizure.rate ~ (treatment + age_cat) * age_cat
attr(,"variables")
list(seizure.rate, treatment, age_cat)
attr(,"factors")
treatment age_cat treatment:age_cat
seizure.rate 0 0 0
treatment 1 0 1
age_cat 0 1 1
attr(,"term.labels")
[1] "treatment" "age_cat" "treatment:age_cat"
attr(,"order")
[1] 1 1 2
attr(,"intercept")
[1] 1
attr(,"response")
[1] 1
attr(,".Environment")
<environment: R_GlobalEnv>
Parametric coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.97716 0.29951 6.601 4.08e-11 ***
treatment -0.46457 0.39763 -1.168 0.2427
age_cat2 0.06306 0.38880 0.162 0.8712
age_cat3 0.29152 0.46737 0.624 0.5328
treatment:age_cat2 0.25385 0.53232 0.477 0.6334
treatment:age_cat3 -1.58097 0.80874 -1.955 0.0506 .
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
R-sq.(adj) = 0.0226 Deviance explained = 15.1%
-REML = 164.71 Scale est. = 1 n = 58
но когда я пытаюсь построить это, я получаю ошибку. Произведено два сюжета, но я ожидал, что появятся 4 сюжета. Есть идеи, что происходит?
> plot(nb.gam,residuals=TRUE,col="red",shade=TRUE) # cex=1.3,ylim=c(-9,6),
Error in plot.gam(nb.gam, residuals = TRUE, col = "red", shade = TRUE) :
No terms to plot - nothing for plot.gam() to do.
> gam.check(nb.gam)
Method: REML Optimizer: outer newton
full convergence after 2 iterations.
Gradient range [-5.07631e-06,-5.07631e-06]
(score 164.7056 & scale 1).
Hessian positive definite, eigenvalue range [15.68978,15.68978].
Model rank = 6 / 6