I'm a new R user who has been using the gls function to analyze scaling relationships in mammals while considering phylogenetic similarity. I'm having trouble with a few things, though. 1) For my project, I need to know the r or r^2 value of my scaling line, and I'm having trouble figuring out how to find it in R. Is there an easy way to get gls function to spit out this value? 2) Is there a way to plot the regression line and confidence intervals calculated by the program onto the data sets I'm analyzing in R? I've been able to plot residuals, but not the regression line and data. Thanks for any suggestions you can offer! Margie
Finding r^2 value and plotting regression lines and CIs from gls
2 messages · Margie Mathewson, Ben Bolker
3 days later
Margie Mathewson <m1mathew at ...> writes:
I'm a new R user who has been using the gls function to analyze scaling relationships in mammals while considering phylogenetic similarity. I'm having trouble with a few things, though. 1) For my project, I need to know the r or r^2 value of my scaling line, and I'm having trouble figuring out how to find it in R. Is there an easy way to get gls function to spit out this value?
R and R^2 are a little bit complicated once one gets beyond simple linear models -- you have to decide exactly what you mean by "variance explained"; you can search for R^2 or pseudo-R^2 on this list or elsewhere for excruciating details. In the meantime, methods(class="gls") tells you what you can do with a gls fit, and the correlation between predicted and observed values is a reasonable **CRUDE** approximation of R: example(gls) cor(predict(fm1),Ovary$follicles) predict() is also what you need to draw a regression line (see ?predict.gls)
2) Is there a way to plot the regression line and confidence intervals calculated by the program onto the data sets I'm analyzing in R? I've been able to plot residuals, but not the regression line and data.
confidence intervals are probably pretty tricky for the aforementioned reasons ...
Thanks for any suggestions you can offer! Margie