Re: [R-sig-eco] NA error in envfit
Hello, I think I saw something like this in autumn (northern hemisphere) when a variable had constant values with no variation, and envfit did not know how to scale the arrow. We fixed this in the development version of vegan in R-Forge on September 29. Unfortunately R-Forge is again dysfunctional and cannot build the package, but if you are able to do that yourself you can try to see if the problem is fixed there. The same files are also in github, but you need to build the package yourself there too. I'm working with a minor release of vegan (2.0-10) which may be published on Monday 9 Dec, but there are no guarantees that it will have this envfit fix or be released like planned (you know, the best laid plans of mice and men...) It may be easiest to see if a constant variable is the culprit, and remove that if needed. If this is not the case, we need more info and a *reproducible* example. We haven't got any now, and I cannot reproduce your problem. Cheers, Jari Oksanen From: r-sig-ecology-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] on behalf of Stephen Sefick [sas0...@auburn.edu] Sent: 04 December 2013 22:01 To: Mitchell, Kendra Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] NA error in envfit 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,
Re: [R-sig-eco] NA error in envfit
Hai, building and installing from github is quite easy with the devtools package (thanks to Hadley!): # install devtools install.packages('devtools') require(devtools) # install vegan from github install_github('vegan', 'jarioksa') Cheers, Eduard Szöcs On 12/05/2013 02:07 PM, Jari Oksanen wrote: Hello, I think I saw something like this in autumn (northern hemisphere) when a variable had constant values with no variation, and envfit did not know how to scale the arrow. We fixed this in the development version of vegan in R-Forge on September 29. Unfortunately R-Forge is again dysfunctional and cannot build the package, but if you are able to do that yourself you can try to see if the problem is fixed there. The same files are also in github, but you need to build the package yourself there too. I'm working with a minor release of vegan (2.0-10) which may be published on Monday 9 Dec, but there are no guarantees that it will have this envfit fix or be released like planned (you know, the best laid plans of mice and men...) It may be easiest to see if a constant variable is the culprit, and remove that if needed. If this is not the case, we need more info and a *reproducible* example. We haven't got any now, and I cannot reproduce your problem. Cheers, Jari Oksanen From: r-sig-ecology-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] on behalf of Stephen Sefick [sas0...@auburn.edu] Sent: 04 December 2013 22:01 To: Mitchell, Kendra Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] NA error in envfit 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 ...
Re: [R-sig-eco] NA error in envfit
# install vegan from github install_github('vegan', 'jarioksa') BTW I recommend using this form: install_github('jarioksa/vegan') Hadley -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
It is easy if you have C and Fortran compilers plus unix tools. I assume most people do not have those. Then 'easy' is quite different a concept. Cheers, Jari Oksanen alkuperäinen viesti Lähettäjä: Hadley Wickham Lähetetty: 05.12.2013, 16:19 Vastaanottaja: Eduard Szöcs Kopio: r-sig-ecology@r-project.org Aihe: Re: [R-sig-eco] NA error in envfit # install vegan from github install_github('vegan', 'jarioksa') BTW I recommend using this form: install_github('jarioksa/vegan') Hadley -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[R-sig-eco] NA error in envfit
Kendra, I wonder if the problem is a factor level with no observations. One of the frustrating things about factors (class variables) in R is that the list of levels is stored separately from the data. This can cause all sorts of problems if you create the factor, then subset the data, and the subset is missing one or more levels of the factor. You are subsetting your data, so this may be the source of the problem. My working philosophy is to keep variables as character strings or numbers until just before I need the factors. That avoids any issues with extraneous levels. That means reading data sets (.txt or .csv files) with as.is=TRUE to avoid default creation of factors. relevel() may recreate the list of levels. I usually use factor(as.character(variable)) to flip a factor to a vector of character strings then back to a factor with the correct set of levels. Best wishes, Philip Dixon [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
Thanks, I think it was the odd variable that was named f.env$zone I removed that column and suddenly things started working -- Kendra Maas Mitchell, Ph.D. Post Doctoral Research Fellow University of British Columbia 604-822-5646 From: Dixon, Philip M [STAT] [pdi...@iastate.edu] Sent: Thursday, December 05, 2013 8:42 AM To: Mitchell, Kendra Cc: r-sig-ecology@r-project.org Subject: NA error in envfit Kendra, I wonder if the problem is a factor level with no observations. One of the frustrating things about factors (class variables) in R is that the list of levels is stored separately from the data. This can cause all sorts of problems if you create the factor, then subset the data, and the subset is missing one or more levels of the factor. You are subsetting your data, so this may be the source of the problem. My working philosophy is to keep variables as character strings or numbers until just before I need the factors. That avoids any issues with extraneous levels. That means reading data sets (.txt or .csv files) with as.is=TRUE to avoid default creation of factors. relevel() may recreate the list of levels. I usually use factor(as.character(variable)) to flip a factor to a vector of character strings then back to a factor with the correct set of levels. Best wishes, Philip Dixon [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
Thanks, makes sense to remove a variable that has no variation and it fixed the issue. And that is much easier than building and installing from source. -- Kendra Maas Mitchell, Ph.D. Post Doctoral Research Fellow University of British Columbia 604-822-5646 From: r-sig-ecology-boun...@r-project.org [r-sig-ecology-boun...@r-project.org] on behalf of Jari Oksanen [jari.oksa...@oulu.fi] Sent: Thursday, December 05, 2013 7:04 AM To: Eduard Szöcs; Hadley Wickham Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] NA error in envfit It is easy if you have C and Fortran compilers plus unix tools. I assume most people do not have those. Then 'easy' is quite different a concept. Cheers, Jari Oksanen alkuperäinen viesti Lähettäjä: Hadley Wickham Lähetetty: 05.12.2013, 16:19 Vastaanottaja: Eduard Szöcs Kopio: r-sig-ecology@r-project.org Aihe: Re: [R-sig-eco] NA error in envfit # install vegan from github install_github('vegan', 'jarioksa') BTW I recommend using this form: install_github('jarioksa/vegan') Hadley -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] NA error in envfit
It's not that hard: * windows: just go to http://cran.r-project.org/bin/windows/Rtools/, then download and run the installer. * mac: download xcode from the app store and gfortran from http://cran.r-project.org/bin/macosx/tools/ * linux: you're on linux, you can figure it out yourself ;) Hadley On Thu, Dec 5, 2013 at 9:04 AM, Jari Oksanen jari.oksa...@oulu.fi wrote: It is easy if you have C and Fortran compilers plus unix tools. I assume most people do not have those. Then 'easy' is quite different a concept. Cheers, Jari Oksanen alkuperäinen viesti Lähettäjä: Hadley Wickham Lähetetty: 05.12.2013, 16:19 Vastaanottaja: Eduard Szöcs Kopio: r-sig-ecology@r-project.org Aihe: Re: [R-sig-eco] NA error in envfit # install vegan from github install_github('vegan', 'jarioksa') BTW I recommend using this form: install_github('jarioksa/vegan') Hadley -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology -- http://had.co.nz/ ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
[R-sig-eco] reporting non significant glmmPQL results of a fixed factor with two three levels
Dear list, I'm just starting to learn how to use glmmPQL and I have a very basic question. I'm a bit embarrassed asking this, but I could not find a clear answer anywhere, and I did search quite a bit. Unfortunately there is no one around me to ask - none of my collegues work with glmmPQL. Here is the fixed effects section of my output: Fixed effects: cbind(ColoYes.allnoF24, ColoNo.allnoF24) ~ year.coded + sex Value Std.Error DF t-value p-value (Intercept) 1.4442270 0.1824173 74 7.917161 0. year.codedY2011 -0.1733713 0.1864744 74 -0.929732 0.3555 year.codedY2012 -0.3004284 0.2027411 74 -1.481833 0.1426 sexM 0.4403108 0.1507471 74 2.920857 0.0046 I simply want to report the fact that year (categorical, three levels) is not significant. In traditional linear models I would simply report the p value for treatment year from an anova table. But my understanding is that producing an anova from glmmPQL is not possible (?). Reporting those individual p values of my three years separately seems clumsy and out of place... What is the proper way to do this ? Thank you very much for your help, Marie [[alternative HTML version deleted]] ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
Re: [R-sig-eco] Community composition variance partitioning?
Hi Steve, Thank you for your response to my message and for the suggestion. We are also performin RDA-based variance partitioning. Reading the literature on community composition variance partition, my impression was that there is a turmoil and the field is divided into two main fields in disagreement: rda- and partial mantel-based approaches using or not pcnm as spatial descriptors (as opposed to polinomials of lat long). Simulation comparisons concluded that all approaches are subotimal and have strenghts and weakenesses. This without mentioning the danish initiative to use mixed models as a comparative means to these two approaches. We decided to all three: rda, mantel, and mixed model approaches, so as to be able to compare results and see if congruent patterns emerge. To be more specific, in the mixed model approach ordination axes (e.g., pca on hellinger-transformed species data) are used as dependent variables and explanatory environmental factors are used as independent variables. Levels of spatial cluster are included as nesting effects. Sequential model adjustment shows if space is relevent and if the environment is relevant, in which case which environmental variables are relevant are also evaluated. Regarding the R2 problem in the multiple regression on distance matrices, it seems that indeed the problem was that we were including variables as extra columns and not as separate matrices in the formula. With change we obtained r2 in the expected order of increase. What do you think of this all-inclusive approach? All the best, Alexandre Dr. Alexandre F. Souza Professor Adjunto II Departamento de Botanica, Ecologia e Zoologia Universidade Federal do Rio Grande do Norte (UFRN) http://www.docente.ufrn.br/alexsouza Curriculo: lattes.cnpq.br/7844758818522706 ___ Alexandre, I'll leave it to Sarah to advise you on MRM (and I agree with Jari that the method you're describing is not going to work). I'll just add that it is not clear to me why the predictors (even geographic distance) have to be treated as distances to partition the variance in composition. I'm assuming the environmental variables were not originally in the form of euclidean distance matrices and that the raw measurements are available? As for the geographic distances, if you have lat and long coordinates, why not treat both lat and long as predictors and do the necessary analyses as partial distance-based redundancy analyses using capscale? In one analysis the geographic predictors could be partialled out (with the result explaining the fraction explained by the environment). In another, the environmental predictors could be partialled out (with the result explaining the fraction explained by the geographic distance) and in a third both geographic and environmental predictors could be considered with no conditioning covariates (which will give the total variance explained by both combined). Best Steve ___ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology