[R] linear regression in a data.frame using recast

2011-03-16 Thread Justin Haynes
I have a very large dataset with columns of id number, actual value,
predicted value.  This used to be a time series but I have dropped the
time component.  So I now have a data.frame where the id number is
repeated but each value in the actual and predicted columns are
unique.

I assume I need to use recast somehow but I'm at a loss... how can I
perform a simple linear regression (using lm()?) on my two variables
for each unique id number?

additionally, I need to fix the y-intercept at zero.


Thanks for your help,

Justin

__
R-help@r-project.org mailing list
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.


Re: [R] linear regression in a data.frame using recast

2011-03-16 Thread David Winsemius


On Mar 16, 2011, at 3:19 PM, Justin Haynes wrote:


I have a very large dataset with columns of id number, actual value,
predicted value.  This used to be a time series but I have dropped the
time component.  So I now have a data.frame where the id number is
repeated but each value in the actual and predicted columns are
unique.

I assume I need to use recast somehow but I'm at a loss... how can I
perform a simple linear regression (using lm()?) on my two variables
for each unique id number?

additionally, I need to fix the y-intercept at zero.


?formula

Something like:

lm(y ~ x + factor(id) -1, data=dat)

If this is really a time series, then you will have serious validity  
problems due to auto-correlation among non-independent units. (But if  
you are just searching for a way to pull the wool over the eyes of the  
statistically uninformed, then I guess there's no stopping you.)


--

David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
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.


Re: [R] linear regression in a data.frame using recast -- A fortunes candidate??

2011-03-16 Thread Bert Gunter
Ha! -- A fortunes candidate?
-- Bert


 If this is really a time series, then you will have serious validity
 problems due to auto-correlation among non-independent units. (But if you
 are just searching for a way to pull the wool over the eyes of the
 statistically uninformed, then I guess there's no stopping you.)

 --

 David Winsemius, MD
 West Hartford, CT


__
R-help@r-project.org mailing list
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.


Re: [R] linear regression in a data.frame using recast -- A fortunes candidate??

2011-03-16 Thread Abhijit Dasgupta, PhD

Seconded

On 03/16/2011 05:37 PM, Bert Gunter wrote:

Ha! -- A fortunes candidate?
-- Bert


If this is really a time series, then you will have serious validity
problems due to auto-correlation among non-independent units. (But if you
are just searching for a way to pull the wool over the eyes of the
statistically uninformed, then I guess there's no stopping you.)

--

David Winsemius, MD
West Hartford, CT


__
R-help@r-project.org mailing list
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.


__
R-help@r-project.org mailing list
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.