[R] Marginal effects with plm

Fox, John j|ox @end|ng |rom mcm@@ter@c@
Thu Sep 6 14:16:01 CEST 2018


Dear Milu,

Effect() doesn't have a specific plm method so the default method is invoked. Before responding to your initial question. I tried Effect() with an example from ?plm and it worked.

Without a reproducible example that produces the error that you encountered, there's no way to answer your question.

Best,
 John

> -----Original Message-----
> From: Miluji Sb [mailto:milujisb using gmail.com]
> Sent: Thursday, September 6, 2018 5:37 AM
> To: Fox, John <jfox using mcmaster.ca>
> Cc: r-help mailing list <r-help using r-project.org>
> Subject: Re: [R] Marginal effects with plm
> 
> Dear John,
> 
> Thank you very much for the solution and the suggestion. I have tried the
> following;
> 
> plm1 <- plm(formula = log(gva_ind) ~  poly(x1, 2, raw=TRUE) +
> heat*debt_dummy + tt, data = df, index=c("region","year"))
> 
> Ef.hd <- Effect(c("heat", "debt_dummy"), plm1)
> 
> 
> But get the following error;  - Error in UseMethod("droplevels") : no applicable
> method for 'droplevels' applied to an object of class "NULL"
> 
> Is this something to do with the way the plm object? Thanks again!
> 
> Sincerely,
> 
> Milu
> 
> On Thu, Sep 6, 2018 at 1:12 AM Fox, John <jfox using mcmaster.ca
> <mailto:jfox using mcmaster.ca> > wrote:
> 
> 
> 	Dear Milu,
> 
> 	Depending upon what you mean by "marginal effects," you might try
> the effects package. For example, for your model, try
> 
> 	        (Ef.hd <- Effect(c("heat", "debt_dummy"), plm1))
> 	        plot(Ef.hd)
> 
> 	A couple of comments about the model: I'd prefer to specify the
> formula as log(y) ~ poly(x1, 2) + heat*debt + tt or log(y) ~ poly(x1, 2,
> raw=TRUE) + heat*debt + tt (assuming that debt_dummy is a precoded
> dummy regressor for a factor debt).
> 
> 	I hope this helps,
> 	 John
> 
> 	--------------------------------------
> 	John Fox, Professor Emeritus
> 	McMaster University
> 	Hamilton, Ontario, Canada
> 	Web: socialsciences.mcmaster.ca/jfox/
> <http://socialsciences.mcmaster.ca/jfox/>
> 
> 
> 
> 	> -----Original Message-----
> 	> From: R-help [mailto:r-help-bounces using r-project.org <mailto:r-help-
> bounces using r-project.org> ] On Behalf Of Miluji
> 	> Sb
> 	> Sent: Wednesday, September 5, 2018 6:30 PM
> 	> To: r-help mailing list <r-help using r-project.org <mailto:r-help using r-
> project.org> >
> 	> Subject: [R] Marginal effects with plm
> 	>
> 	> Dear all,
> 	>
> 	> I am running the following panel regression;
> 	>
> 	> plm1 <- plm(formula = log(y) ~ x1 + I(x1^2) + heat*debt_dummy + tt,
> data
> 	> = df, index=c("region","year"))
> 	>
> 	> where 'df' is a pdata.frame. I would like to obtain marginal effects of
> 	> 'y'
> 	> for the variable 'x1'. I have tried the packages 'prediction' and
> 	> 'margins'
> 	> without luck.
> 	>
> 	> Is it possible to obtain marginal effects with 'plm'? Any help will be
> 	> highly appreciated. Thank you.
> 	>
> 	> Error in UseMethod("predict") :
> 	>   no applicable method for 'predict' applied to an object of class
> 	> "c('plm', 'panelmodel')"
> 	>
> 	> Sincerely,
> 	>
> 	> Milu
> 	>
> 	>       [[alternative HTML version deleted]]
> 	>
> 	> ______________________________________________
> 	> R-help using r-project.org <mailto:R-help using r-project.org>  mailing list --
> To UNSUBSCRIBE and more, see
> 	> https://stat.ethz.ch/mailman/listinfo/r-help
> 	> PLEASE do read the posting guide http://www.R-project.org/posting-
> 	> guide.html
> 	> and provide commented, minimal, self-contained, reproducible
> code.
> 



More information about the R-help mailing list