Skip to content

AIC/R^2 in splm

1 message · Tobias Rüttenauer

#
extraction
Most extract functions do not support "splm" class. You can try to access
the functions for objects of a similar class and rearrange it for splm.
I can
intercept
If you use the same data for different models (having the same number of
time dummies), it does not matter if you include or exclude these dummies.
obtain
If you receive the log Likelihood in your spml model output (
summary(fesar.mod)$logLik ), you can use the following function to calculate
the AIC (it includes the spatial lag as one parameter and the spatial error
as one parameter):

#### AIC function for spml ####

godf.spml<-function(object, k=2, criterion=c("AIC", "BIC"),  ...){
  s<-summary(object)
  l<-s$logLik[1,1]
  np<- length(coef(s))
  N<- nrow(s$model)
  if(criterion=="AIC"){
    aic<- -2*l+k*np
    names(aic)<-"AIC"
    return(aic)
  }
  if(criterion=="BIC"){
    bic<- -2*l+log(N)*np
    names(bic)<-"BIC"
    if(k!=2){
      warning("parameter <k> not used for BIC")
    }
    return(bic)
  }
}

Example:

require(splm)
fesar.mod<-spml(formula= y~x1+x2, data=data.pd, ...)
godf.spml(fesar.mod, criterion="AIC")


If your spml model output does not contain a value for logLik, see here how
to fix this:
http://r-sig-geo.2731867.n2.nabble.com/spml-and-logLik-help-td7581581.html

There is an R squared reported in the model output:

summary(fesar.mod)$rsqr

Unfortunately it is not documented what kind of (Pseudo)-R squared this is
(to my knowledge).

Best
Tobi