library(stargazer) sample1<-("http://kanggc.iptime.org/book/data/korea(77-93)-1.txt") sample1_dat<-read.delim(sample1,header=T) gnp<-ts(sample1_dat$gnp, start=c(1977,1), frequency=4) def<-ts(sample1_dat$def, start=c(1977,1), frequency=4) m2<-ts(sample1_dat$m2, start=c(1977,1), frequency=4) ols.res<-lm(m2~gnp+def) summary(ols.res) res<-resid(ols.res) res.t<-ts(res) nm2<-m2/sqrt(gnp) nc<-1/sqrt(gnp) ngnp<-sqrt(gnp) ndef<-def/sqrt(gnp) wls.lm<-lm(nm2~nc+ngnp+ndef-1) summary(wls.lm) w0<-1/gnp gls.lm<-lm(m2~gnp+def, weight=w0) summary(gls.lm) stargazer(ols.res, wls.lm, gls.lm, type="text")