Exploring HTML Dog – Blog 3

I am against humanities students learning to code. Despite this I think humanities students should have a general understanding of what coding is and the potential for different projects and visualizations. As Matthew G. Kirschenbaum puts it, “More significantly, many of us in the humanities miss the extent to which programming is a creative and generative activity”. With the onset of AI, especially large language models (LLM’s) being able to code without understanding how to actually code is a total possibility and I expect this trend to continue as LLM’s develop further. With this trend, its possible for code and visualizations to be created without the technical knowledge for how to actually create them. Nonetheless, you still need to have some sort of knowledge as to how coding works because an LLM might make errors or not generate a project’s code entirely. A better focus for humanities students would be to learn how to use AI to help them create visualizations and better understand projects. AI can create the necessary code for visualizations.

I have previous coding experience in C#, r, and partial coding experience in python. I learned C# prior to Carleton using Youtube. I learned out to create a video game on Unity Hub using this code and Youtube. I learned r during my time at Carleton through my economic courses. I learned python through Chat GPT. I used Chat GPT to help me create python scripts and projects. I was able to pick up coding knowledge through using GPT to create scripts and projects. I also learned a bit of HTML this way so I could build web scrapers. I’m confident that in using GPT I can create any type of project with code and learn along the way.

Below is a coding example of what I created from HTML Dog:

<!DOCTYPE html>
<html>
<body>
    This is my first web page
</body>
</html>

This is a chuck of r code that I created with the help of Chat GPT to run a regression:

```{r knitr::opts_chunk$set(echo = FALSE)}
```

```{r setup, include=FALSE}
library(dplyr)
library(psych)
library(knitr)
library(kableExtra)
library(broom)
library(tidyr)
library(purrr)
library(tibble)
```

## 2019 Regression

