----- Forwarded Message ----- From: rezvan hatami <rezvan.hatami_...@yahoo.com> To: David Winsemius <dwinsem...@comcast.net> Sent: Monday, 27 June 2016, 9:44 Subject: Re: [R] How I can calculate the value of response variable Dear DavidThank you for your answer. My equation is: nitrate=0.9*fertilizer-0.02*flowrate+0.5*rain my matrix: | season | site | nitrate | fertilizer1 | flow rate | | spring | site1 | 0.2 | 2 | 1 | | spring | site2 | 1.2 | 3 | 1 | | spring | site3 | 2.2 | 5 | 2 | | summer | site1 | 3.2 | 1 | 2 | | summer | site2 | 4.2 | 2 | 2 | | summer | site3 | 5.2 | 3 | 2 | | fall | site1 | 6.2 | 4 | 3 | | fall | site2 | 7.2 | 5 | 3 | | fall | site3 | 8.2 | 6 | 3 | | winter | site1 | 9.2 | 4 | 4 | | winter | site2 | 10.2 | 8 | 4 | | winter | site3 | 11.2 | 9 | 4 |
I would like to know, what will be the values for variable "nitrate" if I divide the values of fertilizer by half and change the equation to: nitrate=0.9*fertilizer2-0.02*flowrate+0.5*rain in a matrix like: | season | site | nitrate | fertilizer2 | flow rate | | spring | site1 | 0.2 | 1 | 1 | | spring | site2 | 1.2 | 1.5 | 1 | | spring | site3 | 2.2 | 2.5 | 2 | | summer | site1 | 3.2 | 0.5 | 2 | | summer | site2 | 4.2 | 1 | 2 | | summer | site3 | 5.2 | 1.5 | 2 | | fall | site1 | 6.2 | 2 | 3 | | fall | site2 | 7.2 | 2.5 | 3 | | fall | site3 | 8.2 | 3 | 3 | | winter | site1 | 9.2 | 2 | 4 | | winter | site2 | 10.2 | 4 | 4 | | winter | site3 | 11.2 | 4.5 | 4 | Would you please tell me how I can do this in R? Cheers Rezvan From: David Winsemius <dwinsem...@comcast.net> To: rezvan hatami <rezvan.hatami_...@yahoo.com> Cc: "r-help@r-project.org" <r-help@r-project.org> Sent: Monday, 27 June 2016, 1:20 Subject: Re: [R] How I can calculate the value of response variable > On Jun 26, 2016, at 3:23 AM, rezvan hatami via R-help <r-help@r-project.org> > wrote: > > How I can calculate the value of response variable in a linear model of a >matrix of several variables?Can somebody please answer me? > You should explain in more detail why the answer to this question is not just the `lm` function. See: ?lm ?predict.lm That would deliver (after suitable invocation of the `predict` function) not be the "value of the response variable" (since that would just be the values in your data), but rather the conditional expectation of the response variable given the values of the predictors. > > Cheers > Rezvan Hatami > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.