[R] Compute Regressions with R-Function

Michael Dewey lists at dewey.myzen.co.uk
Thu Nov 12 18:11:33 CET 2015


In-line

On 12/11/2015 16:27, Matthias Worni wrote:
> Hello
>
> I was trying to set up a function() that allows easely to calculate
> regressions for severel dependent variables with the same independent
> variables.
>
> My function looked like this but was turned down by an error (Im quiet new
> to R Studio). So here is my solution:
>
> b
> CO2
> logTrop_Aerosol
> lm(b ~ CO2  + logTrop_Aerosol  )
>
> Trend <- function(x,CO2,logTrop_Aerosol) { lm x   CO2  + logTrop_Aerosol}

Since you posted in HTML it is hard to be sure but I would have thought 
you have left out the parentheses and the ~ symbol.

>
> b is a vector containing 400 values of heat content
> CO2 also contains 400 values as well as logTropAerosol
>
> my idea would be that I simply can replace x (heat content) by other
> vectors containing heat content.
>
> The error I got was the following:
>
> Error: unexpected symbol in "Trend <- function(x,y,z) { lm x"
>
> Thanks a lot for the help!
>
> Best Matthias
>
> 	[[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.
>

-- 
Michael
http://www.dewey.myzen.co.uk/home.html



More information about the R-help mailing list