2024-02-03

importing data

df <- read.csv("CRIMES AGAINST WOMEN IN INDIA (2022).csv")
df<-na.omit(df)

For this project, we will be looking at data about crimes against women. In particular, this data set is spacfically collected from regions of India, a South Asian country which is unfortunetly plagued by this issue(like most other nations).

What is Simple Linear Regression 3

The objective of Simple Linear Regression is to aid in finding a linear relationship in order to describe the correlation between variables. Typically we are trying to see if a variable is dependent on a independent variable(citation 3). Although most of us are familiar with the formula \[ y = mx+b \] We can use another formula!!!

Simple Linear Regression Equation 4

The Equation for a simple linear Regression is:

\[ y = \beta_0 + \beta_1 x + \epsilon \] When breaking down each component we can say that: \[ \beta_0 \] beta_0 Can be described as the the y intercept of the line \[ \beta_1 \] beta_1 Is the slope of the linear regression line \[ \epsilon \] x and y represent our independent and dependent variables (Citation 4)

least squares method 5

When desiring to create a best fitting line through our data points, the use of the statistical method called least squares which allows us to find the line of best fit for our data points by reducing error(Citation 5). We calculate using the formula:

\[ B_1 = \frac{N(\sum xy) - (\sum x)(\sum y)}{N(\sum x^2)-(\sum x)^2} \] \[ B_0 = \frac{\sum y) - B_1(\sum x)}{N} \]

plotyplot 6

With the use of scatterplots we can better visualize simple linear regression!

R CODE FOR PLOTLY:

plot<- plot_ly(df, x = ~Trafficking, 
               y = ~Sexual.Violence.towards.girl.child, 
               type = "scatter", mode = "markers")

print(plot)

ggplot 1 7

g <- ggplot(data = df, aes(x=Trafficking,y=Sexual.Violence.towards.girl.child))+geom_point()
print(g)

ggplot 2 8

One key component to Simple Linear regression is the “line of best fit” or line that fits best

g <- ggplot(data = df, aes(x=Trafficking,y=Sexual.Violence.towards.girl.child))+geom_point()+ geom_smooth(method = "lm",formula = y~x, se = FALSE,color="deeppink")+
xlim(min(df$Trafficking), max(df$Trafficking))+
ylim(min(df$Sexual.Violence.towards.girl.child),max(df$Sexual.Violence.towards.girl.child))
print(g)

slide citations

slide citations continued