Hello, I would like to state what I am (trying) to do. I have data set. It has 5749 rows (including the header) and 23 columns. The data contains values related to spatial aspects of the 412 landscapes (over various years). I will be making 2 groups from the data based on spatial extent. I will then be performing a quadratic lm for each extent by percent forest vs 1 of 8 other metrics. For a total of 16 (2 extents * 8 metrics) quad lm runs. I will be doing this 'manually'. I hope this is the best way to do these analyses. e.g. ed.qlm.s <- lm(data=small, pfor~ED+I(pfor^2)) pd.qlm.s <- lm(data=small, pfor~PD+I(pfor^2)) ... ed.qlm.l <- lm(data=large, pfor~ED+I(pfor^2)) pd.qlm.l <- lm(data=large, pfor~PD+I(pfor^2)) etc. I am ultimately intested in the residuals and how they compare amongst various delineations fo the data. Q1: I would like to view the residuals for each run. I think this might be better done in a another program. I have the read the R import/export manual. However, using it and trying to use the cat, list, sink, or write functions I am still lost. What is the best way to export the residual (and or other available data from lm) data for viewing elsewhere? A table? Q2: How can I take the residuals and create an object(s) for further analysis. I'd appreciate any comments or suggestions including 'read the manual' but if thats the case perhaps with a little direction. Thank you kindly, Cheers, M Just [[alternative HTML version deleted]]
Nordlund, Dan (DSHS/RDA)
2008-Sep-23 18:47 UTC
[R] Options for viewing / using results from lm
I haven't seen a response to this yet, so I will give my $0.25US worth (which is not worth that much anymore ). :-)> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Michael Just > Sent: Tuesday, September 23, 2008 11:01 AM > To: r-help at r-project.org > Subject: [R] Options for viewing / using results from lm > > Hello, > I would like to state what I am (trying) to do. I have data > set. It has 5749 > rows (including the header) and 23 columns. The data contains values > related to spatial aspects of the 412 landscapes (over > various years). I > will be making 2 groups from the data based on spatial > extent. I will then > be performing a quadratic lm for each extent by percent > forest vs 1 of 8 > other metrics. For a total of 16 (2 extents * 8 metrics) quad > lm runs. I > will be doing this 'manually'. I hope this is the best way to do these > analyses. > > e.g. > ed.qlm.s <- lm(data=small, pfor~ED+I(pfor^2)) > pd.qlm.s <- lm(data=small, pfor~PD+I(pfor^2)) > ... > ed.qlm.l <- lm(data=large, pfor~ED+I(pfor^2)) > pd.qlm.l <- lm(data=large, pfor~PD+I(pfor^2)) > etc. > > I am ultimately intested in the residuals and how they compare amongst > various delineations fo the data. > > Q1: I would like to view the residuals for each run. I think > this might be > better done in a another program. I have the read the R import/export > manual. However, using it and trying to use the cat, list, > sink, or write > functions I am still lost. What is the best way to export the > residual (and > or other available data from lm) data for viewing elsewhere? A table?Why do you think it is better done in another program? Keeping it in R saves you from the exporting, which you say you are having trouble with.> > Q2: How can I take the residuals and create an object(s) for further > analysis. >See ?residuals. Try the following: x <- sample(1:20, 100, replace=TRUE) y <- rnorm(100) fit.lm <- lm(y ~ x) plot(residuals(fit.lm)) plot(x,residuals(fit.lm))> I'd appreciate any comments or suggestions including 'read > the manual' but > if thats the case perhaps with a little direction. > > Thank you kindly, > Cheers, > M Just >Hope this is helpful, Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204
Hello,>Why do you think it is better done in another program? Keeping it in Rsaves you from the exporting, which you say you are having trouble with. I think it might be better for viewing capabilities. If I had columns of residuals right next to each other I could spot differences amongst locations. Right? If I can take the residual values and put them back into my main data file I can then have the options to use grouping values that exist there. (Like I asked here: http://tolstoy.newcastle.edu.au/R/e5/help/08/09/2186.html)>> Q2: How can I take the residuals and create an object(s) for further<http://tolstoy.newcastle.edu.au/R/e5/help/08/09/2259.html#2265qlink2>*analysis. * **>See ?residuals.>Try the following:>x <- sample(1:20, 100, replace=TRUE) >y <- rnorm(100) >fit.lm <- lm(y ~ x) >plot(residuals(fit.lm)) >plot(x,residuals(fit.lm))When I was thinking further analysis, for example, could I take the residuals for all metrics in one extent and compare them to all residuals for all metrics in another extent? Even though the were created with 16 different models? In 'plot(residuals(fit.lm))' what is the index 'counting'? Thank you kindly for you $0.25, Cheers, M Just [[alternative HTML version deleted]]