library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── 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(ggthemes)
library(ggrepel)
setwd("C:/Users/kaitl/OneDrive/Documents/590_Working")

#update data types of dataframe
energy <- read_delim("./590_FinalData1.csv", delim = ",", col_types = "nccnncnnnnnnnn")
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
energy1 <- energy
energy1[energy1 == '..'] <- NA

Selected binary column of data: full_pop_electricity_access

Build a logistic regression model for the variable, using 1-4 explanatory variables.

Explanatory variables:

  1. total_population_electricity_access
energy1 |>
  ggplot(mapping = aes(x = total_elec_output, y = full_pop_electricity_access)) +
  geom_point(size = 2, color = 'darkblue') +
  theme_minimal()
## Warning: Removed 1108 rows containing missing values (`geom_point()`).

Trying to see the linear model of the data before transforming by using logistic regression

```{# {r} # model <- lm(full_pop_electricity_access ~ total_elec_output, data = energy1, na.action = na.omit)


The transformation, using sigmoid

```{# {r}
# sigmoid <- \(x) 1 / (1 + exp(-(-5 + 0.15 * x)))
# 
# energy1 |>
#   ggplot(mapping = aes(x = energy1$full_pop_electricity_access, y = energy1$TFEC)) +
#   geom_jitter(width = 0, height = 0.1, shape = 'O', size = 3) +
#   geom_function(fun = sigmoid, color = 'blue', linewidth = 1) +
#   labs(title = "Modeling a Binary Response with Sigmoid") +
#   scale_y_continuous(breaks = c(0, 1)) +
#   theme_minimal()