[R] Difficulty with 'loess' function

armstrwa William.Armstrong at noaa.gov
Fri Mar 18 16:34:45 CET 2011


Hi,

I am trying to create a loess smooth from hydrologic data.  My goal is to
create a smooth line that describes discharge at a certain point in time.  I
have done this using the 'lowess' function and had no problem, but I'm
having some difficulty with loess.  I am inputting the date ('date') and
discharge ('q') values using the 'scan' function, then inputting the
following:

> dateq<-data.frame(date,q)
> dateq_smooth<-loess(dateq,span=.5)
> dateq_smooth_pred<-predict(dateq_smooth,date)
> dateq_smooth_pred
 [1] 1959.164 1959.516 1963.379 1967.121 1963.781 1970.601 1958.056 1948.846
1954.247
[10] 1954.718 1969.460 1960.974 1949.845 1962.436 1968.374 1954.247 1956.135
1948.852
[19] 1948.846 1957.893 1963.055 1955.327 1961.453 1960.405 1956.135 1963.065
1959.358
[28] 1954.478 1954.415 1964.323 1963.255 1953.139 1966.048 1959.353 1961.817
1959.894
[37] 1958.251 1964.914 1960.157 1964.656 1964.164 1949.873 1965.500 1968.323
1962.196
[46] 1961.656 1954.977 1969.196 1962.318 1952.576 1962.655 1968.031 1963.445
1967.856
[55] 1961.323 1949.032 1954.687 1955.613 1982.081 1960.736 1963.466 1974.468
1970.164
[64] 1954.212 1957.928 1957.893 1961.985 1966.180 1963.283 1963.379 1964.387
1970.017
[73] 1959.353 1969.925 1963.111 1962.667 1963.417 1964.029 1965.241 1964.323
1964.405
[82] 1963.036 1981.359 1968.146 1968.374 1970.050 1963.089 1959.667 1966.129
1958.081
[91] 1964.029 1968.374 1967.856 1955.758 1954.619 1965.227

This output is not what I'm looking for.  It seems like maybe it's smoothing
the date data instead of discharge?

I tried messing around with other ways of inputting the data and I was
getting errors about the input being type "text" and "double" or something
like that.

I read up on: 
http://research.stowers-institute.org/efg/R/Statistics/loess.htm
http://research.stowers-institute.org/efg/R/Statistics/loess.htm   but I was
unable to figure out what I am doing wrong.

Does anyone have any suggestions to offer?

Thanks.

Billy

--
View this message in context: http://r.789695.n4.nabble.com/Difficulty-with-loess-function-tp3387537p3387537.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list