Re: [R-sig-eco] DCCA in R?

2020-11-11 Thread Peter Solymos
o DCCA (detrended canonical > correspondence analysis) but the unconstrained DCA. If anyone knows the > answer for Jonathan's question, please, share it with me, I would also be > interested. > Best regards, > > Attila > > Peter Solymos ezt írta (időpont: 2020. nov. 5., Cs

Re: [R-sig-eco] DCCA in R?

2020-11-05 Thread Peter Solymos
Jonathan, Have you checked ?vegan::decorana (it is also mentioned in the vignette on p 2: https://cran.r-project.org/web/packages/vegan/vignettes/intro-vegan.pdf ) Cheers, Peter On Thu, Nov 5, 2020 at 11:03 AM Jonathan Gordon wrote: > Hello, > > I’m aiming to perform a detrended canonical

Re: [R-sig-eco] LEVELS function NULL

2020-06-23 Thread Peter Solymos
R >= 4.0 will treat categorical variables as character (stringsAsFactors=FALSE is the new default) when importing via e.g. read.table(). If you want factors, you have to make it explicit either as Torsten showed or by setting stringsAsFactors=TRUE. Cheers, Peter On Tue, Jun 23, 2020 at 10:05 AM

Re: [R-sig-eco] Package to analyse population time series (trend analysis)

2016-10-19 Thread Peter Solymos
Manuel, There are few ecology focused packages besides ARIMA() and the forecast package, for example: - popbio (based mostly on the Matrix Population Models by Caswell (2001) and Quantitative Conservation Biology by Morris and Doak (2002). - PVAClone, that uses JAGS and is based on Nadeem, K.,

Re: [R-sig-eco] How to calculate relative abundance along taxonomical hierarchy

2015-06-25 Thread Peter Solymos
Gian, Once you have your samples by OTU matrix row standardized, you can use a level of your hierarchy (a vector matching the columns) and the groupSums(your-matrix, 2, your-groups) function in the mefa4 package to get your relative abundances. Cheers, Peter Gian Maria Niccolò Benucci

Re: [R-sig-eco] How to calculate relative abundance along taxonomical hierarchy

2015-06-25 Thread Peter Solymos
is not very big but I worked with thousands of OTUs) will have this problem. Do you have an idea how to deal with this kind of data object? Thank you, Gian On 25 June 2015 at 11:51, Peter Solymos soly...@ualberta.ca javascript:; wrote: Gian, Once you have your samples by OTU matrix

Re: [R-sig-eco] multipart

2015-04-07 Thread Peter Solymos
Hi Saifi, Here is how you can set up your design variables to be used in the formula interface of multipart() or adipart() in vegan. You need to adjust the settings and make sure that the results make sense, because you know the data. library(vegan) # x - structure(...) # just copied your data

Re: [R-sig-eco] data structures for ecological data

2014-11-19 Thread Peter Solymos
Jason, The segments in 'mefa' just add a 3rd dimension to the object, but that does not limit accessing the stored information. Sample attributes can have spatial information, but it is not specifically designed to support spatial analysis. More concrete feature requests are welcome. There is an

Re: [R-sig-eco] stochastic population models

2014-02-23 Thread Peter Solymos
Jeff, I am not sure why you need 100 random numbers for r and K, but if your goal is to get stochastic state-space model, you need to define the error term as a separate parameter and run the loop 100 times with the *same* fixed parameter values. When you do this, then you need to be aware of

Re: [R-sig-eco] FW: inconsistent p-values in 'indval'

2014-01-01 Thread Peter Solymos
Eda, How many permutations do you use? Have you tried setting the RNG seed via set.seed() ? Also, if you have borderline p-values that change from run to run it might indicate not so strong discrimination by the given clustering of sites. Cheers, Peter -- Péter Sólymos 780-492-8534 |

Re: [R-sig-eco] beta regression error

2013-12-03 Thread Peter Solymos
Attila, See paper and R code by Millar et al. 2011 for a solution based on 'glm': http://www.esapubs.org/archive///ecol/E092/146/ Peter -- Péter Sólymos, Dept Biol Sci, Univ Alberta, T6G 2E9, Canada AB soly...@ualberta.ca, Ph 780.492.8534, http://psolymos.github.com Alberta Biodiversity

Re: [R-sig-eco] Logistic regression with repeated measures ?

2013-11-27 Thread Peter Solymos
Marie, Your problem and data seems to me a resource selection problem with matched use-availability design. Estimating procedure for that design is discussed in Lele and Keim (2006, Ecology 87:3021--3028) and implemented in the ResourceSelection package: rspf function, see description of argument

Re: [R-sig-eco] Logistic regression with repeated measures ?

2013-11-27 Thread Peter Solymos
-project.org] On Behalf Of Peter Solymos Sent: Thursday, 28 November 2013 10:33 AM To: marieline gentes Cc: r-sig-ecology@r-project.org Subject: Re: [R-sig-eco] Logistic regression with repeated measures ? Marie, Your problem and data seems to me a resource selection problem with matched use

