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

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat Nov 8 21:46:38 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")

Umm, as far as I can see you have a plot with xlim from 1982 to 1987, 
and your lines(..~time) has time==1:something.


> 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
> 


-- 
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list