UPNEWS.CN城市更新工作台
LEGACY INTELLIGENCE ARCHIVE

房地产价格的可视化思考︱篇六:美国各州的房价回升

全国微文2017.03.02UPNEWS · 规划头条
内容摘要

2017编辑团队原文/ Len Kiefer 翻译/ 薛雅宁 总校/ 徐蜀辰 文献/ 刘子铭 排版/ 徐逸菁 编辑/ 众山小译者萌像&导读:经过2008年的经济大萧条,美国的房价也有一定的跌落。为了研究2008年美国经济大萧条后房价的回升,作者利用每个州的房价数据,绘制了各个州房价自08年以来的增长趋势,同时也绘制了各个州房价的动态变化趋势。最后,作者还附上了相应的R语言的代码。2017年3月1日刊 篇陆 房地产价格可视化专刊◆ ◆ ◆…

ARCHIVED CONTENT

历史正文

2017编辑团队原文/ Len Kiefer    翻译/ 薛雅宁 总校/ 徐蜀辰     文献/ 刘子铭   排版/ 徐逸菁     编辑/ 众山小译者萌像&导读:经过2008年的经济大萧条,美国的房价也有一定的跌落。为了研究2008年美国经济大萧条后房价的回升,作者利用每个州的房价数据,绘制了各个州房价自08年以来的增长趋势,同时也绘制了各个州房价的动态变化趋势。最后,作者还附上了相应的R语言的代码。2017年3月1日刊 篇陆  房地产价格可视化专刊◆ ◆ ◆ ◆本文是我房地产数据可视化系列中的第六部分,以下是前五期的内容:篇一:数据清洗篇二:动画迷你图和点图篇三:气泡图和波动篇四:数据图表示例篇五:房价分布(这些可视化都是用R制作的,部分图表的代码将会放置在文章结尾。)◆ ◆ ◆ ◆简介目前,根据一些指标,我们可以发现房价已经恢复到了经济萧条前的峰值。例如,房地美的房价指数显示2016年9月份的房价数据已经超过了2008年之前的房价峰值。基于这份报告,本文将对房价的趋势进行探索,同时探索展示房价升高的不同方式,同时在一些个别案例中,将探索房价将还会升高多少。基于个人偏好,下面列出了一些优先猜想,同时我将对下满列出的所有内容持续更新。数据正如前面提到的,本文大部分的可视化将应用房地美的房价数据。我们将需要一个按照发布的帖子组织好的文本数据。只需要按照下述的两个例子设置数据,或者你可以下载下面的两个文本数据。1.    全国与州价格文件 fmhpi.txt2.    城市价格文件 fmhpi2.txt(参考数据,请前往篇一)图一、成图这些图展示了美国季节性变化的指数。在2016年9月的指数为165.25,比2008年之前的峰值165.06高出0.1%。指数在全国范围内有所不同。尽管全国的平均值高于2008年前的峰值,但是具体到每个州是有所不同的,有的州指数高于平均值,有些低于平均值。各州趋势地图:首先,让我们看一下从2015年9月到2016年9月,各个州的年度房价的评估地图。图二、成图我们可以将这个地图与利用百分比差异展示2016年9月的指数和2008年之前的峰值数据的地图进行对比。图三、全美峰值对比这个地图显示北达科他州,科罗拉多州和德克萨斯州与2008年之前的房价相比上升趋势幅度较大(分别是45%,38%和35%)。相反而言,内华达州、康涅狄格州和亚利桑那州是相对2008年以前增长幅度最低的,分别是-24%,-20%和-15%。根据年复一年房价的评估,对比各个州的排序,可以发现有趣的结论。图四、各州对比图我们也可以绘制出包含前几年数据的面板图。图五、各州对比图在美国中部,在房价复苏的时候,从德克萨斯州到到北达科他州,都是房价增长最迅速的(或者是降低最快的)。但是,随着房价复苏的进一步深入,在西部以及佛罗里达州增长逐渐加速。下面的动态图表显示了从1980-2016年的所有9月各个州排名的变化。图六、各个州以及DC特区的年房价增长趋势(级别分为:1-511)点图:在前面的研究中,我描述了如何制作下面的点图。图七、点图这个图显示了相对于过去的12个月2016年9月的房价指数的值。点颜色的深浅表示房价估值的不同等级,同时尾巴的长短代表过去12个月里的指数变化范围。夏威夷有最高的指数的值(意味着与2000年10月的房价相比,夏威夷的房价是增长最快的),但是每年同比增长最快的是在华盛顿州。你可以看到图表中,点的颜色为蓝色的增长幅度最大,同时尾巴的长度最长的变化范围越大。这是一个有趣的动态变化图。图八、各个州房价的动态变化图(级别分为:1-511)绘图的相应代码这是我绘图所使用的代码,使用的数据文件是之前介绍的。需要说明的是,我使用的是R语言和ggplot2的进阶版本。#Load some packages 载入一些程序包library(data.table, warn.conflicts = FALSE, quietly=TRUE)library(ggplot2, warn.conflicts = FALSE, quietly=TRUE)library(dplyr, warn.conflicts = FALSE, quietly=TRUE)library(zoo, warn.conflicts = FALSE, quietly=TRUE)library(ggrepel, warn.conflicts = FALSE, quietly=TRUE)library(ggthemes, warn.conflicts = FALSE, quietly=TRUE)library(scales, warn.conflicts = FALSE, quietly=TRUE)library(animation, warn.conflicts = FALSE, quietly=TRUE)library(grid, warn.conflicts = FALSE, quietly=TRUE)library(tidyr, warn.conflicts = FALSE, quietly=TRUE)library(rgeos, warn.conflicts = FALSE, quietly=TRUE)library(maptools, warn.conflicts = FALSE, quietly=TRUE)library(albersusa, warn.conflicts = FALSE, quietly=TRUE) #load data 载入数据statedata <- fread("data/fmhpi2016q3.txt")statedata$date<-as.Date(statedata$date, format="%m/%d/%Y") #Now uses some data table calculations to compute percent changes in house prices by state/metro# 现在以州或者地铁为单位的使用数据集合计算结果来计算房价的百分比变化statedata<-statedata[,hpa:=c(NA,((1+diff(hpi)/hpi))^12)-1,by=state] statedata<-statedata[,hpa12:=c(rep(NA,12),((1+diff(hpi,12)/hpi))^1)-1,by=state]  #compute pre-2008 peak 计算200年以前的峰值statedata[,hpi.max08:=max(ifelse(year<2009,hpi,0),na.rm=T),by=state] #compute post-2008 trough 计算过去2008年的所有值statedata[,hpi.min08:=min(ifelse(year>2008,hpi,1000),na.rm=T),by=state]  #do map stuff 绘制地图states<-usa_composite()statedata[,iso_3166_2:=state]  #rename state to match usa_compositestatedata[,hpi.comp:=hpi/hpi.max08-1]  #compute house price growth relative to pre-2008 peakstatedata<-statedata[!(state %in% c("US.SA","US.NSA"))]statedata[,hparank:=rank(-hpa12),by=date] #create an indicator for house price appreciation relative to pre-2008 peak#依据2008年以前的峰值创建一个新的房价评估的指数statedata[,hpi.compd:=ifelse(hpi.comp< -0.25,"<-25%",                             ifelse(hpi.comp< -0.05,"-25% to -5%",                              ifelse(hpi.comp<0,"-5% to 0%",                              ifelse(hpi.comp<0.05,"0% to +5%",                           ifelse(hpi.comp<0.25,"+5% to +25%",                                                         ">+25%")))))     ]statedata$hpi.compd<-factor(statedata$hpi.compd, levels=unique(statedata$hpi.compd))smap<-fortify(states,region="fips_state")states@data <- left_join(states@data, statedata, by = "iso_3166_2")   #make annual percent change map:绘制年百分比变化图ggplot() +  geom_map(data = smap, map = smap,           aes(x = long, y = lat, map_id = id),           color = "#2b2b2b", size = 0.05, fill = NA) +  geom_map(data =subset(states@data,year==2016 & month==9), map = smap,            aes( map_id = fips_state,fill=hpa12),           color = "gray", size = .25) +   theme_map( base_size = 12) +  theme(plot.title=element_text( size = 16, margin=margin(b=10))) +  theme(plot.subtitle=element_text(size = 14, margin=margin(b=-20))) +  theme(plot.caption=element_text(size = 9, margin=margin(t=-15))) +  coord_proj(us_laea_proj) +   labs(title="",subtitle="" ) +  scale_fill_viridis(name = "", discrete=F,option="D",end=0.95,                     direction=1,limits=c(0,0.12),                     label=percent                     )+  theme(legend.position = "top") +theme(plot.caption=element_text(hjust=0,vjust=1,margin=margin(t=10)))+  labs(title="Annual House Price Growth (Y/Y %)",        caption="@lenkiefer Source: 房地美 House Price Index (Not Seasonally adjusted)")图九、房产价格和就业趋势#make comparison to pre-2008 peak map与2008年之前的峰值进行对比ggplot() +  geom_map(data = smap, map = smap,           aes(x = long, y = lat, map_id = id),           color = "#2b2b2b", size = 0.05, fill = NA) +  geom_map(data =subset(states@data,year==2016 & month==9), map = smap,           aes( map_id = fips_state,fill=hpi.compd),           color = "gray", size = .25) +  theme_map( base_size = 12) +  theme(plot.title=element_text( size = 16, margin=margin(b=10))) +  theme(plot.subtitle=element_text(size = 14, margin=margin(b=-20))) +  theme(plot.caption=element_text(size = 9, margin=margin(t=-15))) +  coord_proj(us_laea_proj) +   labs(title="",subtitle="" ) +  scale_fill_viridis(name = "", discrete=T,option="D",end=0.95 )+  theme(legend.position = "top") +theme(plot.caption=element_text(hjust=0,vjust=1,margin=margin(t=10)))+  labs(title="House Prices in September 2016 relative to pre-2008 peak",             caption="@lenkiefer Source: 房地美 House Price Index (Not Seasonally adjusted)")图十、2016年9月房产价格与2008年前峰值对比#State annual house price appreciation rank map州年度房价评估排序图ggplot() +    geom_map(data = smap, map = smap,             aes(x = long, y = lat, map_id = id),             color = "#2b2b2b", size = 0.05, fill = NA) +    geom_map(data =subset(states@data,year>2015 & month==mm), map = smap,             aes( map_id = fips_state,fill=hparank),             color = "gray", size = .25) +     theme_map( base_size = 12) +    theme(plot.title=element_text( size = 16, margin=margin(b=10))) +    theme(plot.subtitle=element_text(size = 14, margin=margin(b=-20))) +    theme(plot.caption=element_text(size = 9, margin=margin(t=-15))) +    coord_proj(us_laea_proj) +   labs(title="",subtitle="" ) +    scale_fill_viridis(name = "", discrete=F,option="D",end=0.95,                       direction=-1)+    theme(legend.position = "top") +theme(plot.caption=element_text(hjust=0,vjust=1,margin=margin(t=10)))+    labs(title="Rank for state + D.C. annual house price growth (1 to 51)",         subtitle="September of 2016",         caption="@lenkiefer Source: 房地美 House Price Index (Not Seasonally adjusted)")图十一、2016年9月全美房价年度增幅(1到51)# State annual house price appreciation rank map, panel 2008-2016#州年度房价评估排序地图,从2008-2016ggplot() +    geom_map(data = smap, map = smap,             aes(x = long, y = lat, map_id = id),             color = "#2b2b2b", size = 0.05, fill = NA) +    geom_map(data =subset(states@data,year>2007 & month==mm), map = smap,             aes( map_id = fips_state,fill=hparank),             color = "gray", size = .25) +     theme_map( base_size = 12) + facet_wrap(~year,ncol=3)+    theme(plot.title=element_text( size = 16, margin=margin(b=10))) +    theme(plot.subtitle=element_text(size = 14, margin=margin(b=-20))) +    theme(plot.caption=element_text(size = 9, margin=margin(t=-15))) +    coord_proj(us_laea_proj) +   labs(title="",subtitle="" ) +    scale_fill_viridis(name = "", discrete=F,option="D",end=0.95,                       direction=-1 )+    theme(legend.position = "top") +theme(plot.caption=element_text(hjust=0,vjust=1,margin=margin(t=10)))+    labs(title="Rank for state + D.C. annual house price growth (1 to 51)",         subtitle="September of year",         caption="@lenkiefer Source: 房地美 House Price Index (Not Seasonally adjusted)")图十二、连续8年9月份全美房价年度增幅(1到51) Bonus Time福/利/时/间参考资料免费下载联系我们索取资料免费索取英文原文资料:联系微信公众号 或电邮 Daizongliu@qq.com 「 欢迎投稿 」我们作为专业志愿者团体,秉承理想,帮助中国可持续发展。并为之贡献:理念与传播、培训与教育、实践与孵化。欢迎您加入我们一起并肩前行!2014-2017 ? 转载请注明:源自公众号“”

此页面保留原 UPNEWS 收录地址与历史内容,著作权归原作者及相关机构所有。