[R-sig-eco] NA error in envfit

Stephen Sefick sas0025 at auburn.edu
Wed Dec 4 21:01:42 CET 2013


Kendra,

Something is wrong in X or P; find out what the foreign function call is 
  and then you may be able to track down the offending data problem. 
Maybe a logarithm somewhere? This is probably not much help; I don't 
have much experience with envfit.

Stephen

On 12/03/2013 07:06 PM, Mitchell, Kendra wrote:
> I'm running a bunch of NMS with vectors fitted (slicing and dicing a large dataset in different ways).  I'm suddenly getting an error  from envfit
>
> f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, na.rm=TRUE)
>
> Error in vectorfit(X, P, permutations, strata, choices, w = w, ...) :
>    NA/NaN/Inf in foreign function call (arg 1)
> In addition: Warning message:
> In vectorfit(X, P, permutations, strata, choices, w = w, ...) :
>    NAs introduced by coercion
>
> I can plot the NMS and even run ordifit on individual env variables, so can't figure out what the problem is.   There aren't any NA/NaN/Inf in either of those data that I can find.  I've tried running it without na.rm=TRUE and still get the error.  Guidance on how to fix this would be appreciated.
>
> Here's the whole slicing process and str for the data
>
>
> f.bSBS.org<-f.env$zone.hor=="bSBS.1"
> f.bSBS.org.tyc<-f.tyc[f.bSBS.org,f.bSBS.org]
> f.bSBS.org.env<-subset(f.env, f.env$zone.hor=="bSBS.1")
> f.bSBS.org.nms<-metaMDS(as.dist(f.bSBS.org.tyc), k=3, trymin=50, trymax=250, wascores=FALSE)
> f.bSBS.org.fit<-envfit(f.bSBS.org.nms, f.bSBS.org.env, permutations=999, na.rm=TRUE)
>
>
> str(f.bSBS.org.env)
> 'data.frame':    63 obs. of  14 variables:
>   $ zone         : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 ...
>   $ site         : Factor w/ 18 levels "A7","A8","A9",..: 12 12 12 12 12 12 12 12 12 12 ...
>   $ om           : Factor w/ 4 levels "0","1","2","3": 2 2 2 3 3 3 2 2 2 3 ...
>   $ compaction   : num  1 1 1 1 1 1 1 1 1 1 ...
>   $ herbicide    : num  0 0 0 0 0 0 0 0 0 0 ...
>   $ horizon      : Factor w/ 2 levels "1","2": 1 1 1 1 1 1 1 1 1 1 ...
>   $ Water_content: num  50.3 50.3 50.3 50.1 50.1 ...
>   $ DNA_ug_g     : num  71.2 71.2 71.2 68.6 68.6 ...
>   $ C            : num  30.5 30.5 30.5 28.4 28.4 ...
>   $ N            : num  0.863 0.863 0.863 0.81 0.81 ...
>   $ pH_H2O       : num  4.63 4.63 4.63 4.49 4.49 ...
>   $ CN           : num  35.3 35.3 35.3 35.1 35.1 ...
>   $ f.env$zone   : Factor w/ 6 levels "bIDF","bSBS",..: 2 2 2 2 2 2 2 2 2 2 ...
>   $ zone.hor     : chr  "bSBS.1" "bSBS.1" "bSBS.1" "bSBS.1" ...
>
> str(f.bSBS.org.nms)
> List of 35
>   $ nobj      : int 63
>   $ nfix      : int 0
>   $ ndim      : num 3
>   $ ndis      : int 1953
>   $ ngrp      : int 1
>   $ diss      : num [1:1953] 0.00424 0.00437 0.05169 0.07522 0.11039 ...
>   $ iidx      : int [1:1953] 12 8 55 56 52 7 56 12 59 52 ...
>   $ jidx      : int [1:1953] 7 6 18 55 8 3 18 3 12 49 ...
>   $ xinit     : num [1:189] 0.654 0.837 0.438 0.105 -0.313 ...
>   $ istart    : int 1
>   $ isform    : int 1
>   $ ities     : int 1
>   $ iregn     : int 1
>   $ iscal     : int 1
>   $ maxits    : int 200
>   $ sratmx    : num 1
>   $ strmin    : num 1e-04
>   $ sfgrmn    : num 1e-07
>   $ dist      : num [1:1953] 0.0679 0.0231 0.3598 0.1248 0.1422 ...
>   $ dhat      : num [1:1953] 0.0455 0.0455 0.2076 0.2076 0.2076 ...
>   $ points    : num [1:63, 1:3] -0.1256 0.1224 0.267 0.2374 -0.0427 ...
>    ..- attr(*, "dimnames")=List of 2
>    .. ..$ : chr [1:63] "LL001" "LL002" "LL003" "LL007" ...
>    .. ..$ : chr [1:3] "MDS1" "MDS2" "MDS3"
>    ..- attr(*, "centre")= logi TRUE
>    ..- attr(*, "pc")= logi TRUE
>    ..- attr(*, "halfchange")= logi FALSE
>   $ stress    : num 0.157
>   $ grstress  : num 0.157
>   $ iters     : int 180
>   $ icause    : int 3
>   $ call      : language metaMDS(comm = as.dist(f.bSBS.org.tyc), k = 3, trymax = 250, wascores = FALSE, trymin = 50)
>   $ model     : chr "global"
>   $ distmethod: chr "user supplied"
>   $ distcall  : chr "as.dist.default(m = f.bSBS.org.tyc)"
>   $ distance  : chr "user supplied"
>   $ converged : logi TRUE
>   $ tries     : num 23
>   $ engine    : chr "monoMDS"
>   $ species   : logi NA
>   $ data      : chr "as.dist(f.bSBS.org.tyc)"
>   - attr(*, "class")= chr [1:2] "metaMDS" "monoMDS"
>
>
> --
> Kendra Maas Mitchell, Ph.D.
> Post Doctoral Research Fellow
> University of British Columbia
> 604-822-5646
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>

-- 
Stephen Sefick
**************************************************
Auburn University
Biological Sciences
331 Funchess Hall
Auburn, Alabama
36849
**************************************************
sas0025 at auburn.edu
http://www.auburn.edu/~sas0025
**************************************************

Let's not spend our time and resources thinking about things that are so 
little or so large that all they really do for us is puff us up and make 
us feel like gods.  We are mammals, and have not exhausted the annoying 
little problems of being mammals.

                                 -K. Mullis

"A big computer, a complex algorithm and a long time does not equal 
science."

                               -Robert Gentleman



More information about the R-sig-ecology mailing list