www.crosshyou.info

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

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

都道府県別の経済構造実態調査のデータの分析5 - R言語のaov()関数でANOVA分析

UnsplashのAlex Personが撮影した写真 www.crosshyou.info の続きです。 前回行ったクラスタリングの結果をデータフレーム、dfにくっつけます。 まず、dfがどんなものだったか、str()関数で確認します。 これにクラスタリングの結果をくっつけたいので、まず…

読書記録 - 「東京国税局査察部」 立石勝規 著 岩波新書

東京国税局査察部 (岩波新書) 作者:立石 勝規 岩波書店 Amazon 1999年に出版された本なので、東京国税局査察部が現在もこの本に書かれているようなものなのかはわかりませんが、1999年当時を思い出すことができました。 金丸信の脱税や、山一證券の自主廃業…

都道府県別の経済構造実態調査のデータの分析4 - R言語でhierarchial clusteringとk-means clusteringを実行する。

UnsplashのSebastian Unrauが撮影した写真 www.crosshyou.info 前回はデータフレームを大きい順、小さい順に並び替えました。東京都や大阪府などが値が大きくて、奈良県などが値が小さかったです。 そこで今回は、R言語でクラスタリングを実行してみたいと思…

都道府県別の経済構造実態調査のデータの分析3 - R言語でデータフレームを大きい順・小さい順に並び替える。

UnsplashのBoris Smokrovicが撮影した写真 www.crosshyou.info の続きです。 前回は都道府県ごとの統計値のデータフレーム、(stat_prefと名前をつけた)、を作成しました。今回はこのデータフレームを並び替えてどういう都道府県が値が大きいのかを調べてみま…

都道府県別の経済構造実態調査のデータの分析2 - R言語の tapply() 関数で産業別、都道府県別の統計値を算出する。

UnsplashのMarek Piwnickiが撮影した写真 www.crosshyou.info の続きです。 前回はCSVファイルにあるデータをR言語に読み込ませ、分析用のデータフレームを作成するところまで進みました。 まず、hist()関数でvalue: 売上高(百万円単位)の分布をみてみましょ…

都道府県別の経済構造実態調査のデータの分析1 - R言語にCSVファイルのデータを読み込む。

UnsplashのAaron Burdenが撮影した写真 今回は都道府県別の経済構造実態調査のデータを分析してみようと思います。 まず、政府統計の総合窓口(e-stat.go.jp)からデータをダウンロードします。 経済構造実態調査は、我が国の製造業及びサービス産業における企…

読書記録 - 「日本のコメ問題 - 5つの転換点と迫りくる最大の危機」 小川真如 著 中公新書

日本のコメ問題-5つの転換点と迫りくる最大の危機 (中公新書 2701) 作者:小川 真如 中央公論新社 Amazon コメ問題と田んぼ問題がごちゃまぜになっていることが問題のようです。 今世紀中、この本では2052年ごろに、日本の農地が余る状態、つまり、全部の農…

OECD Non-Financial Corporations Debt to Surplus Ratio Analysis 6 - Hierarchical Clustering using R

UnsplashのWolfgang Hasselmannが撮影した写真 www.crosshyou.info This post is following of the above post.In this post, I will do hierarchical clustering using R. It is very easi with R. Firstly, I make a matrix for hierarchical clustering. …

OECD Non-Financial Corporations Debt to Surplus Ratio Analysis 5 - arranging data frame and make a bar chart using R.

UnsplashのPierre Lemosが撮影した写真 www.crosshyou.info Thsi post is following of the above post. In this post I will arrange data frame with arrange() function of dplyr packkage. Let's make a graph with ggplot2 packages. LUX has the highe…

OECD Non-Financial Corporations Debt to Surplus Ratio Analysis 4 - t-test, Wilcoxon rank sum test and correlation test using R

Unsplashのmartin bennieが撮影した写真 www.crosshyou.info This post is following of above post. Let's calculate difference between Y2016 and Y2015 Let's see a histogram of d2016 Then, let's calculate difference between Y2017 and Y2016 Let's…

OECD Non-Financial Corporations Debt to Surplus Ratio Analysis 3 - Calculating Confidence Interval in R, Parametric and Monte Carlo.

UnsplashのHeather Wildeが撮影した写真 www.crosshyou.info This post is following of the above post. In this post, I will show some statistics of our data. Before investigation, I make data frame to wide format with pivot_wider() function. W…

OECD Non-Financial Corporations Debt to Surplus Ratio Analysis 2 - making various type plots with ggplot() + geom_~~~ using R.

UnsplashのJ Cruikshankが撮影した写真 www.crosshyou.info This post is following of the above post. In the previous post, I load CSV file data into R. Then, let's make some basic graphs using ggplot2 package. Scatter plot ggplot() + geom_poi…

OECD Non-Financial Corporations Debt to Surplus Ratio Analysis 1 - Load CSV file data using R

UnsplashのJeremy Thomasが撮影した写真 In this post, I will use R for analysis about OECD Non-Financial Corporations Debt to Surplus Ratio. This ratio is debt outstanding / annual flow if gross operating surplus. So, the higher the ratio, t…

都道府県別の定期健康診断結果報告のデータ分析9 - R言語で非階層クラスタリング

UnsplashのWexor Tmgが撮影した写真 www.crosshyou.info の続きです。前回はR言語で階層クラスタリングをしました。今回は非階層クラスタリングをしてみて、前回の結果を比較してみます。 k-means法というクラスタリング手法で、kmeans()関数で実行可能です…

都道府県別の定期健康診断結果報告のデータ分析8 - R言語で階層クラスタリング

UnsplashのSora Saganoが撮影した写真 www.crosshyou.info 前回までは回帰分析をしていましたが、 今回はR言語でクラスタリングをしてみようと思います。 まず、クラスタリング用のデータフレームとして、aggregate()関数とmean()関数を使って3年間の平均の…

