library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.3.0
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dplyr)
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(dplyr)
library(tidyr)
library(readxl)
nonprofitimpacts <- read_excel("nonprofitimpacts2.xlsx")
view(nonprofitimpacts)
head(nonprofitimpacts)
## # A tibble: 6 × 11
## ResponseId ProgDem PplSrv MajGiftAmt CEOrace_White BChairrace_White
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 R_6hdrzX5DYuu6hVf 0 300000 500 0 0
## 2 FS_10sszir9xkTX9U5 0 50000 200 0 0
## 3 R_72t5uogX3qcLjlq 0 29000 100 0 0
## 4 R_3lrXJzS0AHM2DqX 0 12000 500 0 0
## 5 FS_3itvPD8YLhTOqWH 0 9000 50 0 0
## 6 FS_5xwR3CqoL2qwfwb 0 8200 100 0 0
## # ℹ 5 more variables: PercentDemPOCBoard <dbl>, Northeast <dbl>, Midwest <dbl>,
## # South <dbl>, West <dbl>
cor(nonprofitimpacts$CEOrace_White, nonprofitimpacts$BChairrace_White, method = "pearson")
## [1] 0.4796578
plot(nonprofitimpacts$CEOrace_White, nonprofitimpacts$BChairrace_White)

model <- lm(nonprofitimpacts$CEOrace_White~nonprofitimpacts$BChairrace_White, data=nonprofitimpacts)
summary(model)
##
## Call:
## lm(formula = nonprofitimpacts$CEOrace_White ~ nonprofitimpacts$BChairrace_White,
## data = nonprofitimpacts)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.94225 0.05775 0.05775 0.05775 0.47320
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.52680 0.01323 39.81 <2e-16 ***
## nonprofitimpacts$BChairrace_White 0.41545 0.01486 27.96 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3078 on 2617 degrees of freedom
## Multiple R-squared: 0.2301, Adjusted R-squared: 0.2298
## F-statistic: 782 on 1 and 2617 DF, p-value: < 2.2e-16
plot(lm(nonprofitimpacts$CEOrace_White~nonprofitimpacts$BChairrace_White, data=nonprofitimpacts))




summary(nonprofitimpacts)
## ResponseId ProgDem PplSrv MajGiftAmt
## Length:2619 Min. : 0.000 Min. :0.000e+00 Min. : 0
## Class :character 1st Qu.: 0.000 1st Qu.:3.420e+02 1st Qu.: 500
## Mode :character Median : 0.000 Median :1.500e+03 Median : 1000
## Mean : 2.704 Mean :1.575e+06 Mean : 3557
## 3rd Qu.: 5.000 3rd Qu.:7.500e+03 3rd Qu.: 5000
## Max. :10.000 Max. :4.000e+09 Max. :200000
## CEOrace_White BChairrace_White PercentDemPOCBoard Northeast
## Min. :0.0000 Min. :0.0000 Min. : 0.000 Min. :0.0000
## 1st Qu.:1.0000 1st Qu.:1.0000 1st Qu.: 0.000 1st Qu.:0.0000
## Median :1.0000 Median :1.0000 Median : 1.000 Median :0.0000
## Mean :0.8564 Mean :0.7934 Mean : 2.471 Mean :0.1798
## 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.: 4.000 3rd Qu.:0.0000
## Max. :1.0000 Max. :1.0000 Max. :11.000 Max. :1.0000
## Midwest South West
## Min. :0.0000 Min. :0.0000 Min. :0.0000
## 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:0.0000
## Median :0.0000 Median :0.0000 Median :0.0000
## Mean :0.1333 Mean :0.3765 Mean :0.3104
## 3rd Qu.:0.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :1.0000 Max. :1.0000 Max. :1.0000