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

uep uep at live.co.uk
Sat Nov 8 23:23:18 CET 2008


Thank you Daniel,

I did try to change xlim's and ylim's, but the fitted line still doesn't
appear on the plot.
Below is a small expample I've created (I'm sorry for using names, but I het
confused with x's and y's):

>mat<-matrix(c(1,2,3,4,5,6,7,8,1,2,3,4,1,2,3,4,1,5,2,7,3,7,5,8),nrow=8,ncol=3)
>mats<-ts(mat[,3],start=c(1,1),freq=4)
>quart<-mat[,2]
>time<-seq(1,length(mats),1)
>nmat<-data.frame(time=c(9),quart=c(1))
>quar<-factor(nmat$quart)
>t1<-lm(mats~time)
>plot(mats,xlim=c(1,3.25),ylim=c(0,15))
>lines(fitted(t1)~time,col="blue")
>points(c(3),predict(t1,newdata=nmat),col="red")

Unfortunately for me, this example works and does plot fitted line and
predicted points. I really don't understand why I can't make the same
commands work when trying with my real life data.

Anyway, thanks for getting back to me earlier on.
Regards
Ula

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

-- 
View this message in context: http://www.nabble.com/Plotting-Standard-Regression-Fit-Am-I-wrong-or-a-bug--tp20399460p20401091.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list