[R] R: Problems using log() in a plm() regression.
Millo Giovanni
Giovanni_Millo at Generali.com
Wed Nov 23 12:24:28 CET 2011
Hello. Just a quick follow-up, for other 'plm' users on the list:
- the problem turned out to be logs of zero values hidden in the big dataset
- trying log(xx) would not reveal the problem, because log(0)=-Inf is a valid result in log() while it is an invalid input to plm()
--> it is always advisable to try lm(yourformula, yourdata) as a first diagnostic check when plm(yourformula, yourdata, ...) fails: the result should be the same as plm(yourformula, yourdata, model="pooling"); or, for more complicated instances, a more specific "computationally robust" counterpart is lme() from 'nlme'.
Best,
Giovanni
-----Messaggio originale-----
Da: Millo Giovanni
Inviato: martedì 22 novembre 2011 13.14
A: 'steiner-manuel at web.de'
Cc: r-help at r-project.org
Oggetto: [R] Problems using log() in a plm() regression.
Hello Manuel.
Yes please, would you send me the data to reproduce the example? Else I cannot tell, although this error is typical of undefined logs (zero or negative argument).
Two general observations, for now:
- inserting special characters like '*' in variable names is looking for trouble
- a good first step in diagnosing 'plm' errors is always to check the same specification (formula+data) on lm()
Please remember to exclude the r-help list from the reply containing the dataset. I will treat it with confidentiality.
Let me know
Giovanni
Giovanni Millo, PhD
Research Dept.,
Assicurazioni Generali SpA
Via Machiavelli 4,
34132 Trieste (Italy)
tel. +39 040 671184
fax +39 040 671160
-------------- original message ----------------
Message: 17
Date: Mon, 21 Nov 2011 04:33:13 -0800 (PST)
From: ManuelS <steiner-manuel at web.de>
To: r-help at r-project.org
Subject: [R] Problems using log() in a plm() regression.
Message-ID: <1321878793485-4091377.post at n4.nabble.com>
Content-Type: text/plain; charset=us-ascii
hey guys
I have a panel data set that i want to perform some regressions on. I am using the /plm/ package.
I defined a model in the following way:
PWBw.pool <- plm(*PWB* ~ log(*I_EQON*) + log(*RD*) + ... + *PAGRI*, data = pfem, na.action=na.exclude, model="pooling")
When i run this it gives the following error (the error remains when i use other model = "" specifications like "within" or "random"):
/Fehler in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in externem Funktionsaufruf (arg 1) /
The translation would be something like:
/Error in lm.fit(x,y, offset = offset, singular.ok = singular.ok, ...) :
NA/NaN/Inf in external fuction call (arg 1)/
This error disappears and the regression work perfectly when i remove the
log() from *RD*. The log of *I_EQON* on the other hand poses no problem. I dont quite get that cause there is no difference in the variables *I_EQON* and *RD*:
They have:
1.) the same number of variables
2.) both NA's so that cant be it
3.) class: "numeric"
When performing /log() /on the variable *RD* simply like this (not within the plm command): log(pfem$*RD*) everything works out fine which in my opinion indicates that the problem is related to the/ plm()/ function.
Anyone any advise? If u need the data to run the regression please let me know so i can send them to you personally.
Thank you in advance.
Manu
--
View this message in context: http://r.789695.n4.nabble.com/Problems-using-log-in-a-plm-regression-tp4091377p4091377.html
Sent from the R help mailing list archive at Nabble.com.
------------ end original message ------------------
Ai sensi del D.Lgs. 196/2003 si precisa che le informazi...{{dropped:12}}
More information about the R-help
mailing list