2015-01-12 3 views
0

10 개의 래스터 파일을 사용하여 회귀를 계산했습니다. 기울기와 Rsquared에 대한 래스터 출력을 얻을 수 있지만 잔차와 피팅 된 값을 생성하는 데 문제가 있습니다.회귀 잔차 및 적합 값 래스터 출력 R

########################################## 
require(raster) 
require(rgdal) 

#Create list of files 
rasters <- list.files(pattern='\\.tif$') 


time <- 1:nlayers(rasters) 
fun <- function(x) { if (is.na(x[1])){ NA } else { lm(x ~ time)$coefficients[2] }} 
slope <- calc(rasters, fun) 

time <- 1:nlayers(rasters) 
fun <- function(x) { if (is.na(x[1])){ NA } else { lm(x ~ time)$;summary(m)$r.squared }} 
Rsquared <- calc(rasters, fun) 

time <- 1:nlayers(rasters) 
fun <- function(x) { if (is.na(x[1])){ NA } else { lm(x ~ time)$;summary(m)$residuals }} 
residuals <- calc(rasters, fun) 

time <- 1:nlayers(rasters) 
fun <- function(x) { if (is.na(x[1])){ NA } else { lm(x ~ time)$;summary(m)$fitted.values }} 
fitted.values <- calc(rasters, fun) 
############################## 

가, 누군가가 나를 도울 수하십시오 : 여기

내 스크립트입니다?

덕분에 많은

gianca

+1

을 "일부 문제는"무엇인지 자세히 적어주세요. 오류가 있습니까? 문제를 [reproducible] (http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)하기위한 입력을 제공하지 않으므로 우리는 무엇을 알지 못합니다. 문제는. – MrFlick

답변

0

당신은 LM의 기능을 연구 할 필요가있다. 예를 장착하려면 (예측) 값의 경우, 당신은 할 수 있습니다 :

y = runif(10) 
x = 1:10 
m = lm(y~x) 
predict(m) 

하지만

summary(m)$fitted.values