Posts

Showing posts from October, 2025

Module 9 Assignment

Image
 In this assignment, I was given a data frame to generate a simple table in R that consisted of four columns: Country, age, salary, and Purchased. I had to generate a contingency table (rx C table) using the mtcars dataset.  Question 1: I used the given data frame called "assignment_data" to format each data into its own line. So, by using the data.frame() function and manually entering the values for each variable. I placed each variable in their own lines so that it is easier to read but it also automatically placed them in separate columns for the table. After defining the data frame, I displayed it by typing "assignment_data", which printed the table showing all ten observations and their corresponding values for each variable. Question 2: I generated a contingency table that represents the relationship between two variables in the mtcars dataset. I chose gear and cylinders to be my two variables. The value of cylinder makes up the columns, and the value of gear...

Module 8 Assignment

Image
  A researcher is interested in the effects of drug against stress reaction. She gives a reaction time to three different groups of subjects: one group that is under a great deal of stress, one group that is under a moderate amount of stress, and a third group that is under almost no stress. The subjects od the study were instructed to take the drug test during their next stress episode and to report their stress on a scale of 1 to 10 (10 being most pain). Report on drug and stress level by using R. Provide a full summary report on the results of ANOVA testing and what does it mean. More specifically, report using the following R functions: Df, Sum, Sq mean, Sq, F value, Pr(>F) Fist I created a data frame using the data provided, which includes three columns of different levels of stress high, moderate, and low. The data from these columns were combined into a single vector called "data.combined" to simplify assigning group labels, with each stress levels repeated six time...

Module 7 Assignment

Image
For the assignment, I used the regression equation Y=a+bX+e and the lm() function which is lm([target variable] ~ [predictor variables], data = [data source]). The data for this assignment is: x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10) y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48) 1.1  Define the relationship model between the  predictor  and the  response  variable: The relationship between the predictor and the response variable is shown through the equation Y = 19.206 + 3.269X, where 19.206 is the intercept and 3.269 is the slope. The intercept represents the predicted value of Y when X equals zero. The slope indicates that for each one-unit increase in X, the value of Y is expected to increase by 3.269 units. 1.2 Calculate the coefficients: I used the coefficients() function on the linear regression model to calculate the return an intercept value of 19.206 and an x value of 3.269. Problem using the simple linear regression model: I applied a simp...

Module 6 Assignment

Image
  A. Consider a population consisting of the following values, which represents the number of ice cream purchases during the academic year for each of the five housemates. 8,14,16,10,11 a) Compute the mean of this population I created a vector called ice_cream_purchase from the values that was provided and calculated the mean of the values using the mean() function. The set.seed was to make sure the results of consistent. The mean of this population was calculated to be 11.8. I created a sample of ice_cream_purchase using the sample() function and selected a random sample size of 2. I labeled it as ice.cream.sample. The random sample results were 16 and 14. I computed the mean, sample, and standard deviation of the sample using the mean() and sd() functions. The mean is 15 and the standard deviation is 1.414214 for the sample. I calculated the population mean which is 11.8 as well as the standard deviation of the population which is 3.193744. Next, I compared the sample mean (15) w...