Hello, I have a time-series of standards measured for Refractive index. They are daily standards, however, I didn't run one everyday so some days have no data. I can plot the values, but the x-axis does not represent the correct time series (i.e. it's just an evenly spaced 1,2,3 type axis). I want to plot the points with some form of representitive date line on the x-axis. I don't think the ts() function will work in this instance as I have missing data. Once I have that data, I want to plot a least squares line with 95% confidence interval bands. Can anyone help with this?? Thanks in advance. -- Gareth Campbell PhD Candidate The University of Auckland P +649 815 3670 M +6421 256 3511 E gareth.campbell@esr.cri.nz gcam032@gmail.com [[alternative HTML version deleted]]
do you want just a date time stamp or do you want other things. There are many ways to skin this cat, but we are going to need more information... as a first start try looking at the zoo package. stephen On Tue, Aug 5, 2008 at 5:47 PM, Gareth Campbell <gcam032 at gmail.com> wrote:> Hello, > > I have a time-series of standards measured for Refractive index. They are > daily standards, however, I didn't run one everyday so some days have no > data. I can plot the values, but the x-axis does not represent the correct > time series (i.e. it's just an evenly spaced 1,2,3 type axis). I want to > plot the points with some form of representitive date line on the x-axis. I > don't think the ts() function will work in this instance as I have missing > data. > > Once I have that data, I want to plot a least squares line with 95% > confidence interval bands. Can anyone help with this?? > > Thanks in advance. > > > > -- > Gareth Campbell > PhD Candidate > The University of Auckland > > P +649 815 3670 > M +6421 256 3511 > E gareth.campbell at esr.cri.nz > gcam032 at gmail.com > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >-- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
The zoo package can represent time and plot such time series using both classic and lattice graphics There are three vignettes that come with the package that you can read for more info. Also see ?zoo ?plot.zoo ?xyplot.zoo Regarding ols see ?lm or the dyn or dynlm packages both of which work with zoo objects. On Tue, Aug 5, 2008 at 5:47 PM, Gareth Campbell <gcam032 at gmail.com> wrote:> Hello, > > I have a time-series of standards measured for Refractive index. They are > daily standards, however, I didn't run one everyday so some days have no > data. I can plot the values, but the x-axis does not represent the correct > time series (i.e. it's just an evenly spaced 1,2,3 type axis). I want to > plot the points with some form of representitive date line on the x-axis. I > don't think the ts() function will work in this instance as I have missing > data. > > Once I have that data, I want to plot a least squares line with 95% > confidence interval bands. Can anyone help with this?? > > Thanks in advance. > > > > -- > Gareth Campbell > PhD Candidate > The University of Auckland > > P +649 815 3670 > M +6421 256 3511 > E gareth.campbell at esr.cri.nz > gcam032 at gmail.com > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. >
For the first part: Create a two-column data frame of which one contains your data (Y) and the other the time index (time). Then do: plot(Y~time,type="l") ##lower case L if you want a least-squares line, run a linear regression of Y on time and add that line together with lines for the confidence bands using the abline() command. Are you sure you want an LS-line though? ?abline Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Gareth Campbell Gesendet: Tuesday, August 05, 2008 5:48 PM An: R Help Betreff: [R] Time series, least squares line Hello, I have a time-series of standards measured for Refractive index. They are daily standards, however, I didn't run one everyday so some days have no data. I can plot the values, but the x-axis does not represent the correct time series (i.e. it's just an evenly spaced 1,2,3 type axis). I want to plot the points with some form of representitive date line on the x-axis. I don't think the ts() function will work in this instance as I have missing data. Once I have that data, I want to plot a least squares line with 95% confidence interval bands. Can anyone help with this?? Thanks in advance. -- Gareth Campbell PhD Candidate The University of Auckland P +649 815 3670 M +6421 256 3511 E gareth.campbell at esr.cri.nz gcam032 at gmail.com [[alternative HTML version deleted]] ______________________________________________ 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.