都道府県別の定期健康診断結果報告のデータ分析7 - R言語でパネルデータを回帰分析する。

UnsplashのLeopold Stengerが撮影した写真 www.crosshyou.info 前回は年と都道府県も説明変数に加えてtworatioを重回帰分析してみました。その結果、l_num: 健康診断を実施した事業場数の対数変換値はtworatioを説明する有意な変数ではないことがわかりまし…

都道府県別の定期健康診断結果報告のデータ分析6 - R言語で回帰モデルの不均一分散に適応した標準誤差やF検定をする。

UnsplashのGanapathy Kumarが撮影した写真 www.crosshyou.info の続きです。 前回の重回帰モデルに年と都道府県を説明変数に加えて、l_numの係数がどうなるかを見てみます。 まず、yearをas.factor()関数でファクター型に変換した変数をつくります。 yfがフ…

都道府県別の定期健康診断結果報告のデータ分析5 - R言語で回帰モデルの均一分散を調べたり、複数の回帰モデルの表を作成する。

UnsplashのYoksel Zokが撮影した写真 www.crosshyou.info の続きです。 前回は tworatio: 2回以上実施した事業場数の割合をnum: 検査を実施した事業所の数で回帰分析してみました。その結果、事業所の数が大きいほど、割合は低下している傾向があることがわ…

読書記録 - 「未踏の蒼穹」 ジェイムズ・P・ホーガン

未踏の蒼穹 (創元SF文庫) 作者:ジェイムズ・P・ホーガン 東京創元社 Amazon 大学生か高校生の頃に同じ作者の「星を継ぐもの」を読んでほんとうにSFって面白いと感じました。同じ作者の同じような話です。地球人はもう絶滅してしまっていて、金星人たちが主…

読書記録 - 「理論とケースで学ぶ 企業倫理入門」 高浦康有・藤野真也 編

理論とケースで学ぶ 企業倫理入門 白桃書房 Amazon 企業倫理学は、誤解を恐れずに言えば、グッド・ビジネスとは何かを探求する学問である。そして、「グッド」の基準を定めることの難しさと「ビジネス」という言葉の多様性がこの学問の面白いところだと思っ…

都道府県別の定期健康診断結果報告のデータ分析4- R言語で棒グラフを描いたり、単純線形回帰分析をしたりする。

UnsplashのCristina Anne Costelloが撮影した写真 www.crosshyou.info 今回は、上のブログの続きです。 前回は、散布図や箱ひげ図を描きました。今回は、barplot()関数を使って棒グラフを描いてみます。 まずは、ritsu: 所見のあった人数の割合を都道府県ご…

都道府県別の定期健康診断結果報告のデータ分析3 - R言語で散布図や箱ひげ図を描いたり、ANOVA分析をしたりする。

UnsplashのJean Girouxが撮影した写真 www.crosshyou.info 前回はR言語でヒストグラムを描きました。今回は散布図を描いでみます。 plot()関数で、データフレームの散布図にしたい変数を指定すると、上の画面のような散布図のマトリックスが描かれます。 rit…

都道府県別の定期健康診断結果報告のデータ分析2 - R言語でヒストグラムを描く

Photo by Thijs Boom on Unsplash www.crosshyou.info この記事は上の記事の続きです。 今回は、R言語に読み込んだデータをグラフにしてみます。tidyverseパッケージを使わずに、通常のグラフィック関数でやってみます。 まずは、それぞれの変数の分布状況を…

都道府県別の定期健康診断結果報告のデータ分析1 - R言語にデータを取り込む

Photo by Dana Luig on Unsplash 今回は、都道府県別の定期健康診断結果報告のデータを調べてみます。 政府統計の総合窓口(www.e-stat.go.jp)のウェブサイトからデータをダウンロードします。 定期健康診断結果報告は、労働安全衛生法に基づく定期健康診断結…

OECD Nutrient balance data analysis 8 - F-Test and Heteroskedasticity-Robust Inference in R

Photo by S. Tsuchiya on Unsplash www.crosshyou.info This post is following above post. In the previous post, I did multiple regression, s_ni_kg ~ s_po_kg + s_ni_to. Let's add 'time' variables. All time variables are not statistically signi…

OECD Nutrient balance data analysis 7 - Simple Regression and Multiple Regression using R

Photo by Harry Gillen on Unsplash www.crosshyou.info This post is following of the above post. In the previous post, I made scaled variables in df4, let's see correlation matrix of those variables. The most highly correlated variable pair …

OECD Nutrient balance data analysis 6 - making a panel data using R

Photo by Philip Myrtorp on Unsplash www.crosshyou.info This post is following of above post. Since I made several objects, let me confirm what objects there is. ls() function shows current object list. So far, I have df_raw, df1, df2 and d…

OECD Nutrient balance data analysis 5 - Hierarchical Clustering using R

Photo by Erda Estremera on Unsplash www.crosshyou.info This post is following of above post. Let's make two scatter plots and display them in a panel. Firstly, I load gridExtra package. Then, I make two objects, each object is for a scatte…

OECD Nutrient balance data analysis 4 - PCA(Principal Component Analysis) using R

Photo by Ash from Modern Afflatus on Unsplash www.crosshyou.info This post is following of above post. In the above post, I made a dataframe which has basic statistics data for each locations. Let's look into it further, Firstly, let's see…

OECD Nutrient balance data analysis 3 - Line charts using R

Photo by Stephen Leonardi on Unsplash www.crosshyou.info This post is following of above post. I will make line charts using R ggplot2 package. Let's start with ni_kg(NITROGEN measured by KG_HA) Some locations have declining trend, some ha…