Add your Name and the Date

The first thing you need to do in this file is to add your name and date in the lines underneath this document’s title.

Identify and Set Your Working Directory

You need to identify and set your working directory in this section.

Installing and Loading Packages and Data Set

You need to install and load the packages and data set you’ll use for the lab assignment in this section.

Creating Dichotomous Variables

You need to create three dichotomous variables based on existing variables in the data set in this section. The first should be named “Prefers.Brisket” and should take on a value of “1” if a respondent identified beef brisket as their preferred type of BBQ meat and a value of “0” if they did not. The second should be named “Prefers.Fries” and should take on a value of “1” if a respondent identified french fries as their preferred side dish and a value of “0” if they did not. The third should be named “Longer.Distances” and should take on a value of “1” if a respondent is willing to drive longer than average for good BBQ and and value of “0” if they are not.

Relationships between Two Continuous and Most Discrete and Ordinal Variables

You need to produce a pair of basic scatterplots and analyze a pair of bivariate correlations in this section.

Scatterplots

You need to produce two basic scatterplots in this subsection. The first should be between variables that identify respondents’ preferred level of sweetness of BBQ sauce and how much they are willing to pay for a plate of pulled pork. When making this scatterplot, let’s assume you are interested in whether a respondent’s sauce preference influences how much they will pay for a plate of pulled pork. The second scatterplot should be between variables that identify how much respondents are willing to pay for a plate of ribs and how far they are willing to drive for good BBQ. When making this scatterplot, let’s assume you are interested in whether how much respondents are willing to pay for a plate of ribs influences how far they are willing to drive for good BBQ.

Correlations

You need to estimate two bivariate correlations in this subsection. The first should be between variables that identify respondents’ preferred level of sweetness of BBQ sauce and how much they are willing to pay for a plate of pulled pork. The second correlation should be between variables that identify how much respondents are willing to pay for a plate of ribs and how far they are willing to drive for good BBQ.

term Dinner.Plate.Price Sweetness 1 Dinner.Plate.Price NA 0.0220 2 Sweetness 0.0220 NA

term Ribs.Price Minutes.Driving 1 Ribs.Price NA 0.180 2 Minutes.Driving 0.180 NA

Relationships between a Continuous Variable and a Dichotomous Variable

You need to produce a pair of scatterplots appropriate for visualizing the relationship between a continuous and a dichotomous variable and conduct a pair of difference-of-means or t-tests in this section.

Scatterplots

You need to produce two appropriate scatterplots for visualizing the relationship between a continuous and a dichotomous variable in this subsection. The first should be between variables that identify respondents whose favorite type of BBQ is beef brisket and respondents’ preferred level of sauce sweetness. The second scatterplot should be between variables that identify respondents’ age and whether or not french fries are their favorite type of side dish for BBQ. Both scatterplots should plot the continuous variable along the y-axis and the dichotomous variable along the x-axis.Difference-of-Means Tests

You need to estimate two difference-of-means tests using the same two pairs of a continuous variable and a dichotomous variable as you did above in this subsection. You should again assume that you are interested in explaining variation in the continuous variable as a function of the dichotomous variable.

data:  Sweetness by Prefers.Brisket t = 0.18207, df = 54.757, p-value = 0.8562 alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0 95 percent confidence interval:  -0.2324762  0.2789340 sample estimates: mean in group 0 mean in group 1         2.944282        2.921053 
data:  Age by Prefers.Fries t = -0.061739, df = 45.278, p-value = 0.951 alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0 95 percent confidence interval:  -4.015705  3.776800 sample estimates: mean in group 0 mean in group 1         26.35277        26.47222 

Relationships between Two Dichotomous Variables

You need to produce a pair of contingency tables and conduct a pair of \(\chi^{2}\)-tests in this section.

Contingency Tables

You need to produce two contingency tables in this subsection. The first should be between the variables that identify whether a respondent is willing to drive a relatively long way for good BBQ and whether they prefer beef brisket over all other types of BBQ meat. The second contingency table should be between the variables that identify whether a respondent is willing to drive a relatively long way for good BBQ and whether or not they prefer french fries over other side dishes.

          Prefers.Brisket                      Prefers Brisket
Longer.Distances       0 1                              Brisket  Not Brisket
          0           219 29         Will Drive Longer                 
          1           129 9                   Long            9         129
                                          Not Long            29        212
                 Prefers.Fries                              Fries         
Longer.Distances        0   1                Will Drive Longer Fries No Fries
            0          216 25                           Long    11      127
             1         127 11                        Not Long    25      216

\(\chi^{2}\)-tests

You need to conduct two \(\chi^{2}\)-tests using the same two pairs of dichotomous variables as you did above in this subsection. You should assume you are trying to explain whether a respondent is willing to drive longer for good BBQ than average as a function of the other two dichotomous variables.

Pearson's Chi-squared test with Yates' continuity correction 
data:  BivariateRelationshipsData$Longer.Distances and BivariateRelationshipsData$Prefers.Brisket X-squared = 2.3754, df = 1, p-value = 0.1233
Pearson's Chi-squared test with Yates' continuity correction
data:  BivariateRelationshipsData$Longer.Distances and BivariateRelationshipsData$Prefers.Fries
X-squared = 0.34284, df = 1, p-value = 0.5582

Publish Document

Click the “Knit” button to publish your work as an html document. This document or file will appear in the folder specified by your working directory. You will need to upload both this RMarkdown file and the html file it produces to AsU Learn to get all of the points associated with this lab.