www.crosshyou.info

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

2021-01-01から1年間の記事一覧

OECD Meat Consumption Data Analysis 8 - Serial Correlation Robust Inference using R

Photo by T o T on Unsplash www.crosshyou.info This post is following of above post. In this post, I will check if there is serial correlation in the previous regression model. First, I make residual with resid() function. Then, let's make …

OECD Meat Consumption Data Analysis 7 - Time Series Regression using R dynlm() function.

Photo by Ashutosh Saraswat on Unsplash www.crosshyou.info This post is following of aabove post.In this post, I will do some time-series regression with R. First, I made JPN only dataframe. Let's see df_jpn. Then, I make ts object form df_…

OECD Meat Consumption Data Analysis 6 - POULTRY Consumption is positively correlated with GDP

Photo by corina ardeleanu on Unsplash www.crosshyou.info This post is following of above post. I have GDP data like below CSV file. So, let's combine this GDP data and Meat Consumption data. Next, I use inner_join() function to combine df2…

OECD Meat Consumption Data Analysis 5 - scatter plot using R ggplot2::geom_point()

Photo by Casey Horner on Unsplash www.crosshyou.info This post is following of above post.In this post, let's draw scatter plots using R ggplot2::geom_point.First of all, let's see correlations about 4 KG_CAPs. bekg: BEEF KG_CAP and pokg: …

OECD Meat Consumption Data Analysis 4 - USA is the most meat consumption country.

Photo by Claiton Conto on Unsplash www.crosshyou.info This post is following of above post.Let's see KG_CAP data as country average. Firstly, bekg: BEEK KG_CAP ARG is the highest beef consumption country. IND is the lowest. How about pikg:…

OECD Meat Consumption Data Analysis 3 - PIG and POULTRY are on up trend while BEEF and SHEEP are on down trend.

Photo by Nathan Anderson on Unsplash www.crosshyou.info This post is following of above post. Let's see coun: country. We see all country have 40 observations. Let's see year We see all year have 38 observations.So, df2 data frame is 40 co…

OECD Meat Consumption Data Analysis 2 - PIG is the most popular meat.

Photo by boris misevic on Unsplash www.crosshyou.info This post is following above post.Now, we now there are 4 sunjects and 2 measures. 4 subjects are BEEG, PIG, POULTRY and SHEEP. 2 measures are KG_CAP and THND_TONNE.So, we have 8 combin…

OECD Meat Consumption Data Analysis 1 - Using R to read CSV data with read_csv() function.

Photo by Wolfgang Hasselmann on Unsplash Hello! This post, I will anaysis OECD Meat Consumption data using R. I got a CSV file like below from OECD web site(Agricultural output - Meat consumption - OECD Data) Firstly, I load tidyverse pack…

都道府県別の仕事の平均時間のデータ分析7 - 女性の仕事の平均時間は、1人当たり県民所得が高くなると短くなる。

Photo by Xavier von Erlach on Unsplash www.crosshyou.info の続きです。 こんどは、male_m: 男性の仕事の平均時間(分)を回帰分析してみます。 P-valueが0.703ということなので、有意なモデルではないです。 step関数でモデルを単純化してみます。 female_…

都道府県別の仕事の平均時間のデータ分析6 - R言語のprop.test()関数で比率の検定をする。

Photo by catrina farrell on Unsplash www.crosshyou.info の続きです。 各都道府県の 女性(15~64歳)の人口 / 男性(15~64歳)の人口の比率は西日本のほうが高いとわかりましたが、東日本全体の女性(15~64歳)の人口/東日本全体の男性(15~64歳)の人口と、西日…

都道府県別の仕事の平均時間のデータ分析5 - R言語でRidge Plotというものを描く。

Photo by Mark Harpur on Unsplash www.crosshyou.info rafalab.github.io というものでRidge Plotというものを知りましたので、忘れないうちに実践です。 Ridge Plotはあるデータ(身長、体重、所得など)の分布をグループごとに見るときに便利です。 早速、…

都道府県別の仕事の平均時間のデータ分析4 - 海のない県のほうが、女性の仕事の平均時間/男性の仕事の平均時間 は低い。

Photo by Manson Yim on Unsplash www.crosshyou.info の続きです。 前回の分析で西日本のほうが、女性の人口(15~64歳)/男性の人口(15~64歳)の比率が高い傾向にあることがわかりました。 統計的に有意に違うのか検定してみます。 p-valueは1.125e-06とかなり…

都道府県別の仕事の平均時間のデータ分析3 - 東日本は女性(15~64歳)が少なく、西日本は多い。

Photo by Dileep M on Unsplash www.crosshyou.info の続きです。 前回、女性の仕事時間 / 男性の仕事時間 という変数をfmという名前で作りました。 女性の人口 (15~64歳)/ 男性の人口(15~64歳) の変数をfm_popという名前で作ります。 こうしてみると東日本…

都道府県別の仕事の平均時間のデータ分析2 - 男性は鹿児島県、香川県、新潟県などが長時間、女性は大分県、沖縄県、山形県などが長時間仕事をしている。

Photo by Edrick Krozendijk on Unsplash www.crosshyou.info の続きです。 男性の仕事の平均時間の長いところ、短いところはどこでしょうか? 鹿児島県、香川県、新潟県などが長い時間働いています。 山梨県、愛媛県、高知県が短いです。 同じ四国でも香川…

都道府県別の仕事の平均時間のデータ分析1 - R言語にデータを取り込む。

Photo by frank mckenna on Unsplash 今回は都道府県別の仕事の平均時間のデータを分析しようと思います。 データは、政府統計の総合窓口(www.e-stat.go.jp)から取得しました。 47の都道府県を選択します。 取得するデータは、 15~64歳人口(男)(人) 15~64歳…

OECD Gender wage gap data analysis 5 - Serial Correlation Test using R

Photo by BP Miller on Unsplash www.crosshyou.info This post is following of the above psot. In this post, let's test if there is serial correlation. Firdt of all, load lmtest package. All right, let's start with model1. p-value of lag resi…

OECD Gender wage gap data analysis 4 - Time Series Data Regression with lag and trend using R

Photo by Masako Ishida on Unsplash www.crosshyou.info This post is following of the above post. Which chountry has many observations? NZL has 22 observations. AUT, BEL, DNK, FIN, NOR and SWE have 16 observations. Let's see NZL data. We see…

OECD Gender wage gap data analysis 3 - using facet_grid() and facet_wrap() in R.

Photo by Damien TUPINIER on Unsplash www.crosshyou.info This post is following of above post.Let's see which year has many observations. Okay, 2014, 2010, 2006 and 2018 have over 20 observations. Let's see those years more. First, emp dens…

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

高地文明―「もう一つの四大文明」の発見 (中公新書 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…