[R] Plotting Standard Regression Fit-Am I wrong or a bug?

uep uep at live.co.uk
Sat Nov 8 21:40:49 CET 2008




uep wrote:
> 
> I'm trying to plot a time series (quarterly observations, seasonal effect,
> T=56),regression line and predicted point on the same plot.
> I'm using following commands:
>> plot(qdts,xlim=c(1982,1997))
>> lines(fitted(m2)~time,data=qd,col="red")
>> points(predict(m2,newdata=nqd),col="blue")
> 
> where:
> qdts<-ts(qd$durables,start=c(1982,1),freq=4)
> m2<-lm(qdts~time+quar)
> time<-seq(1,length(qdts),1)
> nqd<-data.frame(time=c(57),quar=c(1))
> 
> Unfortunately once I enter all three commands the fitted line and
> predicted point don't appear on the plot. What surprises me is that I am
> not getting any error message.
> 
> What I am doing wrong?
> Many thanks in advance
> 
> Ula
> 
> 
Thanks.
This is the qd dataset:
   year quarter durables
1  1982       1     3852
2  1982       2     3480
3  1982       3     4226
4  1982       4     3881
5  1983       1     4738
6  1983       2     4164
7  1983       3     5006
8  1983       4     4342
9  1984       1     4766
10 1984       2     4485
11 1984       3     4757
12 1984       4     4630
13 1985       1     5082
14 1985       2     4606
15 1985       3     5560
16 1985       4     4918
17 1986       1     5588
18 1986       2     5226
19 1986       3     6323
20 1986       4     5835
21 1987       1     6343
22 1987       2     5859
23 1987       3     7446
24 1987       4     6775
25 1988       1     7821
26 1988       2     7146
27 1988       3     9476
28 1988       4     7945
29 1989       1     9012
30 1989       2     8147
31 1989       3     9971
32 1989       4     8284
33 1990       1     9085
34 1990       2     7937
35 1990       3     9714
36 1990       4     7940
37 1991       1     8323
38 1991       2     7028
39 1991       3     9201
40 1991       4     7788
41 1992       1     8120
42 1992       2     7228
43 1992       3     9475
44 1992       4     8245
45 1993       1     8758
46 1993       2     7496
47 1993       3    10861
48 1993       4     8892
49 1994       1     9592
50 1994       2     8344
51 1994       3    11410
52 1994       4     9563
53 1995       1    10172
54 1995       2     8627
55 1995       3    12066
56 1995       4    10007
-- 
View this message in context: http://www.nabble.com/Plotting-Standard-Regression-Fit-Am-I-wrong-or-a-bug--tp20399460p20400227.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list