prophecy.plm.out: Out of Sample Prediction of Panel Data Estimations

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/plmNeviim.R

Description

blup

Usage

1
2
prophecy.plm.out(estimate, data, pindex = NULL, pname = "y",
  levelconstr = T, add.model.matrix = F)

Arguments

estimate

a plm object,

data

a data.frame to use for the outcome predictions,

pindex

the panel index of the estimate.

pname

the predicted outcome name. Defalt is "y",

levelconstr

logical, if true a estimation of a logarithmic outcome is assumed and the level outcome is additonally created

Details

plmNeviim, or plm Prophets creates out of sample predicitons based on Panel Data estimates. Original estimate coefficients are used be to create predicted values of outcomes using the original dataset or a new dataset with equal column names.

Value

a data frame with fitted / predicted values

Note

Blup

Author(s)

Elías Cisneros <[email protected]>

References

https://rdrr.io/rforge/plm/src/R/plm.R
https://r-forge.r-project.org/scm/viewvc.php/pkg/R/pfunctions.R?view=markup&root=plm&sortdir=down
https://stackoverflow.com/questions/23143428/merge-plm-fitted-values-to-dataset/44185726#44185726
http://r.789695.n4.nabble.com/fitted-from-plm-td3003924.html
https://stackoverflow.com/questions/7123060/is-there-a-predict-function-for-plm-in-r/44185441#44185441
https://stackoverflow.com/questions/7123060/is-there-a-predict-function-for-plm-in-r/44185441#44185441

See Also

plm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
##packages
library(plm)
library(plmNeviim)
library(spd4testing)

#data
d<-spd4testing(missingX=T,missingY=T,missing.pre.years=T)
d

#test
#new data
o<-spd4testing(missingX=FALSE)
o

#formula
f<- formula(y ~ x + factor(year)*factor(gid))

#fixed effects or first difffernce estimation
e<-plm(f,data=d,model="within")
e<-plm(f,data=d,model="fd")
summary(e)

##fitted values
#with the plm-extended predict funciton
predict(e)
#from the plm object information
c(pmodel.response(e)-residuals(e)) #(shows row names)

##prediciton with plmNeviim
#fitted values
x<-prophecy.plm.out(estimate=e,data=d,pindex=c("id","year"),levelconstr=FALSE)
x$y.t.hat
#level construct
x<-prophecy.plm.out(estimate=e,data=d,pindex=c("id","year"),levelconstr=TRUE)
x[,c("id","year","y.l","y.t.hat","y.l.hat")]

#out of sample prediciton
x<-prophecy.plm.out(estimate=e,data=o,pindex=c("id","year"),levelconstr=TRUE)
x[,c("id","year","y.l","y.t.hat","y.l.hat")]


## Not run: 
##standard out of sampel prediciton
predict(e,newdata=d)
predict(e,newdata=dn)
# Error in crossprod(beta, t(X)) : non-conformable arguments
# Whenever plm omits variables specified in the formula (e.g. base year in factor(year))
# it tries to multiply two matrices with different length of columns than regressors
# the new funciton avoids this and therefore is able to apply out of sample predicitons
# predict.out.plm(e,f,dn,"fd")

## End(Not run)

eliascis/plmNeviim documentation built on Oct. 31, 2017, 5:28 a.m.