Message-ID: <1336057017432-7523889.post@n2.nabble.com>
Date: 2012-05-03T14:56:57Z
From: tiffanysmith
Subject: gridded time series analysis
In-Reply-To: <AANLkTi=+3SAuZY0N_7aHcb14zAV3uvC8NN1RGKSou-09@mail.gmail.com>
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.