Re: [R-sig-eco] Logistic regression with repeated measures ?

2013-11-27 Thread Peter Solymos
identical ? Thank you so much again for your time, Marie On Wednesday, November 27, 2013 7:19:47 PM, Peter Solymos soly...@ualberta.ca wrote: Chris, It is not random effect strictly speaking, but something like that. The problem is this: RSF models are often constructed as mixed models

Re: [R-sig-eco] Diversity on standardised densities in R

2013-10-25 Thread Peter Solymos
Hello, A parametric model (e.g. Clench) would allow both intrapolation and extrapolation. There are some caveats of course: (1) these models arose in the temporal accumulation sense, spatial accumulation is usually calculated for randomized data, which is an assumption that individuals in the

Re: [R-sig-eco] offset function in glm.nb

2013-06-14 Thread Peter Solymos
Matias, The offset term is processed as part of parsing the formula, which results in a vector of length of the response. Using a vector should not be a problem. Peter -- Péter Sólymos, Dept Biol Sci, Univ Alberta, T6G 2E9, Canada AB soly...@ualberta.ca, Ph 780.492.8534,

Re: [R-sig-eco] Rao entropy with presence-absence data

2013-06-13 Thread Peter Solymos
was wondering what happens if I have abundance data for my species matrix but binary trait values? Because it seems the function has some problems with this combination. Regards, Thomas On 6/12/2013 5:17 PM, Peter Solymos wrote: Thomas, 1) Presence absence data means that you

Re: [R-sig-eco] Rao entropy with presence-absence data

