Translate

Tuesday, July 4, 2017

Total Construction Spending: Residential (TLRESCONS)

Total Construction Spending on Residential (TLRESCONS) as of May 2017 is shown below. The spending is still below the peak before the financial crisis.


The spending on residential construction has been increasing above 10% since 2011. The spending on construction spending has been increasing at 2.7% as of May 2017. 
 The monthly changes in construction spending on residential decreased in May 2017.
 However, the changes from the same period in a previous year is still above 10%.
 The changes from the previous year will gradually decline in near future.


Source: Bureau of Census



The following R codes generate the charts above:

library(Quandl)
library(ggplot2)
library(forecast)
library(quantmod)

getSymbols('TLRESCONS', src='FRED' ) # FRED

mydata<-(TLRESCONS)


write.table(mydata, "mydata.txt",  sep=" ")

chartSeries(mydata)

names (mydata)[1] <- "Value"



Annual_Return <- annualReturn(mydata)*100
Monthly_Return <- monthlyReturn(mydata)*100
Weekly_Return <- weeklyReturn(mydata)*100


Diff=Delt(mydata, k=12)*100

plot(Diff, main='Changes from previous year')



summary(Monthly_Return)

Annual_Return

plot(Monthly_Return)

chartSeries(Monthly_Return)
addEMA()
addBBands()


barplot(Annual_Return, main='Annual Changes', col='blue')

barplot(last(Monthly_Return, '5 year'), main='Monthly Changes', col='red')


#Historigram

hist(Monthly_Return,
     main="Histogram of Monthly Changes",
     xlab="blue",
     col="green",
     prob=TRUE
   
     )
lines(density(Monthly_Return))


barplot(Monthly, main='Monthly Changes',xlab='Year',
        ylab= 'Percent Changes', col='red')


fit <- arima(Diff, order=c(1, 0, 0))

fit


# predictive accuracy
library(forecast)
accuracy(fit)

# predict next 5 observations
library(forecast)
forecast(fit, 12)
plot(forecast(fit,12))

No comments:

Post a Comment