[R-sig-Geo] negative r-squares

Pinar Aslantas Bostan aslantas at metu.edu.tr
Thu Sep 9 16:42:07 CEST 2010


Hi all,

I am working about comparison of kriging and regression methods. I  
have one dependent (PREC) and seven independent variables. I created  
10 different test and train datasets. I am using train datasets for  
building the models and test datasets for calculating error (RMSE) and  
r-squares. When I obtained prediction values for grid, then I use  
overlay() to get predictions for test dataset. For example:

# regression kriging
# dem is the grid (I want to get predictions for each pixel of dem)  
and dem$rk.pred1 contains regression kriging predictions
> test1$rk.predicted = dem$rk.pred1[overlay(dem, test1)]

# calculating r-square values based on test values
> ss <-(test1$PREC-mean(test1$PREC))*(test1$PREC-mean(test1$PREC))
> sst1<-sum(ss)
> e <-(test1$PREC-test1$rk.predicted)*(test1$PREC-test1$rk.predicted)
> sse.rk<-sum(e)
> rk1.r.square<-1-(sse.rk/sst1)

My problem is that, for some datasets the methods can be resulted with  
negative r-squares. Here I gave an example about regression kriging  
but also same problem may occur for linear regression. I checked the  
dependent and independent variables and there is no problem with them.  
Are there anyone who knows another function instead of overlay() for  
the same purpose? (I thougt that maybe the problem is because of  
overlay function) or do you have any idea about reason of negative  
r-square values?

Best regards,
Pinar


********************************************************************************
Pinar Aslantas Bostan
Research Assistant
Department of Geodetic and
Geographic Information Technologies (GGIT)
Middle East Technical University
06531 Ankara/TURKEY
aslantas at metu.edu.tr



More information about the R-sig-Geo mailing list