Posts

Showing posts from October, 2023

Module #9 Assignment

  1. Your data.frame is > assignment_data <- data.frame( Country = c("France","Spain","Germany","Spain","Germany", "France","Spain","France","Germany","France"), age = c(44,27,30,38,40,35,52,48,45,37), salary = c(6000,5000,7000,4000,8000), Purchased=c("No","Yes","No","No","Yes", "Yes","No","Yes","No","Yes")) Generate simple table in R that consists of four rows: Country, age, salary and purchased. In order to make a table from the dataframe, I loaded the data.table package. This is the result: > setDT(assignment_data) > assignment_data Country age salary Purchased 1: France 44 6000 No 2: Spain 27 5000 Yes 3: Germany 30 7000 No 4: Spain 38 4000 No 5: Germany 40 8000 Yes 6: France 35 6000 Yes 7: Spain 52...

Module #8 Assignment

1.  Report on drug and stress level by using R. Provide a full summary report on the result 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 ) I created a data frame with the function: > data <- data.frame( + ReactionTime = c(10, 9, 8, 9, 10, 8, 8, 10, 6, 7, 8, 8, 4, 6, 6, 4, 2, 2), + StressLevel = factor(rep(c("High Stress", "Moderate Stress", "Low Stress"), each = 6)) I then printed out the summary of the report using: > report <- aov(ReactionTime ~ StressLevel, data = data) > summary(report) Df Sum Sq Mean Sq F value Pr(>F) StressLevel 2 82.11 41.06 21.36 4.08e-05 *** Residuals 15 28.83 1.92 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 From the p-value it can be concluded that there are differences in reaction times between the stress levels. 2.1 The zelazo data (taken from textbo...

Module #7 Assignment

Image
10/9/2023 1.1 Define the relationship model between the  predictor  and the  response  variable: lm(formula = y ~ x, data = data) y is the response variable and x is the predictor variable. 1.2 Calculate the coefficients?   Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 19.206 15.691 1.224 0.2558 x 3.269 1.088 3.006 0.0169 * --- 2.1 Define the relationship model between  the predictor  and the  response variable . lm(discharge ~ waiting, data = visit) 2.2 Extract the parameters of the estimated regression equation with the  coefficients  function . > coefficients(model) (Intercept) waiting -1.53317418 0.06755757 2.3 Determine the fit of the  eruption  duration using the estimated regression equation. > estimated_eruption (Intercept) 3.871431 3.1 Examine the relationship Multi Regression Model as stated above and its Coefficients using 4 differen...

Module #6 Assignment

 10/2/2023 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. population <- c(8, 14, 16, 10, 11) mean(population) 11.8 b. Select a random sample of size 2 out of the five members.  > sample_size <- 2 > sample <- sample(population, sample_size) > cat("Random sample:", sample, "\n") Random sample: 16 14 c. Compute the mean and standard deviation of your sample. mean(sample) 15 sd(sample) 1.414214 d. Compare the Mean and Standard deviation of your sample to the entire population of this set (8,14, 16, 10, 11). With only 2 of the five members, the mean was higher and standard deviation was lower than the original sample. B.  Suppose that the sample size  n  = 100 and the population proportion  p  = 0.95. Does the sample proportion  p  have approximately a...