To open R with the dataset preloaded, right-click here and choose "Save Target As" to download the file to your computer. Then find the downloaded file and double-click it to open it in R.The data have been loaded into the data frame a. Enter the command a to see the data. The variables in a are animal, gestation, and longevity.animal: the name of the animal speciesgestation: the average gestation period of the species, in dayslongevity: the average longevity of the species, in yearsNotice that the correlation between gestation and longevity has changed.Remember that the correlation is only an appropriate measure of the linear relationship between two quantitative variables. First produce a scatterplot to verify that gestation and longevity are nearly linear in their relationship.To do this in R, copy the entire command below:plot(a$longevity,a$gestation,xlab="Average Longevity of Species (years)", ylab="Average Gestation Period of Species (days)")Observe that the relationship between gestation period and longevity is linear and positive. Now we will compute the correlation between gestation period and longevity.To do that in R, copy the command:cor(a$longevity,a$gestation)Now return to the scatterplot that you created earlier. Notice that there is an outlier in both longevity (40 years) and gestation (645 days). Note: This outlier corresponds to the longevity and gestation period of the elephant.Report the correlation between gestation and longevity and comment on the strength and direction of the relationship. Interpret your findings in context.
Question
To open R with the dataset preloaded, right-click here and choose "Save Target As" to download the file to your computer. Then find the downloaded file and double-click it to open it in R.The data have been loaded into the data frame a. Enter the command a to see the data. The variables in a are animal, gestation, and longevity.animal: the name of the animal speciesgestation: the average gestation period of the species, in dayslongevity: the average longevity of the species, in yearsNotice that the correlation between gestation and longevity has changed.Remember that the correlation is only an appropriate measure of the linear relationship between two quantitative variables. First produce a scatterplot to verify that gestation and longevity are nearly linear in their relationship.To do this in R, copy the entire command below:plot(agestation,xlab="Average Longevity of Species (years)", ylab="Average Gestation Period of Species (days)")Observe that the relationship between gestation period and longevity is linear and positive. Now we will compute the correlation between gestation period and longevity.To do that in R, copy the command:cor(agestation)Now return to the scatterplot that you created earlier. Notice that there is an outlier in both longevity (40 years) and gestation (645 days). Note: This outlier corresponds to the longevity and gestation period of the elephant.Report the correlation between gestation and longevity and comment on the strength and direction of the relationship. Interpret your findings in context.
Solution
The instructions provided are for analyzing a dataset in R, a programming language used for statistical computing and graphics. Here are the steps:
-
Download the dataset: Right-click on the provided link and select "Save Target As" to download the file to your computer.
-
Open the dataset in R: Locate the downloaded file on your computer and double-click it to open it in R. The data will be loaded into a data frame named 'a'. You can view the data by entering the command 'a' in R.
-
Understand the variables: The data frame 'a' contains three variables - 'animal' (the name of the animal species), 'gestation' (the average gestation period of the species, in days), and 'longevity' (the average longevity of the species, in years).
-
Create a scatterplot: To visualize the relationship between 'gestation' and 'longevity', create a scatterplot using the command: plot(agestation,xlab="Average Longevity of Species (years)", ylab="Average Gestation Period of Species (days)")
-
Compute the correlation: To calculate the correlation between 'gestation' and 'longevity', use the command: cor(agestation)
-
Analyze the scatterplot and correlation: Look at the scatterplot you created and the correlation value. Notice if there are any outliers. For example, an animal with a longevity of 40 years and a gestation period of 645 days would be an outlier. This outlier corresponds to the elephant.
-
Interpret your findings: Based on the correlation value and the scatterplot, comment on the strength and direction of the relationship between gestation period and longevity. Remember, a positive correlation indicates that as one variable increases, the other also increases. A negative correlation indicates that as one variable increases, the other decreases. The closer the correlation value is to 1 or -1, the stronger the relationship. Interpret your findings in the context of the animal species, gestation periods, and longevities in your dataset.
Similar Questions
To open R with the dataset preloaded, right-click here and choose "Save Target As" to download the file to your computer. Then find the downloaded file and double-click it to open it in R.The data have been loaded into the data frame h. Enter the command h to see the data. There are three variables in h: gender, height, and weight.The variables are identified as follows:gender: 0 = male, 1 = female.height: in inches.weight: in pounds.First we will create a scatterplot to examine how weight is related to height, ignoring gender.To do that in R, copy the following command to R:plot(h$height,h$weight)Again, a good graphic should have labels so lets add x and y-axis labels:plot(h$height,h$weight, xlab="Height (inches)", ylab="Weight (lbs)")Describe the relationship between the height and weight of the subjects suggested by the data. Consider the pattern of the data—mainly direction and form—and any deviations from this pattern, such as outliers.
Now return to the scatterplot that you created earlier. Notice that there is an outlier in both longevity (40 years) and gestation (645 days). Note: This outlier corresponds to the longevity and gestation period of the elephant.What do you think will happen to the correlation if we remove this outlier?To do this in R, copy the following command:cor(a$longevity[a$animal!="elephant"],a$gestation[a$animal!="elephant"])Notice that the correlation between gestation and longevity has changed.Report the new value for the correlation between gestation and longevity and compare it to the value you found earlier when the outlier was included. What is it about this outlier that results in the fact that its inclusion in the data causes the correlation to increase? (Hint: look at the scatterplot.)
Use R data frames to study and analyze real-world datasets, perform basic data manipulations, and generate descriptive statistics using R functions.
## 1. Load data set(s) and libraries ```{r} load("C:\\Users\\local_9\\OneDrive\\Desktop\\Assignments\\Second Year\\Statistics\\Statistics final project\\High_School_Alcoholism") vars <- c("X1st_Semester_Grade", "Alcohol_Weekdays", "Alcohol_Weekends", "Desire_Graduate_Education") my_data <- data.frame(vars) library(descr) library(stats) save.image("myProject.RDATA") ```
Use the packages “survival” and "survminer" in RStudio to answer the following three questions. See Question 3 in Practice sheet 4 for details on how to use the above packages to analyse the data. You need to setup up the above data in a csv file (suggest that enter the data in an Excel file in the correct format (with column 1 name as “status” and column 2 name as “time”) and save it as “csv” file.The following data gives the lifetimes (in operating hours) of 23 identical components. The measurements with `*’ indicate suspensions.8.0, 21.3, 25.5, 8.1, 4.5, 4.2, 13.2, 9.9, 11.9*, 27.0, 25.7, 25.8, 28.6, 12.5, 6.0, 19.9, 8.0*, 8.6, 14.5*, 32.9, 15.5, 3.4, 18.2Calculate the Kaplan-Meier estimate of R(20). Give your answer to 3 decimal place accuracy.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.