I just realized after some tips and a little digging that what I was trying to do "manually" has already been done. I was trying to fit my data using 'lm' then taking the "residual" data and trying to do a spectral estimate (for seasonality) usiing fft and then passing the "residual" of all of that to arima to get the irregular portion of the time series forecast equation. I found 'stl' that advertises that it does all of this (and probably better than my efforts). The only problem that I found was that it takes a time-series object. Time-series objects don't handle missing observations. Say I only have two observations for the year (enough to fit a line through). I can easily fit a line through the observation points but if I add in zeros for the missing observations least squares will undoubtedly throw my observations out and fit the "wrong" line. The other steps will more than likely have residual data so I don't have to worry for these steps about missing data. Has anyone used 'stl' with missing observations? If so what sort of tricks did you use to get around the missing data and time series? Thank you. Kevin
if your two points are valid and you would be willing to run a least spuares regression on then you should be fairly comfortable with using na.approx in the zoo package. If interpolating values is going to give you an erroneous result then maybe this is not the correct path. But have a look. On Mon, Sep 1, 2008 at 1:50 AM, <rkevinburton at charter.net> wrote:> I just realized after some tips and a little digging that what I was trying to do "manually" has already been done. I was trying to fit my data using 'lm' then taking the "residual" data and trying to do a spectral estimate (for seasonality) usiing fft and then passing the "residual" of all of that to arima to get the irregular portion of the time series forecast equation. I found 'stl' that advertises that it does all of this (and probably better than my efforts). The only problem that I found was that it takes a time-series object. Time-series objects don't handle missing observations. Say I only have two observations for the year (enough to fit a line through). I can easily fit a line through the observation points but if I add in zeros for the missing observations least squares will undoubtedly throw my observations out and fit the "wrong" line. The other steps will more than likely have residual data so I don't have to worry for these steps about missing data. Has anyon! > e used 'stl' with missing observations? If so what sort of tricks did you use to get around the missing data and time series? > > Thank you. > > Kevin > > ______________________________________________ > 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. >-- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy 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
<rkevinburton <at> charter.net> writes:> > I just realized after some tips and a little digging that what I was trying todo "manually" has already been> done. I was trying to fit my data using 'lm' then taking the "residual" dataand trying to do a spectral> estimate (for seasonality) usiing fft and then passing the "residual" of allof that to arima to get the> irregular portion of the time series forecast equation. I found 'stl' thatadvertises that it does all of> this (and probably better than my efforts). The only problem that I found wasthat it takes a time-series> object. Time-series objects don't handle missing observations. Say I only havetwo observations for the> year (enough to fit a line through). I can easily fit a line through theobservation points but if I add in> zeros for the missing observations least squares will un > doubtedly throw my observations out and fit the "wrong" line. The other stepswill more than likely have> residual data so I don't have to worry for these steps about missing data. Hasanyon!> e used 'stl' with missing observations? If so what sort of tricks did you useto get around the missing data> and time series? > > Thank you. > > Kevin > > ______________________________________________ > 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. > >Someone can correct me if I am wrong, but R's STL implementation uses the Fortran version of stl, which in interest of speed does not allow for missing observations. If you use the stl implemented in S, you should be able to have missing observations. If you read the original stl paper, the algorithm is described and is pretty straightforward to implement or do your own variation on.