[R-sig-Geo] [r-sig-geo] Please help to solve error of spml model in SPLM of R
Roger Bivand
Roger.Bivand at nhh.no
Wed Sep 26 10:28:21 CEST 2012
On Wed, 26 Sep 2012, gum hwang wrote:
> Hi Roger
>
> I have followed your advice.
> However, I had the same error like below:
>
> I'd welcome any comments from all of you.
You must check the lengths of each variable used - simplify to:
lm(mr2.tent ~ Census, data = mega.data)
first. If the error is still there, you know which variables to check.
This is very basic stuff, if you have missing values, you must drop those
observations. Try any(is.na()) too on each variable to find NAs.
Roger
>
>> mega.lm <- lm(
> +
> + mr2.tent ~ as.numeric(Census) + as.numeric(Den)
> + + as.numeric(CmtSch) + as.numeric(CmtPop)
> + + as.numeric(SchPop) + as.numeric(StayPop) + as.numeric(DayPop)
> + + as.numeric(firm) + as.numeric(firm500)
> + + as.numeric(RegWrk) + as.numeric(GrsWrk)
> + + as.numeric(MnfFirm) + as.numeric(MnfReg) + as.numeric(MnfGrs)
> +
> + , data = mega.data) ###, na.action=na.fail)
> Error in model.frame.default(formula = mr2.tent ~ as.numeric(Census) + :
> variable lengths differ (found for 'as.numeric(Census)')
>>
>
>
>
> On Tue, Sep 25, 2012 at 4:33 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>
>> On Tue, 25 Sep 2012, gum hwang wrote:
>>
>> Howdy, Grus
>>>
>>> If this message is overlapped, please forgive me.
>>>
>>> I have some troubles with SPLM package of R.
>>> I am trying to estimate some parameters and their model using SPML in SPLM
>>> package of R.
>>> Could you tell me some tips to solve my problem below ?
>>>
>>
>> Try:
>>
>> lm(fm.2, data = mega.data, na.action=na.fail)
>>
>> and see if you get the same error. It looks as though there are different
>> numbers of observations on some variables. Also always run traceback()
>> after any error you do not understand, to see the calling sequence of
>> functions. Here model.frame.default() was the failing function, which is
>> also called in lm(), hence my suggestion. It is also possible that you have
>> multiple objects called Census, say both in the global environment and in
>> mega.data.
>>
>> Hope this clarifies,
>>
>> Roger
>>
>>
>>
>>
>>> ------------------------------**------------------------------**
>>> ------------------------------**------------------------------**
>>> ------------------------------**--
>>> ...
>>> fm.2 <- mr2.tent ~ Census + Den + CmtSch + CmtPop + SchPop + StayPop +
>>> DayPop
>>> + firm + firm500 + RegWrk + GrsWrk + MnfFirm + MnfReg+ MnfGrs
>>> ...
>>>
>>>> fespaterr <- spml(fm.2, data = mega.data, listw = mat2listw(megaww),
>>>>
>>> model="within", spatial.error="b")
>>> Error in model.frame.default(object, data, xlev = xlev) :
>>> variable lengths differ (found for 'Census')
>>>
>>>>
>>>>
>>> For variaable reference,
>>> Y variable is mr2.tent.
>>> X variables are population and firm workers.
>>> Population is Census, Den, CmtSch, CmtPop, SchPop, StayPop, DayPop.
>>> Firms are firm and firm500.
>>> Firm workers are RegWrk, GrsWrk, MnfFirm, MnfReg, MnfGrs.
>>> ------------------------------**------------------------------**
>>> ------------------------------**------------------------------**
>>> ------------------------------**----
>>>
>>> I appreciate in advance,
>>>
>>>
>>>
>> --
>> Roger Bivand
>> Department of Economics, NHH 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, NHH 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