Dear all,

Thanks a lotfor your valuable suggetions,it was a great welcome to the
forum, Well,I took but since I am not as advanced as you, I just fitted
(after breaking the data by prey)  two curves, using the curve function to
the M&Mmodel.

Changing little bit the header I have the model for lepidopterans

model<-nls(Eaten~SSmicmen(Density,a,b))
summary(model)
 summary(model)

after that ants estimation

model1<-nls(Kill~SSmicmen(Dens,a,b))
summary(model1)

Plotting model
plot(Density,Eaten,pch=as.numeric(Prey))
> xv<-seq(0,10,1)
> yv<-predict(model,list(Density=xv))
> lines(xv,yv)


Plotting model1

plot(Dens,Kill,pch=as.numeric(Prey))
> cv<-seq(0,10,1)
> dv<-predict(model,list(Density=cv))
> lines(cv,dv)



My question now is how to compare both models and how to graph the two
lines on the same graph. I would appreaciate an help :D

All the best!





2013/5/30 Novack-Gottshall, Philip M. <pnovack-gottshall@ben.edu>

>  Dear Luis,
>
> Pierre is correct that nls() can do this. Note that this function is
> sensitive to choice of parameters. You may need to try different estimates
> (see ?selfStart), or modify the control settings (see ?nls.control) to get
> it to work.
>
> Once you have an nls regression, you could then use log-likelihood to
> calculate the fit of your data to multiple models (say, type I, II, and
> III), and then use Akaike weights to evaluate the support for each model.
> (It's a different question then you're asking, but could allow you to claim
> that, say, type II would be significantly better fit than the alternatives,
> or you could fit the model for lepidopterans to the ants, and do a similar
> thing with a single model.)
>
> Here's an example (comparing fit of logistic and linear regression), where
> r, K, and x.0 and the control settings in nls() are pre-specified. Data is
> just includes, like yours, a set of x and y data.
>
> y <- c(0.2121, 0.8863, 2.1730, 5.7529, 11.7042, 14.7078, 15.3028)
> x <- seq(1, length(y))
> data <- data.frame(x=x, y=y)
>
> # Set parameters and control for nls:
> K <- max(y)
> x.0 <- min(y)
> r <- 1
> control <- nls.control()
> control$minFactor <- 1e-16
> control$maxiter <- 200
>
> # Fit models
> nlsfit <- nls(y ~ K / (1 + ((K - x.0)/x.0) * exp(-r * x)), data=data,
> start=list(K=K, r=r, x.0=x.0), control=control)
> lm <- lm(y ~ x)
>
> # Now logLik and Akaike comparison
> models <- c("Linear", "Logistic")
> k <- c(2, 3) # Number of parameters in each model
> n <- length(y)
> Llm <- logLik(lm)
> Lnls <- logLik(nlsfit)
> table <- data.frame(models, lambda=round(c(Llm, Lnls), 3), k, AICc=NA,
> weight=NA)
> # AICc: 2k – 2 ln(L) + [2k(k+1)]/[n-k-1]
> table[,4] <- (2 * table[,3]) - (2 * table[,2]) + ((2 * table[,3] *
> (table[,3] + 1)) / (n - table[,3] - 1))
> min <- min(table[,4])
> # Akaike weights: exp(delta AICc/2) / sum [exp(delta AICc/2)]
> delta <- table[,4] - min
> sum <- sum(exp(delta / 2))
> table[,5] <- round((exp(delta / 2) / sum), 4)
> table  # For this data, the logistic model is the better one.
>
> There used to be a nice example running through this at
> http://mercury.bio.uaf.edu/mercury/R/R.html#nonlinear, but that website
> appears to have evaporated in the ether. I did a quick search, but couldn't
> track down an updated website for it.
>
> Good luck,
> Phil
>
>
>
> On 5/30/2013 1:59 AM, Pierre THIRIET wrote:
>
> Dear Fernando,
>
> I would suggest the function nls() that fit non-linear model.
> You can specify by hand your equation and starting values of your
> parameters (your guessed value)
> R include some Self-Starting functions for the model the most used, this
> could be easier for you to work with it. check ?selfStart()
> According to wikipedia, Type II functional response is similar to the
> Michaelis--Menten equation, which is implemented in R as self starting
> function:http://stat.ethz.ch/R-manual/R-patched/library/stats/html/SSmicmen.html
>
> By adpting examples, you could easily fit your model, if the choosen
> equation is suitable.
>
> About statistical comparisons of estimated parameters among curves, I
> have no idea but I found, among other this post:http://stats.stackexchange.com/questions/26611/how-to-test-the-effect-of-a-grouping-variable-with-a-non-linear-model
>
> Good luck,
> Pierre
>
> Le 30/05/2013 07:49, Luis Fernando García Hernández a écrit :
>
>  Dear all,
>
> I am new on the list and on the more complex applications of R, so I ask
> you to excuse me if my mail is too long.
>
> This time I have to do several tasks related tu functional reponse. I want
> to evaluate the relationship between prey density (x) vs prey consumed(y)
> the idea is to fit the data set to the functional reponse equation:
>   Na/TP=a/(1+aThN). I have idea about the value of most of the equation
> parameters, but I am completely lost about how to fit the data points to
> this equation.
>
> On another hand I have to graph and compare if there are significative
> differences on estimated parameters of the curves for lepidopterans and
> ants, the final data should look like the attacher picture.If any of you
> have some idea about how to do this, would be really appreciated.
>
> Below you  can find the data and the pictures.
>
> Thanks in advance
>
>      Prey Density Eaten  Lepidopteran 1 2  Lepidopteran 1 3  Lepidopteran 1 3
> Lepidopteran 3 4  Lepidopteran 3 5  Lepidopteran 3 4  Lepidopteran 5 7
> Lepidopteran 5 5  Lepidopteran 5 6  Lepidopteran 10 8  Lepidopteran 10 10
> Lepidopteran 10 7  Ant 1 3  Ant 1 1  Ant 3 4  Ant 3 2  Ant 5 4  Ant 5 6  Ant
> 10 5  Ant 10 6
>
>
> _______________________________________________
> R-sig-ecology mailing listR-sig-ecology@r-project.orghttps://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
>
> 	[[alternative HTML version deleted]]
>
>
>
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  Phil Novack-Gottshall
>  Assistant Professor
>  Department of Biological Sciences
>  Benedictine University
>  5700 College Road
>  Lisle, IL 60532
>
>  pnovack-gottshall@ben.edu
>  Phone: 630-829-6514
>  Fax: 630-829-6547
>  Office: 332 Birck Hall
>  Lab: 107 Birck Hall
>  http://www1.ben.edu/faculty/pnovack-gottshall
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>

	[[alternative HTML version deleted]]

