Hi, I need help in running a Chi-squared test with R This question compares the proportion of overweight and cancer from the data file shown in the following link:...

1 answer below »
I need a few lines of R codes to do chi_square test comparing the proportion of overweight and cancer . The prof already provided the codes for half of the question. I need to complete a few lines to get the cancer patient data and run the test.


Hi, I need help in running a Chi-squared test with R This question compares the proportion of overweight and cancer from the data file shown in the following link: https://drive.google.com/file/d/1T_37kwyyAFZhM5hh9OVtYeDL3Zrmu3hC/view The file name is:   cancer data for MOOC 1.csv a. load the csv file on your desk top. b. extract data from the csv file only two columns : the BMI and Cancer columns c. compare the proportion of overweight and cancer We are given the following code in italics by the prof. and we are asked to add a few lines of code to load the csv file on the desk top so we can run it in R-studio. BMI >= 25 is defined as overweight and is assigned (1) and not overweight is assigned (0). # define the variables and the object g 1 cancer <-g $cancer="" 2="" 3="" overweight=""><- ifelse(g$bmi="">=25,1,0) # check variable and object g to make sure everything makes sense # here is the output table we should be getting 1 table ( overweight ) 2 3 Overweight 4 5 0 1 6 34 32 # the table says that of the 66 observations, 34 are not overweight and 32 are overweight. # set the null hypothesis : that overweight and cancer are not associated # next perform a chi-squared test, let the y axis be cancer, the dependent variable and x axis the independent variable 1 chi. test( x=overweight, y= cancer) Find the p-value and draw conclusion. Show all of your R coding with # comments and output as required.
Answered 2 days AfterMar 09, 2021

Answer To: Hi, I need help in running a Chi-squared test with R This question compares the proportion of...

Naveen answered on Mar 09 2021
151 Votes
# Reading data from Excel
cancer_data <- read.csv('cancer data for MOOC 1.csv')

# Defining the
variables by taking from the cancer_data
# Taking cancer variable from cancer_data
cancer <- cancer_data$cancer
# Creating overweight variable to the categorical that is one or zero
# If bmi is greater than 25 coded as 1 if it is less than it is coded as 0.
overweight <- ifelse(cancer_data$bmi>=25,1,0)
# check variable and object...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here