[R] Re gression for loop test HELP! URGENT!

Daniel Malter daniel at umd.edu
Mon Jul 20 05:23:40 CEST 2009


for a beginner, it's probably even easier to it by hand if it is just five
datasets.

bind the 5 datasets together in one dataset and create and index variable (1
to 5) for each of the observations according to the dataset the obersvation
comes from

then run five regressions using

reg1=lm(M~D+O+S,subset=c(index==1))
.
.
.
reg5=lm(M~D+O+S,subset=c(index==5))

and then predict from each regression

predict(reg1,newdata=data.frame(D,O,S))
.
.
.
predict(reg5,newdata=data.frame(D,O,S))

You can then assess how well the prediction from each of the datasets fits
the respective other datasets...

Daniel

-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von Rbeginner
Gesendet: Sunday, July 19, 2009 9:49 PM
An: r-help at r-project.org
Betreff: [R] Re gression for loop test HELP! URGENT!


Hi everyone!
I'm new to R, and I'm stuck on a problem I don't know how to approach.
I have calculated a regression in the form of M ~ D + O + S, and I would
like to take this regression and test it with other samples, 5 at a time(5
meaning 5 set, each consisting M, D, O, and S of a specific date). I assume
I'll need a for loop. Right now, My data of M, D, O, and S are all stored in
separate txt files, but should I just put them into a table or something?
And then how would I calculate the error of how well the test samples fit
the original regression?
This is for my internship, so it's very urgent.
THANKS A LOT!!!!!
RBeginner
--
View this message in context:
http://www.nabble.com/Regression-for-loop-test-HELP%21-URGENT%21-tp24562766p
24562766.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at 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.




More information about the R-help mailing list