2013-06-12 Thread Peter Solymos
Thomas, 1) Presence absence data means that you have cell probabilities 1/S_i for detections and 0 for missing species in a given community i. As Zoltán also pointed out, it is meaningful to use this, as it has the interpretation of choosing different species from a species list (and not from a

Re: [R-sig-eco] Standardizing data

2013-01-23 Thread Peter Solymos
Bruce, Standardizing might not be the best way to go if you have low counts. You can possibly assume that events follow a homogeneous Poisson process and rate varies with night length (linear or quadratic) [Y|x ~ Poisson(phi); log(phi)=f(x)]. You can estimate corresponding coefficients by glm().

Re: [R-sig-eco] looping and plotting a Lefkovitch/Leslie projection

2012-11-29 Thread Peter Solymos
Jeffrey, Check out also the popbio package. Cheers, Peter -- Péter Sólymos, Dept Biol Sci, Univ Alberta, T6G 2E9, Canada AB soly...@ualberta.ca, Ph 780.492.8534, http://psolymos.github.com Alberta Biodiversity Monitoring Institute, http://www.abmi.ca Boreal Avian Modelling Project,

Re: [R-sig-eco] Replacing values in a data frame

2012-10-25 Thread Peter Solymos
Maybe: A$X2[A$X21] - 1 Peter -- Péter Sólymos, Dept Biol Sci, Univ Alberta, T6G 2E9, Canada AB soly...@ualberta.ca, Ph 780.492.8534, http://psolymos.github.com Alberta Biodiversity Monitoring Institute, http://www.abmi.ca Boreal Avian Modelling Project, http://www.borealbirds.ca 2012/10/25

Re: [R-sig-eco] subsetting in R

2012-09-18 Thread Peter Solymos
Kristen, Try something like this: i - sample(1:nrow(DataSet.Sub2), 85, replace=FALSE) DataSet.Sub2.66- DataSet.Sub2[i,] DataSet.Sub2.33- DataSet.Sub2[-i,] Peter -- Péter Sólymos, Dept Biol Sci, Univ Alberta, T6G 2E9, Canada AB soly...@ualberta.ca, Ph 780.492.8534, http://psolymos.github.com

Re: [R-sig-eco] Randomizing matrices

2012-08-19 Thread Peter Solymos
shuffle the cells a 1000 times, and then go on to make the SSD value 1000 times? Thanks again for helping out. Allan - Original Message - From: Peter Solymos soly...@ualberta.ca To: Allan Edelsparre aedel...@uoguelph.ca Cc: r-sig-ecology@r-project.org Sent: Saturday, August 18, 2012

Re: [R-sig-eco] error distribution in GLM model

2012-08-19 Thread Peter Solymos
Mario, If you can assume that the waiting time between events is constant through time, you can model your counts per unit time with Poisson glm (constant waiting time leads to an exponential survival function). log(Observation time) can be used as an offset: glm(interactions~covariate,

Re: [R-sig-eco] How to transform a cross-tabulated matrix (as provided by mefa4::Xtab) for further multivariate analyses

2012-06-12 Thread Peter Solymos
Ivailo, Some (but not all) vegan functions internally coerce the matrix like input object to matrix using 'x - as.matrix(x)'. The as.matrix() coercion method is defined for sparse matrices in the Matrix package, and that is why it works for some (but not all) vegan functions. In case it does not

Re: [R-sig-eco] Combining two matrices

2012-05-13 Thread Peter Solymos
Thiago, It's all about indexing: rn - union(rownames(matrix1), rownames(matrix2)) cn - union(colnames(matrix1), colnames(matrix2)) x - array(0, dim=c(length(rn), length(cn)), dimnames=list(rn, cn)) x[rownames(matrix1), colnames(matrix1)] - matrix1 x[rownames(matrix2), colnames(matrix2)] -

Re: [R-sig-eco] Presence-absence to Occurrence Dataset?

2012-04-20 Thread Peter Solymos
Hi Elyse, Tom referred to the mefa package, I'd like to draw the attention to the mefa4 package which is more efficient and can handle large data since it uses sparse matrices through the Matrix package. The Melt() function is the inverse operation to xtabs() or its modified version Xtabs() in

Re: [R-sig-eco] ctree regression tree, interpretation of mean predicted values in terminal nodes

2012-03-27 Thread Peter Solymos
Kay, That is an obvious result of the regression tree algorithm which recursively splits the data and prediction is given as e.g. mean of observations at terminal nodes. New data will, however, contribute to cross validation error, a measure of prediction accuracy. The tree gives the 'global'

Re: [R-sig-eco] How can I combine several workspaces into one?

2012-02-10 Thread Peter Solymos
Guojun, Make lists of them with this function: fun - function(file) { x - new.env() load(file, x) as.list(x) } HTH, Peter On Fri, Feb 10, 2012 at 1:52 PM, lgj200306 lgj200...@163.com wrote: Hi, everyone! I have several R workspaces, with each contains many files. I want to

Re: [R-sig-eco] Calculating an AIC for the Fisher's log series.....

2011-10-05 Thread Peter Solymos
Cory, There is a profile method for fisherfit. If that's not enough, you can have a look inside of fisherfit, and you'll see the Dev.logseries internal function and how it is used in nlm to get estimate of alpha. The same function can be used for manual profiling to get likelihood values for a

Re: [R-sig-eco] Help with distribution fitting and AIC in R

2011-08-06 Thread Peter Solymos
On Sat, Aug 6, 2011 at 4:06 AM, Lene Jung ljk...@hotmail.com wrote: HI, I’m having several problems trying to fit distributions to data that I have sorted into a data frame, so the each ID has its own step length and turn angle. I can fit a Weibull distribution to step lengths with

Re: [R-sig-eco] zero-truncated Poisson

2011-04-09 Thread Peter Solymos
Jeff, The zero truncated Poisson distribution can be described as a probability function conditional on Y0: Pr(Y=y|Y0) = Pr(Y=y) / (1-Pr(Y=0)), y=1,2,3,... This leads to this function 'nll' for the negative log-likelihood: nll - function(theta, y, X) { lambda - exp(drop(X %*% theta))

Re: [R-sig-eco] Specifying a lognormal distribution

2011-03-26 Thread Peter Solymos
Hi Scott, Lognormal refers to a probability distribution of a random variable whose logarithm is normally distributed. Said so, if you log transform your CV, you can apply Gaussian family, or simply lm(). Cheers, Peter On Sat, Mar 26, 2011 at 9:16 AM, Scott Chamberlain scttchamberla...@gmail.com

Re: [R-sig-eco] omit levels from boxplots

2011-01-06 Thread Peter Solymos
Hi, for one factor, it is enough to do dat$ageclass - dat$ageclass[drop=TRUE] the 'purgef' function applies the drop statement for each columns in the data frame and eventually returns a list because that's how 'lapply' works. If you want a data frame in the end, you can either do (as I recall

Re: [R-sig-eco] Converting species counts into species list

2010-12-06 Thread Peter Solymos
Ophelia and Others, A more general solution is: ## define a function (that is part of the mefa package) `rep.data.frame` - function(x, ...) as.data.frame(lapply(x, rep, ...)) ## example from ?mefa:::rep.data.frame x - data.frame(sample = LETTERS[c(1,1,2,2,3)], species =

Re: [R-sig-eco] Distinctiveness and contribdiv( )

2010-12-01 Thread Peter Solymos
Burak, Not exactly clear what you want, but Lu et al. 2007 describes the differentiation coefficient D that is the sum(beta)/sum(gamma) and can be obtained as attributes(contribdiv(x))$diff.coef . Note also that there is a link between diversity partitions and distance indices so you might as well

Re: [R-sig-eco] Distinctiveness and contribdiv( )

2010-12-01 Thread Peter Solymos
within them. Does the beta component of contribdiv ( ) do this, or does it also take into account the total number of species within the sites? -Burak -Original Message- From: psoly...@gmail.com [mailto:psoly...@gmail.com] On Behalf Of Peter Solymos Sent: Wednesday, December 01

Re: [R-sig-eco] p-Function for Empirical Distributions

2010-09-04 Thread Peter Solymos
On Fri, Sep 3, 2010 at 11:32 PM, Jane Shevtsov jane@gmail.com wrote: Does R have a p-function for empirical distributions? In other words, how can I find out what fraction of the values in my data set are smaller than a given value? Maybe sum(x = crit) / length(x) Cheers, Peter Péter

Re: [R-sig-eco] hurdle model

2010-08-19 Thread Peter Solymos
Dear All, I had a quick look at the internal functions used by pscl::hurdle to do the numerical optimization by optim. It clearly corresponds to the hurdle model defined in the paper/vignette, where the zero component is based on a right censored random variable, that is 0 if the original count

Re: [R-sig-eco] repeated measures with multivariate data

2010-07-25 Thread Peter Solymos
Hi Kay, I meant to make permutations within time points, i.e. strata=time, and not within locations (strate=locations). adonis do F-tests based on sequential sums of squares from permutations, thus the non independence of repeated measures can have an effect on p-values associated with terms

Re: [R-sig-eco] repeated measures with multivariate data

2010-07-23 Thread Peter Solymos
Kay, using strata (restricting permutations within time points, and not within locations) in adonis makes some sense, given that permutation tests assume independence. But that does not solve the problem of dependence, but it is a good starter. If you have a before-after control-treatment design,

Re: [R-sig-eco] Vegan fisher.alpha error

2010-06-01 Thread Peter Solymos
Kang Min, The error comes from the function 'fisherfit' that uses 'nlm' to minimize the negative log likelihood for the Fisher's log-series. Numerical optimization does not tolerate missing values. This code reproduces your error: library(vegan) data(BCI) BCI[1,1] - NA fisher.alpha(BCI)

Re: [R-sig-eco] vegdist producing empty result object

2010-04-07 Thread Peter Solymos
Dave, The vegdist function of the vegan package produces an object of class dist similarly to the dist function in stats. It can be converted into a symmetric matrix by as.matrix(x). The help page of dist will give you details about the structure of dist objects. Cheers, Peter On Wed, Apr 7,

Re: [R-sig-eco] Handling lots of zero + spatial autocorrelation

2010-03-25 Thread Peter Solymos
Claudia, Here is a more specific paper with hierarchical Bayesian model: Stephen L. Rathbun and Songlin Fei A spatial zero-inflated poisson regression model for oak regeneration Environmental and Ecological Statistics, 2006, 13: 409-426

Re: [R-sig-eco] Species CoOccurance

2010-03-12 Thread Peter Solymos
Lanna, I don't know exactly what do you mean by co-occurrence data frame, but if you'd like to get a species-by-species matrix, in which you count the co-occurrences of the species (columns in the sites-by-species community matrix) with each other, you can use the crossprod function or the %*%

Re: [R-sig-eco] multiple regression

2010-02-08 Thread Peter Solymos
for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: Gavin Simpson [mailto:gavin.simp...@ucl.ac.uk] Verzonden: maandag 8 februari 2010 11:14 Aan: ONKELINX, Thierry CC: Peter Solymos; Nathan Lemoine

Re: [R-sig-eco] multiple regression

2010-02-06 Thread Peter Solymos
Nathan, Species richness is categorical, so if your richness values are usually low (say 20), you should consider the use of Poisson GLM, or log-transform your response (and log is the canonical link function for Poisson GLM). This usually improves the model fit. And this might apply to

Re: [R-sig-eco] multiple regression

2010-02-06 Thread Peter Solymos
I meant Species richness is discrete, not categorical. Peter On Sat, Feb 6, 2010 at 12:52 PM, Peter Solymos soly...@ualberta.ca wrote: Nathan, Species richness is categorical, so if your richness values are usually low (say 20), you should consider the use of Poisson GLM, or log-transform

Re: [R-sig-eco] null models with continuous abundance data

2010-01-07 Thread Peter Solymos
again for your help. Etienne Le 7 janvier 2010 08:17, Peter Solymos soly...@ualberta.ca a écrit : Dear Etienne, You can try the Chris Hennig's prablus package which have a parametric bootstrap based null-model where clumpedness of occurrences or abundances

Re: [R-sig-eco] null models with continuous abundance data

2010-01-07 Thread Peter Solymos
is that matrix fill should be kept constant *but also* be constrained within rows. Thanks again for your help. Etienne Le 7 janvier 2010 08:17, Peter Solymos soly...@ualberta.ca a écrit : Dear Etienne, You can try the Chris Hennig's prablus package which have a parametric

Re: [R-sig-eco] Mantel test with skew-symmetric matrices?

2009-10-01 Thread Peter Solymos
Dear Steve, If the direction is important, you can use that information as a separate matrix with signs to scale up its effect. Because distance can't be negative, you might end up with numbers hard to interpret. Yours, Peter Péter Sólymos Alberta Biodiversity Monitoring Institute Department

Re: [R-sig-eco] adonis model specification

2009-09-29 Thread Peter Solymos
Christine, There is no summary method for adonis. After calling the function, simply use print: x - adonis(...) x And you are right, you can supply raw data and use the method argument in adonis to define dissimilarity index (which is bray by default). Cheers, Peter Péter Sólymos Alberta

Re: [R-sig-eco] glm for ratio [0,1] data

2009-08-31 Thread Peter Solymos
Hi Bálint, Here are my two cents. By using LM with transformed data (which transformation can also be logit, loglog, cloglog, probit) you loose the Binomial error structure, because you won't follow the trial/success experiment scheme. But percent cover is not that kind of [0,1] data where this

Re: [R-sig-eco] Help with downloading package

2009-08-19 Thread Peter Solymos
Dear Leigh, You have 2 options: 1. build the MAC OS X package for yourself and install it, in this way you will be able to use the help files as usual, 2. unpack the .tar.gz and source all files in the /R directory (on how to do it at once see Example in help(source)). Cheers, Peter On Wed,

Re: [R-sig-eco] How to convert matrix to paired list?

2009-07-23 Thread Peter Solymos
Dear Jin-Long, You can try this: x - cbind(rnorm(10), rnorm(10), rnorm(10), rnorm(10)) y - cor(x) y library(mefa) z - as.data.frame(as.dist(y)) z Yours, Peter Peter Solymos, PhD Postdoctoral Fellow Department of Mathematical and Statistical Sciences University of Alberta Edmonton, Alberta

Re: [R-sig-eco] problem using reshape package

2009-07-09 Thread Peter Solymos
) + SPECIES, x) ## replicates cross tabulated separately y2 - xtabs(Counts ~ SITE + SPECIES + Replicate, x) ## same with mefa (will give you warnings ## due to some 'empty sample' misspecifications) m - mefa(stcs(x)) m$segm Yours, Peter Peter Solymos, PhD Postdoctoral Fellow Department

Re: [R-sig-eco] testing for distribution

2009-05-13 Thread Peter Solymos
Dear Jacob, Erika was right, you just have to perform a goodness of fit test. Bit it is easier to inspect your residual deviance. It follows a Chi-sqared distribution, where the expected value should be close to the degrees of freedom if the fit is good. To get a P value for an object of class

Re: [R-sig-eco] Clustering large data

2008-10-07 Thread Peter Solymos
this (SAMPLES and SPECIES are the two column in the long format, have to be the same length): x - mefa(stcs(data.frame(SAMPLES,SPECIES))) cl - hclust(dist(x$xtab)) Hope this works, Peter Peter Solymos, PhD Department of Mathematical and Statistical Sciences University of Alberta Edmonton, Alberta, T6G