# [R] gam.check() NA results (k-index, p-value) of a gam logistic regression model

Simon Wood simon.wood at bath.edu
Wed May 18 11:05:56 CEST 2016

```Dear Fotis,

The test is a randomization test, based on comparing differences of
residuals, ordered with respect to the covariate of the smooth, to
differences of residuals in randomized order. Random effect terms are
excluded because there is not basis size to choose. Currently smooths
with factor by variables are also excluded for reasons of maintainer
laziness, as this would require special case code to exclude the
covariate values that are irrelevant given the factor level. Sorry about
that.

My guess is that you don't have a problem here anyway, given the fairly
low edfs relative to the basis dimension. In general as a double check I
would plot the residuals against ctrial, colour coded by level of igc,
just to check that there doesn't seem to be missed pattern in them.
However with binary residuals you are unlikely to see much.

best,
Simon

On 17/05/16 20:39, Fotis Fotiadis wrote:
> Hello all
>
> I am using bam for a mixec-effects logistic regression model:
>
> b0<-bam(acc~ 1 + igc + s(ctrial, by=igc) + s(sbj, bs="re") + s(ctrial, sbj,
> bs="re") , data=data, family=binomial)
>
>> summary(b0)
> Family: binomial
> Link function: logit
>
> Formula:
> acc ~ 1 + igc + s(ctrial, by = igc) + s(sbj, bs = "re") + s(ctrial,
>      sbj, bs = "re")
>
> Parametric coefficients:
>                Estimate Std. Error z value Pr(>|z|)
> (Intercept)     2.8334     0.2030  13.955  < 2e-16 ***
> igcPA.pseudo    0.4692     0.1285   3.650 0.000262 ***
> igcCAT.ideo     0.3276     0.2906   1.127 0.259734
> igcCAT.pseudo   0.6701     0.2945   2.275 0.022888 *
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Approximate significance of smooth terms:
>                             edf Ref.df Chi.sq  p-value
> s(ctrial):igcPA.ideo     3.827  4.733  295.0  < 2e-16 ***
> s(ctrial):igcPA.pseudo   3.317  4.110  356.1  < 2e-16 ***
> s(ctrial):igcCAT.ideo    3.979  4.911  308.6  < 2e-16 ***
> s(ctrial):igcCAT.pseudo  4.937  5.974  383.8  < 2e-16 ***
> s(sbj)                  54.326 62.000 3032.8  < 2e-16 ***
> s(ctrial,sbj)           43.045 62.000 2706.6 1.31e-08 ***
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> R-sq.(adj) =  0.362   Deviance explained = 38.9%
> fREML =  25436  Scale est. = 1         n = 18417
>
>
> I want to know if the wigglyness of the smooths [s(ctrial, by=igc)] is
> appropriate, so I used the gam.check() function. The values though for
> k-index and p-value are NAs:
>
>> gam.check(b0)
> Method: fREML   Optimizer: perf newton
> full convergence after 5 iterations.
> Gradient range [-7.60152e-08,8.12795e-06]
> (score 25436.12 & scale 1).
> Hessian positive definite, eigenvalue range [0.6271375,24.46625].
> Model rank =  168 / 168
>
> Basis dimension (k) checking results. Low p-value (k-index<1) may
> indicate that k is too low, especially if edf is close to k'.
>
>                             k'   edf k-index p-value
> s(ctrial):igcPA.ideo     9.00  3.83      NA      NA
> s(ctrial):igcPA.pseudo   9.00  3.32      NA      NA
> s(ctrial):igcCAT.ideo    9.00  3.98      NA      NA
> s(ctrial):igcCAT.pseudo  9.00  4.94      NA      NA
> s(sbj)                  64.00 54.33      NA      NA
> s(ctrial,sbj)           64.00 43.04      NA      NA
>
> Does anyone know why is this?
>
> Thank you in advance for your time,
> Fotis
>
> P.S. I am using RStudio Version 0.99.896, R 3.3.0, and mgcv package version
> 1.8.12.
> --
> PhD Candidate
> Department of Philosophy and History of Science
> University of Athens, Greece.
> http://users.uoa.gr/~aprotopapas/LLL/en/members.html#fotisfotiadis
>
> Notice: Please do not use this account for social networks invitations, for
> sending chain-mails to me, or as it were a facebook account. Thank you for
> respecting my privacy.
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> Απαλλαγμένο
> από ιούς. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
Simon Wood, School of Mathematics, University of Bristol BS8 1TW UK
+44 (0)117 33 18273     http://www.maths.bris.ac.uk/~sw15190

```

More information about the R-help mailing list