[R] Plot with residuals in mgcv

Peter Ehlers ehlers at ucalgary.ca
Wed Nov 28 21:16:30 CET 2012


On 2012-11-28 05:02, silje skår wrote:
> Hi,
>
> I am using the mgcv package (version 1.7-22.) running the model works fine,
> but when I want to have a plot with residuals I get an error.
>
> fit29<-gam(IV~s(G3)+s(V3)+factor(AAR)+s(D3)+s(RUTE,bs="re"),data=subsf,gamma=1.4,method="ML")
>
>
> plot(fit29,residuals=T)
> Error in X[, first:last] %*% object$coefficients[first:last] :
>    non-conformable arguments
>
> does some one know what this error means? the subsf matrix is 35x27.
>
> Silje

Well, the error means that the matrix X[, first:last] and
the vector object$coefficients[first:last] don't have
'matching' dimensions. I don't see why, but since the
'residuals' argument to plot.gam() can be an array
_of the correct length_ (see ?plot.gam), it just might be
that you have an object called 'T' hanging around, in which
case using 'T' in place of 'TRUE' is a bad idea.
Actually, it's _always_ a bad idea.

Peter Ehlers




More information about the R-help mailing list