```{r 2019, echo=FALSE, results='asis'}
data <- read.csv("/Volumes/My Passport/Comps Related/Data/2019.csv")

data$Neighborhood_Class <- factor(data$Neighborhood_Class, levels = c("A+", "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F"))

data$Asset_Class <- factor(data$Asset_Class, levels = c("A+", "A", "A-", "B+", "B", "B-", "C+", "C", "C-", "D+", "D", "D-", "F"))

data$PM <- factor(data$PM_Type, levels = c("Local", "National", "Regional", "International"))

data$Green_Status <- factor(data$Green_Building, levels = c("N", "Y"))

data$REIT <- factor(data$REIT, levels = c("N", "Y"))

data$County <- factor(data$County, levels = c("Essex County, NJ", "Marion County, IN", "Ramsey County, MN", "Maricopa County, AZ", "Orange County, CA", "San Mateo County, CA", "Alameda County, CA", "San Diego County, CA", "San Franscico County, CA", "Los Angeles County, CA", "Ventura County, CA", "Denver County, CO", "District of Columbia", "Duval County, FL", "Broward County, FL", "Miami Dade County, FL", "Fulton County, GA", "Cook County, IL", "Jackson County, MO", "Hennepin County, MN", "Mecklenburg County, NC", "Middlesex County, NJ", "Clark County, NV", "Suffolk County, NY", "Kings County, NY", "Queens County, NY", "Westchester County, NY", "Franklin County, OH", "Philidelphia County, PA", "Davidson County, TN", "Harris County, TX", "Dallas county, TX", "Travis County, TX", "Bexar County, TX", "Tarrant County, TX", "Fairfax County, VA", "King County, WA", "Pierce County, WA", "Milwaukee County, WI", "Fairfield County, CT"))

data$Total_Units <- cut(data$Unit_Count,
                                breaks = c(99, 150, 200, 250, 300, 350, 400, 450, Inf),
                                right = TRUE,
                                labels = c("100-150", "151-200", "201-250", "251-300", "301-350", "351-400", "401-450", "451+"),
                                include.lowest = TRUE)

# Adjusting the pctg_studio units
data$pctg_studio <- data$pctg_studio / 0.01

# Adjusting the pctg_1bd units
data$pctg_one_bed <- data$pctg_one_bed / 0.01

# Adjusting the pctg_2bd units
data$pctg_two_bed <- data$pctg_two_bed / 0.01

# Adjusting the pctg_3bd units
data$pctg_three_bed <- data$pctg_three_bed / 0.01

# Model with a rent control 
model_with_rent <- lm(Lease_Up_Length ~ pctg_studio + pctg_one_bed + pctg_two_bed + pctg_three_bed + Asset_Class + Neighborhood_Class + Green_Status + REIT + PM + County + Total_Units + Average_rent, data = data)

# Function to append significance levels
add_significance <- function(p.value){
  ifelse(p.value < 0.001, "***",
         ifelse(p.value < 0.01, "**",
                ifelse(p.value < 0.05, "*",
                       ifelse(p.value < 0.1, ".", ""))))
}

# Tidy and modify the first model's output
tidy_model_with_rent <- tidy(model_with_rent) %>%
  mutate(significance = sapply(p.value, add_significance),
         Estimate = paste0(round(estimate, 4), significance)) %>%
  select(term, Estimate)

# Display the summary of the first model with significance levels
kable(tidy_model_with_rent, caption = "Summary of Model with Rent Control with Significance Levels") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

# Extract model summary for easier access
model_summary <- summary(model_with_rent)

# Prepare statistics
residual_se <- sprintf("Residual standard error: %.3f on %d degrees of freedom", 
                       model_summary$sigma, model_summary$df[2])
multiple_r_squared <- sprintf("Multiple R-squared: %.3f", 
                              model_summary$r.squared)
adjusted_r_squared <- sprintf("Adjusted R-squared: %.4f", 
                              model_summary$adj.r.squared)

# Correctly calculate and format the F-statistic and its p-value
f_value <- model_summary$fstatistic["value"]  # F-statistic value
f_df1 <- model_summary$fstatistic["numdf"]    # Degrees of freedom (model)
f_df2 <- model_summary$fstatistic["dendf"]    # Degrees of freedom (residual)
f_pvalue <- pf(f_value, f_df1, f_df2, lower.tail = FALSE)  # Calculate p-value from F-statistic
f_statistic <- sprintf("F-statistic: %.2f on %d and %d DF, p-value: %e", 
                       f_value, f_df1, f_df2, f_pvalue)

# Create a data frame for the table, ensuring each vector has the same length
model_stats <- data.frame(
  Statistic = c("Residual Standard Error", "Multiple R-Squared", "Adjusted R-Squared", "F-Statistic"),
  Value = c(residual_se, multiple_r_squared, adjusted_r_squared, f_statistic)
)

# For Table 1: Categorical variables summary with blanks for frequencies of 1 or 0
categorical_summary <- data %>%
  select_if(is.factor) %>%
  map_df(~{
    # Create the frequency table
    freq_table <- table(.x)
    # Replace 1's and 0's with NA (which will appear as blank in the final table)
    freq_table[freq_table <= 1] <- ""
    # Convert to tibble without using .x in enframe
    enframe(name = "Level", value = "Frequency", x = freq_table)
  }, .id = "Variable") %>%
  kable(caption = "Summary of Categorical Variables Frequency", na = "") %>% # Set NA values to appear as blank
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

# For Table 2: Numeric variables summary
numeric_summary <- data %>%
  select_if(is.numeric) %>% 
  summarise(across(everything(), list(
    Mean = ~mean(., na.rm = TRUE),
    Median = ~median(., na.rm = TRUE),
    `St. Dev` = ~sd(., na.rm = TRUE)
  ), .names = "{.col}_{.fn}")) %>%
  pivot_longer(cols = everything(), names_to = "Variable_Statistic", values_to = "Value") %>%
  separate(Variable_Statistic, into = c("Variable", "Statistic"), sep = "_", extra = "merge") %>%
  pivot_wider(names_from = Statistic, values_from = Value, values_fn = list(Value = mean)) %>%
  kable(caption = "Summary of Numeric Variables") %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

# Print the tables
print(categorical_summary)
print(numeric_summary)

```

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

css.php