www.crosshyou.info

政府統計の総合窓口のデータや、OECDやUCIやのデータを使って、Rの練習をしています。ときどき、読書記録も載せています。

2021-08-01から1ヶ月間の記事一覧

読書記録 - 「高地文明 - 「もう一つの四大文明」の発見」 山本紀夫 著 中公新書

高地文明―「もう一つの四大文明」の発見 (中公新書 2647) 作者:山本 紀夫 中央公論新社 Amazon 一般に知られている四大文明は、黄河文明、エジプト文明、インダス文明、メソポタミア文明の4つで、これらの文明は大河があることによって、穀類の大量栽培が可…

OECD Gender wage gap data analysis 2 - Data Visualization using R ggplot() + geom_histogram(), geom_points(), geom_line()

Photo by Luca Bravo on Unsplash www.crosshyou.info This post is following of above post. I will makse some graphs for data visualization using R. Fist, let's see how our data are distributed. I use ggplot() + geom_histogram() First, emp(em…

OECD Gender wage gap data analysis 1 - Load CSV file data into R

Photo by Trevor McKinnon on Unsplash In this post, I will analyze OECD Gender wage gap data. From the OECD web site, I downloaded the CSV data file like below. I will use R to analyze this data. First, I load tidyverse packages Then, I use…

都道府県別の一般病院病床利用率のデータ分析7 - より多くの観測数で回帰分析をする。(Pooling Cross Section regression)

Photo by shay cohen on Unsplash www.crosshyou.info の続きです。前回は都道府県別の平均値のデータフレームで回帰分析しましたが、今回は生のデータフレームで回帰分析してみます。 まず、変数間の散布図マトリックスをみてみます。 相関係数マトリックス…

都道府県別の一般病院病床利用率のデータ分析6 - R言語のlm()関数で回帰分析をする。医療費が高いところは病床利用率も高い。

Photo by Sajad Nori on Unsplash www.crosshyou.info の続きです。 今回は都道府県別の平均値のデータフレームを使って、回帰分析をしてみます。 まずは、east, big6, noseaというダミー変数を加えないで回帰分析してみます。 R言語のlm()関数を使います。 …

都道府県別の一般病院病床利用率のデータ分析5 - R言語で散布図マトリックスを描くのと相関係数マトリックスを作る。

Photo by Tanya Grypachevskaya on Unsplash www.crosshyou.info の続きです。 まず、R言語のgroup_by()関数とsummarize()関数を使って、年ごとの平均値を計算してみます。 2002年、2005年、2008年、2011年、2014年と3年ごとに5年間ぶんのデータがあったので…

都道府県別の一般病院病床利用率のデータ分析4 - 各変数の分布を見てskewを計算する。

Photo by Tim Mossholder on Unsplash www.crosshyou.info の続きです。 今回はriyou以外の各変数の分布をみてみます。 まずは、mitsudo: 可住地面積1平方キロメートル当たりの人数、つまり人口密度です。 右のほうに外れ値っぽい分布があるのがわかります…

都道府県別の一般病院病床利用率のデータ分析3 - 病床利用率は東日本と西日本で違いがある。

Photo by Rob Sheahan on Unsplash www.crosshyou.info の続きです。 riyou: 一般病院病床利用率(%)について、もう少しグラフをみてみます。 まずは、year: 調査年との関係です。 全体として、年を追うごとに一般病院病床利用率は低くなっていることがわかり…

都道府県別の一般病院病床利用率のデータ分析2 - gridExtra::grid.arrange()関数でグラフを並べて表示する。

Photo by L J on Unsplash www.crosshyou.info の続きです。 今回はgridExtraパッケージのgrid.arrange()関数でグラフを並べて表示できることを知ったので、忘れないように実践します。 riyou: 一般病院病床利用率(%)をグラフにします。 まずは、ヒストグラ…

都道府県別の一般病院病床利用率のデータ分析1 - R言語にデータを取り込む。

Photo by Federico Bottos on Unsplash 新型コロナウイルスの影響で病床利用率がひっ迫している、というニュースをよく見聞きしますので、普段の病床利用率はどんなものなのか調べてみようと思いました。 政府統計の総合窓口(www.e-stat.go.jp)からデータを…

OECD Household disposable income data analysis 7 - Bootstrap using R

Photo by Toni Lluch on Unsplash www.crosshyou.info This post is following of above post.In this post I will do Bootstrap and make confidence inerval of regression. First, let's check coefficients for static regression model again. Intercep…

OECD Household disposable income data analysis 6 - Time-Series Data Regression using R

Photo by Jeremy Bishop on Unsplash www.crosshyou.info This post is following of above post.In this post, I will do time-series data regression using R. Firstly, I converted avg_gr_us in 10000 value. Then, I converted df_year2 data frame to…

OECD Household disposable income data analysis 5 - simple linear regression analysis using R

Photo by V Srinivasan on Unsplash www.crosshyou.info This post is following of the above post. In this post, let's do simple linaer regression anaysis using R. First, I use df_country data frame. Coefficients of avg_gr_us is -1.002e-04, it…

OECD Household disposable income data analysis 4 - make a data frame by country and by year using R.

Photo by Olga Tsai on Unsplash www.crosshyou.info This post is following of above post. In this post, let's make average value data frame by country and by year. First, I make a data frame for average value by country using group_by() func…

OECD Household disposable income data analysis 3 - making some graphs using R.

Photo by Lorena Schmidt on Unsplash www.crosshyou.info This post is following of above post. In this post, let's make some graphs to understand data distributions, data relationship. Fisrt, a histgram of gr_us. ecdf plot of gr_us. boxplot …

OECD Household disposable income data analysis 2 - using filter(), select(), inner_join() functions to make a date frame more analyzable.

Photo by CHUTTERSNAP on Unsplash www.crosshyou.info This post is following of above post. In the previous post, we made a dafa frame called a "df". We see there are two values in subject, GROSSADJ and NET, two values in measure, AGRWTH and…

OECD Household disposable income data analysis 1 - import data into R

Photo by Bob Brewer on Unsplash In this post, I will analyze OECD Household disposable income. Household accounts - Household disposable income - OECD Data I got below CSV file from the web site. I will import this data into R. First of al…

都道府県別の書籍・文房具販売額データの分析5 - R言語のstargazer()関数で整った回帰分析の結果の表を作る。

Photo by Matt Anderson on Unsplash www.crosshyou.info の続きです。 前回の続きで、今度は交差項を含んだ回帰分析をします。 まずは、per_shobuをincとその他で回帰分析します。 p-valueが1.387e-13とかなり小さいの有意なモデルです。Multiple R-sauared…

都道府県別の書籍・文房具販売額データの分析4 - R言語で回帰分析。1人当たり県民所得が増えると1人当たり書籍・文房具販売額も増える。

Photo by Sam Mgrdichian on Unsplash www.crosshyou.info の続きです。 前回までの分析で気づいたことは、1人当たり県民所得が大きいところは1人当たりの書籍・文房具販売額も大きいということです。 相関係数を確認してみると、 というように相関係数は0.8…

都道府県別の書籍・文房具販売額データの分析3 - R言語でデータを可視化する

Photo by Thor Alvis on Unsplash www.crosshyou.info の続きです。 今回はR言語でデータを可視化します。 ggplot2パッケージでのチャートをいくつか作ってみます。 per_shobu: 1人当たり年間書籍・文房具販売額(千円)のチャートです。geom_barでバーチャー…

都道府県別の書籍・文房具販売額データの分析2 - R言語で基本的な記述統計量を表示する

Photo by Jan Haerer on Unsplash www.crosshyou.info の続きです。 今回は各変数の基本的な記述統計量をみてみます。 最小値はmin()関数、最大値はmax関数、平均値はmean()関数、中央値はmedian()関数、標準変数はsd()関数、パーセンタイル値は、quantile()…

都道府県別の書籍・文房具販売額データの分析1 - R言語でCSVファイルのデータを読み込む

Photo by Wil Stewart on Unsplash 今回は都道府県別の書籍・文房具の販売金額のデータを分析しようと思います。 データは政府統計の総合窓口、e-statから取得しました。(www.e-stat.go.jp) 47都道府県を選択して、 総人口、15~64歳の男性の割合、15~64歳の…

OECD Road accidents data analysis 5 - Time Series Data Regression using R

Photo by JJ Ying on Unsplash www.crosshyou.info This post is following of above post.In this post, I woll do time series data regression using R , dynlm package. Firstly, I wll make time series data. Then, let's see how data is looking. Le…

OECD Road accidents data analysis 4 - Regression analysis Death per Habitant on Accident Number

Photo by Yoksel Zok on Unsplash www.crosshyou.info This post is following of above post.In the previous post, we see it is better to convert all variables to logarithm to make more normal distribition looking.So, let's make new variables.…

OECD Road accidents data analysis 3 - make a histogram with ggplot() + geom_histogram(). Log conversion makes better looking histogram.

Photo by Robert Lukeman on Unsplash www.crosshyou.info This post is following og above post. We have five combinations for value, 1. ACCI & NBR 2. DEATH & HAB 3. DEATH & VEH 4. DEATH & NBR 5. INJURE & NBR So, I will make five sub data fram…

東京都の職業別のコロナ感染者はどうなっているのか?

コロナ感染者が日ごとに増加していますね。。 年齢別では30代以下が7割との報道がありましたが、 感染者急増 30代以下が7割超 - Yahoo!ニュース 職業別ではどうなっているのでしょうか? 気になったので、東京都のデータで調べてみました。 上の画像の東京都…