R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

# Load necessary libraries
library(wooldridge)
library(dplyr)
# Load the DISCRIM dataset from the wooldridge package
data("discrim", package = "wooldridge")

# View the first few rows of the dataset to understand the variables
head(discrim)
# Calculate the mean and standard deviation for prpblck and income
summary_stats <- discrim %>%
  summarise(mean_prpblck = mean(prpblck),
            sd_prpblck = sd(prpblck),
            mean_income = mean(income),
            sd_income = sd(income))

print(summary_stats)
# Run the OLS regression for psoda on prpblck and income
model <- lm(psoda ~ prpblck + income, data = discrim)

# Print the summary of the model
summary(model)
# Run the simple regression of psoda on prpblck
simple_model <- lm(psoda ~ prpblck, data = discrim)

# Print the summary of the simple model
summary(simple_model)
# Run the log-log model
log_model <- lm(log(psoda) ~ prpblck + log(income), data = discrim)

# Print the summary of the log-log model
summary(log_model)
# Add prppov to the model
model_with_prppov <- lm(log(psoda) ~ prpblck + log(income) + prppov, data = discrim)

# Print the summary of the new model
summary(model_with_prppov)
# Calculate the correlation between log(income) and prppov
cor(log(discrim$income), discrim$prppov)
# Check for multicollinearity using VIF
library(car)
vif(model_with_prppov)

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.