gridded time series analysis
Martin, I think the problem is whith the lm function that returns an error rather than NA:
a <- rep(NA,10) lm(a~a)
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases #rather than something like this:
fun=function(x) { lm(x[1]~x[2])$coefficients[2] }
fun(c(NA,NA))
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (non-NA) cases #you could catch this in your function and do something like:
fun=function(x) { if (is.na(x[1])){ NA } else { lm(x[1]~x[2])$coefficients[2] }}
fun(c(NA,NA))
[1] NA and then: calc(s, fun=fun) lm and relatives have an na.action argument but I do not think that can come to the rescue here. Roberrt
On Sun, Nov 28, 2010 at 4:33 AM, Martin <martin_brandt at gmx.net> wrote:
thanks Robert, this works fine. but could it be that the functions have a problem with NA-values? your Regression functions return this error:
x3 <- calc(tt, fun)
error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : ?0 (non-NA) cases when i use rasters with NA values...it works without problems with rasters without NAs.. cheers, Martin -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/gridded-time-series-analysis-tp5775651p5781554.html Sent from the R-sig-geo mailing list archive at Nabble.com.
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo