[R] Fw: How I can calculate the value of response variable

rezvan hatami rezvan.hatami_iut at yahoo.com
Mon Jun 27 03:15:35 CEST 2016


For the sake ofsimplicity, I use my example to explain what I have written:


nutrient<-lm(nitrate~0.9*fertilizer-0.02*flowrate+0.5*rain)

datafram=data1


Change the value offertelizer--à datafram=data2


predict(lm(nitrate~0.9*fertilizer2-0.02*flowrate+0.5*rain), datafram=data2
Is that better now?

      From: Bert Gunter <bgunter.4567 at gmail.com>
 To: rezvan hatami <rezvan.hatami_iut at yahoo.com> 
Cc: "r-help at r-project.org" <r-help at r-project.org>
 Sent: Monday, 27 June 2016, 10:34
 Subject: Re: [R] Fw: How I can calculate the value of response variable
   
Is this homework? This list tries to enforce  a no homework policy...

If not, it looks to me as if you have made no effort to learn R nor
have you read and followed the posting guide. We generally expect
posters to have made reasonable efforts to do both and demonstrate
what they have tried and how it has failed.

Cheers,
Bert Gunter





Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jun 26, 2016 at 5:22 PM, rezvan hatami via R-help
<r-help at r-project.org> wrote:
>
>
>
> ----- Forwarded Message -----
>  From: rezvan hatami <rezvan.hatami_iut at yahoo.com>
>  To: David Winsemius <dwinsemius at 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 <dwinsemius at comcast.net>
>  To: rezvan hatami <rezvan.hatami_iut at yahoo.com>
> Cc: "r-help at r-project.org" <r-help at 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 at 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 at 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 at 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.

  
	[[alternative HTML version deleted]]



More information about the R-help mailing list