[R] 600 people's time series
bt_jannis at yahoo.de
Sun Apr 17 22:58:35 CEST 2011
Your questions are as basic that it smells like home/classwork. Try to
formulate precise questions and not questions like "how do I solve this
general problem" and you are much mor likely to get answers.
To get you started:
For questions on how to plot values from dataframes please have a look
either at "an introduction to R (pdf)", some basic textbooks or just
google: "r-project plotting tutorial" (the second link should get you
For the regression I would loop through all ids and calculate the
regression for a subset of the dataframe like:
invest = DF$invest[DF$id==i]
You will have to find out the details yourself. We will happily help if
you post some precise (!) questions in case you get stuck!
On 04/16/2011 07:15 PM, 苏江东Su Jiangdong wrote:
> Hi there,
> I have a data frame DF of over 600 people's short term trade data in time
> order. Below is the super simplified structure of the data.
> id invest payout
>  1 10 -1
>  1 33 33
>  1 20 -5
>  2 200 33
>  2 33 -20
>  3 5 -5
>  3 5 -5
> id is each person's id. Each person have invested many times in the sampling
> period, in temporal order.
> What I want to check is the correlation between invest and payout.
> 1. How do I run the regression for each person, with the "invest" being
> devided by the mean or medium of the person's "invest"?
> 2. How do I plot a graph with y axis being invest/mean(invest) and x axis
> being payout, all 600 people's dots superimposed on one graph?
> I tried to use
> for (i in 1:(dim (DF)-1))
> if (DF[i,1]=DF[i+1,1]) id.lm<- lm(invest ~ payput, data=DF)
> But I don't know how to superimpose graphs onto each other.
> Thanks a lot!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> 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