how do you load function "pmg" onto R?
The pmg
function appears to be from the plm
R package.
If you haven't already, first you need to install the plm
package to your local machine.
# first, you need to install the package
# that has this function onto your machine
# once you've done this one, you don't need to do it again,
# (unless, possibly, if you upgrade R or other packages that interact with it)
install.packages('plm')
Then, you can load the package, and use the pmg
function.
#this loads the plm package
# which gives you acces to the pmg function
library(plm)
#> Loading required package: Formula
# for example, from help(plm) examples:
data("Produc", package = "plm")
## Mean Groups estimator
mgmod <- pmg(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc)
summary(mgmod)
#> Mean Groups model
#> Call:
#> pmg(formula = log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp,
#> data = Produc)
#>
#> Balanced Panel: n = 48, T = 17, N = 816
#>
#> Residuals:
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> -0.0828079 -0.0118150 0.0004247 0.0000000 0.0126479 0.1189647
#>
#> Coefficients:
#> Estimate Std. Error z-value Pr(>|z|)
#> (Intercept) 2.6722392 0.4126515 6.4758 9.433e-11 ***
#> log(pcap) -0.1048507 0.0799132 -1.3121 0.18950
#> log(pc) 0.2182539 0.0500862 4.3576 1.315e-05 ***
#> log(emp) 0.9334776 0.0750072 12.4452 < 2.2e-16 ***
#> unemp -0.0037216 0.0016427 -2.2655 0.02348 *
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> Total Sum of Squares: 849.81
#> Residual Sum of Squares: 0.33009
#> Multiple R-squared: 0.99961
Created on 2018-09-28 by the reprex package (v0.2.1)
2 Likes
I get the message “package ‘pmg’ is not available (for R version 3.5.1)”
That error suggests that you're trying to install a package called pmg
(which doesn't exist), i.e., you probably executed
install.packages('pmg')
As Curtis noted, the function pmg
is part of the package plm
, so you need to install plm
, not pmg
. Just execute
install.packages('plm')
at the console prompt and you won't get that error anymore.
1 Like