[R] Marginal effects with plm

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


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/



> -----Original Message-----
> From: R-help [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>
> 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 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