Last active
February 26, 2022 12:47
-
-
Save nozma/0361bb5dd068c22074df39ce5377997b to your computer and use it in GitHub Desktop.
総合課税にするかどうかの計算メモ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "総合課税にするかどうか計算" | |
author: '@nozma' | |
date: "2022/02/26" | |
--- | |
```{r setup, include=FALSE} | |
library(dplyr) | |
library(ggplot2) | |
options(scipen = 10) | |
``` | |
## 準備 | |
[No.2260 所得税の税率|国税庁](https://www.nta.go.jp/taxes/shiraberu/taxanswer/shotoku/2260.htm) | |
```{r} | |
## 所得税率の計算 | |
calc_tax_rate <- function(x) { | |
case_when( | |
x <= 1949000 ~ 0.05, | |
x <= 3299000 ~ 0.10, | |
x <= 6949000 ~ 0.20, | |
x <= 8999000 ~ 0.23, | |
x <= 17999000 ~ 0.33, | |
x <= 39999000 ~ 0.40, | |
TRUE ~ 0.45, | |
) | |
} | |
## 控除額の計算 | |
calc_deduction <- function(x) { | |
case_when( | |
x <= 1949000 ~ 0, | |
x <= 3299000 ~ 97500, | |
x <= 6949000 ~ 427500, | |
x <= 8999000 ~ 636000, | |
x <= 17999000 ~ 1536000, | |
x <= 39999000 ~ 2796000, | |
TRUE ~ 4796000, | |
) | |
} | |
## 所得税額の計算 | |
calc_income_tax <- function(x){ | |
x * calc_tax_rate(x) - calc_deduction(x) | |
} | |
``` | |
## 計算 | |
```{r} | |
## 元の所得と追加分の所得の組み合わせで、追加分の所得に係る実質的な所得税がどう変化するかを確認する。 | |
taxable_incomes <- seq(10e4, 1000e4, 10e4) | |
dividend_incomes <- seq(10e4, 1000e4, 10e4) | |
tibble(課税所得 = taxable_incomes) %>% | |
full_join( # cross join | |
tibble(配当所得 = dividend_incomes), | |
by = character() | |
) %>% | |
mutate( | |
所得税額 = calc_income_tax(課税所得), | |
所得税額_配当込 = calc_income_tax(課税所得 + 配当所得), | |
## 配当控除の上限は算出税額のため負の値にはしない | |
所得税額_配当込_控除後 = purrr::map2_dbl(.x = 所得税額_配当込, .y = 配当所得, ~max(.x - .y * 0.1, 0)), | |
配当にかかる所得税率_控除前 = (所得税額_配当込 - 所得税額) / 配当所得, | |
配当所得源泉徴収額 = 配当所得 * 0.15, | |
差引_控除前 = (所得税額 + 配当所得源泉徴収額) - 所得税額_配当込, | |
差引_控除後 = (所得税額 + 配当所得源泉徴収額) - 所得税額_配当込_控除後 | |
) %>% | |
mutate( | |
配当所得の実質税率区分 = case_when( | |
配当にかかる所得税率_控除前 < 0.15 ~ "<15%", | |
配当にかかる所得税率_控除前 < 0.20 ~ "<20%", | |
配当にかかる所得税率_控除前 < 0.25 ~ "<25%", | |
TRUE ~ ">=25%" | |
), | |
総課税所得 = 課税所得 + 配当所得, | |
総課税所得区分 = case_when( | |
総課税所得 <= 695e4 ~ "d. 695万以下", | |
総課税所得 <= 900e4 ~ "c. 900万以下", | |
総課税所得 <= 1000e4 ~ "b. 1000万以下", | |
TRUE ~ "a. 1000万超" | |
) | |
) -> result | |
result | |
``` | |
## プロット | |
追加分の実質税率の分布。 | |
```{r} | |
result %>% | |
ggplot( | |
aes(x = 課税所得, | |
y = 配当所得, | |
fill = 配当所得の実質税率区分, | |
alpha = 総課税所得区分 | |
) | |
) + | |
scale_alpha_discrete(range = c(0.5, 1)) + | |
scale_x_continuous( | |
breaks = seq(0, 1000e4, 100e4), | |
limits = c(0, 900e4), | |
labels = ~scales::comma(., scale = 1e-4, suffix = "万円") | |
) + | |
scale_y_continuous( | |
breaks = seq(0, 1000e4, 100e4), | |
labels = ~scales::comma(., scale = 1e-4, suffix = "万円") | |
) + | |
labs(x = "元の課税所得") + | |
geom_tile() + | |
theme_classic(base_family = "IPAexGothic") + | |
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) | |
``` | |
実際の節税額の分布(配当控除なし)。 | |
```{r} | |
result %>% | |
filter(差引_控除前 > 0) %>% | |
ggplot( | |
aes(x = 課税所得, | |
y = 配当所得, | |
fill = 差引_控除前 | |
) | |
) + | |
scale_x_continuous( | |
breaks = seq(0, 1000e4, 100e4), | |
limits = c(0, 330e4), | |
labels = ~scales::comma(., scale = 1e-4, suffix = "万円") | |
) + | |
scale_y_continuous( | |
breaks = seq(0, 1000e4, 100e4), | |
labels = ~scales::comma(., scale = 1e-4, suffix = "万円") | |
) + | |
labs(x = "元の課税所得") + | |
scale_fill_binned( | |
type = "viridis", | |
breaks = c(1e4, 5e4, 10e4, 20e4, 30e4), | |
labels = ~scales::comma(., scale = 1e-4, accuracy=1, suffix = "万円") | |
) + | |
geom_tile() + | |
theme_classic(base_family = "IPAexGothic") | |
``` | |
配当控除を考慮した場合の節税額の分布。 | |
```{r} | |
result %>% | |
filter(差引_控除後 > 0, 総課税所得 < 1000e4) %>% | |
ggplot( | |
aes(x = 課税所得, | |
y = 配当所得, | |
fill = 差引_控除後 | |
) | |
) + | |
scale_x_continuous( | |
breaks = seq(0, 1000e4, 100e4), | |
limits = c(0, 900e4), | |
labels = ~scales::comma(., scale = 1e-4, suffix = "万円") | |
) + | |
scale_y_continuous( | |
breaks = seq(0, 1000e4, 100e4), | |
labels = ~scales::comma(., scale = 1e-4, suffix = "万円") | |
) + | |
labs(x = "元の課税所得") + | |
scale_fill_binned( | |
type = "viridis", | |
breaks = c(1e4, 5e4, 10e4, 20e4, 30e4), | |
labels = ~scales::comma(., scale = 1e-4, accuracy=1, suffix = "万円") | |
) + | |
geom_tile() + | |
theme_classic(base_family = "IPAexGothic") | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment