Wooldridge Tahmin
library(wooldridge)
## Warning: package 'wooldridge' was built under R version 4.1.3
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2.3. 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=1999)
model2<-dynlm(unem~L(unem) + L(inf),data=tsph, end=1999)
stargazer(model1,model2,type ="text" )
##
## =================================================================
## Dependent variable:
## ---------------------------------------------
## unem
## (1) (2)
## -----------------------------------------------------------------
## L(unem) 0.745*** 0.652***
## (0.094) (0.081)
##
## L(inf) 0.187***
## (0.040)
##
## Constant 1.461** 1.238**
## (0.555) (0.467)
##
## -----------------------------------------------------------------
## Observations 51 51
## R2 0.562 0.699
## Adjusted R2 0.553 0.687
## Residual Std. Error 1.028 (df = 49) 0.860 (df = 48)
## F Statistic 62.750*** (df = 1; 49) 55.795*** (df = 2; 48)
## =================================================================
## 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.2807224
mae
## [1] 0.2400926
rmse2<-sqrt(mean(e2^2))
mae2<-mean(abs(e2))
rmse2
## [1] 0.3125684
mae2
## [1] 0.2464004