четверг, 5 сентября 2019 г.

Modeling Logistic Growth Data in R, marine global change ecology

marine global change ecology. at UMASS AMHERST. Modeling Logistic Growth Data in R. My dog rocks. Wilson is friendly to almost everyone (mailmen excepted) and he’s very soft. We’ve had him since he was a puppy and because the wife and I are dorky scientists, we’ve collected (non-invasive) data from him since day one. So today we’ll be modeling growth data, courtesy of Wilson, using R, the “nls” function, and the packages “car” and “ggplot2”. For reference, I drew on Fox and Weisburg (2010). Wilson’s growth looks like a logistic function. As a puppy, he put on the pounds quickly (yep, I remember that), and he has flattened out around 75 lbs (thank god). Although I will say that he still thinks he is a lap dog. A logistic growth model can be implemented in R using the nls function. “nls” stands for non-linear least squares. The logistic growth function can be written as. Post navigation. 25 responses to “ Modeling Logistic Growth Data in R ” Thanks for nonlinear low down. What if I had multiple dogs in multiple groups? Could I use this package to tell me if my groups differed? Hey Dustin! Yes you could totally use this to distinguish groups. I am unsure of the specific syntax using ‘nls’ but I’ve done similar things with logistic regression. Off the top of my head, you could look at parameter estimates between groups and see if they differed (e.g. compare confidence intervals of the estimates). If the groups had differing phi values that did not overlap, that would be evidence for different growth models. I will try and look at the code for this…. Looking at each parameter estimate independently would be a cool approach. I guess it would allow you to specify what aspect of growth differed among groups. Thanks. This is GREAT, thank you so much. Thanks. What I will do if I have random growth rate. I mean if my gowth rates don’t have any trend or pattern over time like your example. Growth rates typically follow some pattern, assuming resources are not limited. This is why most studies evaluate growth under ad libitum resource availability. I would first ask why your data don’t have any discernible trend. Second, what is your question of interest? Dear Brian, I am trying to fit the predicted curve on my data, but I think there is something wrong in the curve. Can you review my script to look what is wrong? Thank you very much for your attention. Sincerely, Bruna. Hi Bruna, Send me your script and I’ll take a look! You can find my email on my “about” page. Hi Brian, this was so helpful, thanks! Any way you could add in confidence intervals on either side of the predicted curve? Hi Taryn! For an approximate 95 CI you could double the standard errors around the slope coefficients. But I think there is a better method involving pulling estimates from the profiled log-likelihood, which will allow for asymmetric CIs (I’ll have to look into this). Another approach would be to bootstrap the data and generate CIs that way. So for example, simulate 999 more Wilsons (with replacement) and calculate model coefficients. Then take the 2.5 and 97.5 percentiles of those models and there is your 95% CI. Hi Brian, I am very interested in this code! I am trying to predict the size of a given population using the following line of code: predict.pop. Hi Antoine! “confint(model)” will return the lower and upper 95% CI of the parameter estimates for your model. Try modeling both upper and lower bounds and using geom_ribbon to fill in the prediction. If this doesn’t make sense, perhaps I can generate a follow up post to highlight this. Cheers, Brian. thanks for being so responsive! Your answer makes sense but I am struggling a little bit with my code. By running the predict cmd, I get the expected pop size at a given year. The LGM I used is the following: nls(value. SSlogis(time, phi1, phi2, phi3), mydata) it is based on the following webpage: When I run confint on the model itself: confint(nls(value. SSlogis(time, phi1, phi2, phi3),data=mydata)), it works but gives me the CI of phi1, phi2 and phi3. My goal is to obtain the confint of predict… I tried to adapt the model above with the given upper CI of phi1, phi2 and phi3 but was not successful Thoughts? I am happy to try an optimized/alternative model if you favor another one. Here’s an example for a limited subpopulation (value=nb of subjects): time value 2010 1 2011 1 2012 4 2013 6 2014 7 2015 8 2016 13. I’d like to predict the expected size in 2020, 2030 and CI… thanks again! a. Hi Brian, I am reaching out to you again regarding the lgm model I am using. Thanks to your advices, I was able to run my model and got CI for phi1, phi2 and phi3 with the following: model. Makes sense to me. I’m unsure if the predict function works for nls. Have you tried it the “long” way as in my post? I’m traveling now but can look at this in earnest when I return in two days. Thanks Brian! predict function does work but no CI… I will try the ‘long’ way you suggest but if there is a more straightforward way, I am eager to learn how to do it! Have a safe trip a. Oops sorry. Misread your comment. I’m not sure if plotting confidence intervals the long route is statistically sound. I’ll have to gander at the texts. Another solution would be to bootstrap simulate the data and plot the upper and lower bounds of the simulated data. We did this in a paper, let me know if you want to see that solution. the bootstrap option seems promising. Can you redirect me to your paper? Do you have a code I could use attached to your publication? thanks again. The paper is Komoroske et al 2014 Conservation Physiology (full citation on my publication page). But no code attached to the paper. I can share the code when I return to the states. Feel free to email me if you haven’t heard from me in a day or two! thanks Brian, I will email you in a couple of days. By then, I will read your paper. Have a safe trip! Hi Brian Just a quick reminder. Any chance you can help me for getting CI (or bootstrap sim) for my dataset? thanks again. Hello I am Victor, from Chile, I am glad to meet you and thank you for the explanation. Using your code for learning, I identify a little typing mistake, that blows some minutes my mind, in the 14th line phi1 does not have added the letter “-“, for the rest. I am grateful for you, because despite that spanish is my mother tongue, the spanish explanations were not clear for me. Best Regards from Southern Chile. Thanks Victor! I’ve corrected the typo. Thx Brian. Came to your blog after a long search for such an example on the implementation of a logistic growth model. Ggplot script worked immediately after pasting it to RStudio (mac OS) by the way.

Комментариев нет:

Отправить комментарий