[R-sig-Geo] gridded time series analysis

tiffanysmith smithtiffanyt at gmail.com
Thu May 3 16:56:57 CEST 2012


I've done the following linear regression of my gridded data vs. time:

data<-brick("data.nc")
time<-seq(1979,2011,1)
fun.lm<-function(x) {lm(x~time)$coefficients[2]} 
lm.data<-calc(data,fun.lm)

Then, I was trying to get the R^2 values, but keep getting an error:

> fun=function(x){if (in.na(x[1])){NA}else{m<-lm(x[1]~x[2])$coefficients[2];
> summary(m)$r.squared }}
> r2.data<-calc(data,fun)
Error in .local(x, fun, ...) : cannot use this function

How do I actually print out the R^2 values? Also, is there a way to mask the
output raster from the linear regression w. a 95%sig level?

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/gridded-time-series-analysis-tp5775651p7523889.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list