Wooldridge Tahmin

library(wooldridge)
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(rmarkdown)
library(dynlm)
## Zorunlu paket yükleniyor: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
data(phillips, package = "wooldridge")
paged_table(phillips)
tsph<-ts(phillips, start = 1948)
plot(tsph[,"unem"],lty=1, lwd=1, ylim=c(0,15), ylab=("işz ve enf"))
lines(tsph[,"inf"],lty=2, lwd=2)
legend("topright", c("işsizlik","enflasyon"), lty=c(1,2), lwd = c(1,2))

model1<-dynlm(unem~L(unem),data=tsph, end=1996)
model2<-dynlm(unem~L(unem) + L(inf),data=tsph, end=1996)
stargazer(model1,model2,type ="text" )
## 
## =================================================================
##                                  Dependent variable:             
##                     ---------------------------------------------
##                                         unem                     
##                              (1)                    (2)          
## -----------------------------------------------------------------
## L(unem)                    0.732***               0.647***       
##                            (0.097)                (0.084)        
##                                                                  
## L(inf)                                            0.184***       
##                                                   (0.041)        
##                                                                  
## Constant                   1.572***               1.304**        
##                            (0.577)                (0.490)        
##                                                                  
## -----------------------------------------------------------------
## Observations                  48                     48          
## R2                          0.554                  0.691         
## Adjusted R2                 0.544                  0.677         
## Residual Std. Error    1.049 (df = 46)        0.883 (df = 45)    
## F Statistic         57.132*** (df = 1; 46) 50.219*** (df = 2; 45)
## =================================================================
## Note:                                 *p<0.1; **p<0.05; ***p<0.01
f1<-predict(model1,newdata = window(tsph,start=1997))
f2<-predict(model2,newdata = window(tsph,start=1997))
y<-window(tsph,start=1997)[,"unem"]
time=c(1997:2003)
matplot(time,cbind(y,f1,f2),type = "l",lwd=2,lty=1:3, ylim = c(4,7))
legend("topleft", c("işsizlik","tahmin1","tahmin2"),lwd=2,lty = 1:3)

e1<-y-f1
e2<-y-f2
rmse<-sqrt(mean(e1^2))
mae<-mean(abs(e1))
rmse
## [1] 0.3247281
mae
## [1] 0.2738516
rmse2<-sqrt(mean(e2^2))
mae2<-mean(abs(e2))
rmse2
## [1] 0.3135421
mae2
## [1] 0.2455728