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

From: uep <uep_at_live.co.uk>
Date: Sat, 08 Nov 2008 14:23:18 -0800 (PST)

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.

______________________________________________
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.
Received on Sat 08 Nov 2008 - 22:27:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 08 Nov 2008 - 23:30:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive