Error in X [, pstart [i] - 1 + 1: object $ nsdf [i]] <- Xp: number of items to replace is not a multiple of replacement length "

324 views
Skip to first unread message

Barbara Soto

unread,
Dec 5, 2021, 8:35:47 PM12/5/21
to distance-sampling
Hi
My name is Bárbara Soto and I am making some density models on guanaco populations in the commune of San Gregorio, Magallanes, Chile
The truth is that I am quite new to this and I have already made progress by making several models and combinations of variables but I have had some problems when performing the rqgam.check, which only delivers the Resids vs linear pred graph and not the others. .
On the other hand, when I try to make the prediction with the following command "dsm.pred <- predict (dsm18.3tw, preddata2016, preddata2016 $ area)" I get the following error: "Error in X [, pstart [i] - 1 + 1: object $ nsdf [i]] <- Xp:
   number of items to replace is not a multiple of replacement length "
I know more or less what you mean, but I don't understand why this error is occurring and how to fix it.

Beforehand thank you very much

Len Thomas

unread,
Dec 5, 2021, 9:07:00 PM12/5/21
to distance...@googlegroups.com
Hi Bárbara,

It's hard to diagnose what might be happening from this description.
Perhaps you could send me, to my email address, enough data and code
that I can reproduce what you see on my machine, and I'll try to
determine what the problem might be. Once we've worked it out, we can
post back to the list what the solution was (assuming we find one!).

Best wishes, Len Thomas
> --
> You received this message because you are subscribed to the Google
> Groups "distance-sampling" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to distance-sampl...@googlegroups.com
> <mailto:distance-sampl...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/distance-sampling/ae308f2c-afd0-4cc6-92e6-7948d23ef83dn%40googlegroups.com
> <https://groups.google.com/d/msgid/distance-sampling/ae308f2c-afd0-4cc6-92e6-7948d23ef83dn%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
I am a member of the University and College Union and am currently
participating in industrial action to improve UK higher education
staff pension, pay, equality and working conditions. For more
information, please see
https://www.ucu.org.uk/article/11896/Why-were-taking-action.

--
Len Thomas (he/him) len.t...@st-andrews.ac.uk lenthomas.org @len_thom
Centre for Research into Ecological and Environmental Modelling
and School of Mathematics and Statistics
The Observatory, University of St Andrews, Scotland KY16 9LZ
Office: UK+1334-461801 Admin: UK+1334-461842

While I may be sending this email outside of my normal office hours,
I have no expectation to receive a reply outside of yours.

The University of St Andrews is a charity
registered in Scotland, No SC013532.

Eric Rexstad

unread,
Dec 6, 2021, 3:08:23 AM12/6/21
to distance...@googlegroups.com
Bárbara

I have an answer to your first question regarding rqgam.check​.  That function has been revised in recent versions of the package and comes with this description in the details:

Reproduces the "Resids vs. linear pred" plot from gam.check but using randomised quantile residuals...  Earlier versions of this function produced the full gam.check output, but this was confusing as only one of the plots was really useful. Checks of k are not computed, these need to be done using gam.check.

Therefore calling rqgam.check​ will only produce a single plot of residuals against the linear predictor.


From: 'Len Thomas' via distance-sampling <distance...@googlegroups.com>
Sent: 06 December 2021 02:06
To: distance...@googlegroups.com <distance...@googlegroups.com>
Subject: Re: [distance-sampling] Error in X [, pstart [i] - 1 + 1: object $ nsdf [i]] <- Xp: number of items to replace is not a multiple of replacement length "
 
To unsubscribe from this group and stop receiving emails from it, send an email to distance-sampl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/distance-sampling/06996b8b-e69a-7856-d1cf-870e74ccfe11%40st-andrews.ac.uk.

Joanne Potts

unread,
May 26, 2022, 9:18:18 PM5/26/22
to distance-sampling
Hi Len, Bárbara, and list,

Was this issue resolved off-list and an update not yet posted? 

I encountered this problem this week. The error was being that the observation data included only 3 levels of a factor variable, but the prediction grid had a pesky extra level that got caught right on the boundary for 2 grid cells. (So model was trying to predict to a fourth factor level that wasn't included in the modelling data.) Once those two boundary grid cells were fixed the error went away.

Unsure if that was the issue for Bárbara, but oddly it was the exact same error message within dsm & using predict().

I post here in case it helps any one else :)

Jo
Reply all
Reply to author
Forward
0 new messages