Lab 5
1. More Mini Models. In lecture, we defined linear models using the “mini” dataset.
o Load the data and check to make sure the data loaded correctly. Then, choose
two numeric variables from the dataset - how do you think these variables will
be related to each other? DV: Instagram follows, IV: sleep. I think that the more
lack of sleep you have you are more on social media and are more likely to follow
more Instagram accounts.
o Graph your DV and IV as separate variables using the hist() function. Make sure
there are no errors in the data, and do any data cleaning as necessary. Underneath
the graphs, describe what you observe.
DV:
IV:
o Graph the relationship between the two variables, and add the regression line to the
graph.
o Report the intercept, slope, and R2 value from your model.
o Underneath the graph describe what you learn about the relationship between these
two variables (making sure to reference the relevant statistics reported above.
By analyzing the regression line, there was a positive relationship between the number of accounts
a person follows on Instagram and a person's hours of sleep (b = 58.38), since the regression line
was going upwards. The relationship is not so strong since the line is not very steep, but the points
are close to the line. The slope means that every 1-unit increase of hours of sleep it changes 58.38.
o Finally, use your human brain to make some conclusions. What seems important
about this relationship? Why do you think this relationship occurs? How might we
use this knowledge?
What seems important about this relationship is that people who sleep less, for example 6 hours,
tend to have most likely higher Instagram follows. I think this occurs because people tend to be
more on social media and follow more people, so they sleep less. We could use this knowledge to
try to make people aware of this problem and how social media can affect sleep.
2. (In Discussion Section) Predict [Link] from a variable from the world
happiness dataset. The world happiness dataset reports the average happiness (variable =
[Link]) for each country in the world. Work with a buddy to predict [Link]
(DV) from one of the following numeric variables in the dataset : “[Link]”;
“[Link]”; “[Link]”; “[Link]”;
“Generosity”; or “[Link]”. Make sure to include the following.
o Load your dataset and check to make sure the data are loaded correctly.
o Graph your DV and IV as separate variables using the hist() function. Make sure
there are no errors in the data, and do any data cleaning as necessary.
(Removed
outliers largen than 1)
o Graph the relationship between the two variables, and add the regression line to the
graph.
o Report the intercept, slope, and R2 value from your model.
o Underneath the graph describe what you learn about the relationship between these
two variables (making sure to reference the relevant statistics reported above.)
By analyzing the regression line, there was a positive relationship between the level of happiness
scored by each country and each country’s average of social support (b = 1.30), since the regression
line was going upwards. The relationship is somewhat strong since the line is somewhat steep, and
the points are close to the line. The slope means that every 1-unit increase of social support it
changes 1.30.
o Finally, use your human brain to make some conclusions. What seems important
about this relationship? Why do you think this relationship occurs? How might we
use this knowledge?
What seems important about this relationship is that people who have a larger social support tend
to have most likely higher levels of happiness. I think this occurs because people tend to lean on
people and create bonds, so the more they have, the happier they can be. We could use this
knowledge to try to highlight the importance of social support networks and how it can influence
happiness.
3. (In Discussion Section) Share Your Code. Share your code for Problem 2 with another
student who chose a different IV to predict [Link]. Use their code to generate the
same graph and output that they did. Hooray for Rscripts.
My classmate Hugh and I exchanged codes, even though we both did the same IV (Social Support),
I ran the code removing the outliers, while Hugh kept them, so the values were different. His values
for r squared and slope were higher, but my intercept was higher.