[R-sig-Geo] SPLM sphtest Hausman test not working with Maximum Likelihood

Patrick Meyfroidt patrick.meyfroidt at uclouvain.be
Fri Feb 28 16:15:22 CET 2014


Apologies Roger, I really was not making a silly remark, and I'm very sorry that it was taken as such.
At the contrary, I wrote that because several people already suggested me to move to Matlab for doing this spatial Hausman test, so, thereby I wanted to indicate that, OK, I was aware of that possible solution, but that ws not my option. Indeed, I wanted to see if raising that issue here could help to move further with splm. 

I'm extremely aware of the tremendous efforts done by developers here, and I could not be more grateful. And indeed especially to Giovanni Millo who's been already very helpful trough direct contacts for previous issues. And to be honest, because I was not sure whether this was a issue with the package itself or an error of my own, I preferred to ask the list precisely to not disturb the package's maintainers again. 

So, apologies again for the misunderstanding, that was really the meaning of what I wrote, and I'll do my best to learn how to debug. 

Thank you very much,

Patrick





________________________________________
De : Roger Bivand <Roger.Bivand at nhh.no>
Envoyé : vendredi 28 février 2014 15:58
À : Patrick Meyfroidt
Cc : r-sig-geo at r-project.org; giovanni_millo at generali.com; gpiras at mac.com
Objet : RE: [R-sig-Geo] SPLM sphtest Hausman test not working with Maximum Likelihood

On Fri, 28 Feb 2014, Patrick Meyfroidt wrote:

> Thanks Roger, and sorry.
>
> My code and data are a bit long to put here, but thanks to Caleb
> Gallemore which had a similar problem, I can post here a test code that
> he made for students, which uses data from Ecdat package.
>
> This code below, as well as my code, were tested with:
> R 2.15.1 and splm_1.1-0 (the current stable version)
> and R 3.0.2 and splm_1.2-0 (the development version)
>
> I hope that this addresses your rightful concerns,
>
> Now, if anyone has a suggestion (other than moving to Matlab..), that
> would be very welcome?

<flare>Feel free, silly remarks really motivate us to improve the
software</flare>, seriously, have you any idea how much of their own time
R and package developers use to keep all this running?

The actual response below - if you want to benefit from community effort,
do try to understand how things work. If you are "above that", just keep
to our rules here and keep your jokes to yourself.

>
> Patrick
>
>
> # CODE OF REPRODUCIBLE EXAMPLE:
> #-------------------------------------------------------------------------------
>

library(Ecdat)
library(plm)
data(Produc) #THIS IS THE DATA
library(splm)
library(spdep)
data(usaww) #THIS IS THE ROW-STANDARDIZED QUEEN'S CASE CONTIGUITY WEIGHTS MATRIX FOR
prod.panel <- pdata.frame(Produc, index = c("state", "year"))
usa.sp <- mat2listw(usaww) #JUST WHAT IT SOUNDS LIKE; TURNS A MATRIX INTO A SPATIAL
prod.fm <- log(gsp) ~ 1 + log(pcap) + log(pc) + log(emp)
sphtest(prod.fm, data=prod.panel, listw=usa.sp, spatial.model="sarar",
   method="ML")

shortens this somewhat, the rest is superfluous and is not a big deal. The
error is reproducible with 1.1-0 and 1.2-0. I've CC'd the maintainer.

Standard practice is to run traceback() to identify the failing function:

> traceback()
5: stop("'arg' must be NULL or a character vector")
4: match.arg(spatial.error)
3: spml(x, data = data, index = index, listw = listw, lag = lag,
        spatial.error = spatial.error, model = "within", errors = errors)
2: sphtest.formula(prod.fm, data = prod.panel, listw = usa.sp,
spatial.model = "sarar", method = "ML")
1: sphtest(prod.fm, data = prod.panel, listw = usa.sp, spatial.model =
"sarar", method = "ML")

here spml.

Running inside debug(spml) shows that match.arg(spatial.error) occurs in a
context where it has been given a logical value TRUE by sphtest.formula,
but should be one of c("b","kkp","none").

The package has been being simplified and the arguments have got mixed up,
it happens. The examples for sphtest() only check its performance with
method="GM" - they work OK, so additional checks with method="ML" are
needed, but perhaps within a \donttest block, once the problem has been
resolved.

Users who find issues with software are expected to help developers
promptly, in a case like this by doing as much of the debugging as
possible themselves, and then at least contacting the maintainer of the
involved package.

>From viewing the SVN repository, it isn't immediately obvious where the
bug has come from, but spatial.error is used in sphtest.formula with lag
to pass through the kind of model rather than the type of spatial error.
The authors of the package would welcome further analysis and patches.

Roger

>
> # HERE IS THE PROBLEM: THE TEST RETURNS:
> # "Error in match.arg(spatial.error) :   'arg' must be NULL or a character vector"
>
> # JUST TO CHECK: THE RANDOM EFFECTS AND FIXED EFFECTS MODELS DO WORK PROPERLY:
> prod.fm.rd <- spml(formula = prod.fm,
>                       data = prod.panel,
>                       listw = usa.sp,
>                       listw2 = usa.sp,
>                       model = "random",
>                       effect = "individual",
>                       lag = TRUE,
>                       spatial.error = "b")
> summary.splm(prod.fm.rd)
> prod.fm.fe <- spml(formula = prod.fm,
>                       data = prod.panel,
>                       listw = usa.sp,
>                       listw2 = usa.sp,
>                       model = "within",
>                       effect = "individual",
>                       lag = TRUE,
>                       spatial.error = "b")
> summary.splm(prod.fm.fe)
>
> #-------------------------------------------------------------------------------
>
>
>
>
> ________________________________________
> De : Roger Bivand <Roger.Bivand at nhh.no>
> Envoyé : mardi 25 février 2014 15:11
> À : Patrick Meyfroidt
> Cc : r-sig-geo at r-project.org
> Objet : Re: [R-sig-Geo] SPLM sphtest Hausman test not working with Maximum Likelihood
>
> On Tue, 25 Feb 2014, Patrick Meyfroidt wrote:
>
>> Dear List,
>>
>> I have a problem using splm package: across various datasets and models,
>> the sphtest function never works when I try to calculate the Hausman
>> test with a model using Maximum Likelihood. I always receive the
>> following error message:
>>
>> Error in match.arg(spatial.error) :
>>  'arg' must be NULL or a character vector
>>
>> I see that several other people posted the same problem before, but
>> apparently there was not solution proposed on the list: in September
>> 2011:
>> https://stat.ethz.ch/pipermail/r-sig-geo/2011-September/012826.html and
>> in May 2013:
>> https://stat.ethz.ch/pipermail/r-sig-geo/2013-May/018256.html
>>
>> Does anyone have a solution?
>
> Please never guess, it only misleads you and readers of your posting.
>
> Please always state the output of sessionInfo() - we don't know which
> version of splm you are using.
>
> Please always include a reproducible example of the code leading to the
> error with a built in data set.
>
> Do check that the problem is not already resolved in the development
> version on R-forge, here:
>
> https://r-forge.r-project.org/R/?group_id=352
>
>>
>> Thank you very much,
>>
>>
>> Patrick Meyfroidt ------ F.R.S. - FNRS and Universit? catholique de
>> Louvain - UCLouvain
>>
>>
>>       [[alternative HTML version deleted]]
>
> Finally, do not post HTML, much of the extensive carbon footprint of lists
> like this comes from scanning HTML postings for unwanted and/or dangerous
> payloads.
>
> Hope this helps,
>
> Roger
>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no

--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list