Posts

Showing posts from October, 2024

Module #10 Assignment

> library(ISwR) > # Fit the linear model to predict spemax based on other variables > model <- lm(pemax ~ age + weight + bmp + fev1, data = cystfibr) > anova_results <- anova(model) > print(anova_results) Analysis of Variance Table Response: pemax Df Sum Sq Mean Sq F value Pr(>F) age 1 10098.5 10098.5 18.4385 0.0003538 *** weight 1 945.2 945.2 1.7258 0.2038195 bmp 1 2379.7 2379.7 4.3450 0.0501483 . fev1 1 2455.6 2455.6 4.4836 0.0469468 * Residuals 20 10953.7 547.7 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > summary_results <- summary(model) > print(summary_results$coefficients) Estimate Std. Error t value Pr(>|t|) (Intercept) 179.295719 61.8854992 2.897217 0.008909191 age -3.418055 3.3085843 -1.033087 0.313894581 weight 2.688189 1.1726985 2.292311 0.032866749 bmp -2.065693 0.8198405 -2.519628 ...

Module #9 Assignment

#1 > # Data frame creation > 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, 5500, 4500, 6000, 7500, 5000), + Purchased = c("No", "Yes", "No", "No", "Yes", "Yes", "No", "Yes", "No", "Yes") + ) > > # Display the data frame > 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 5500 Yes 7 Spain 52 4500 No 8 France 48 6000 Yes 9 Germany 45 7500 No 10 France 37 5000...

Module #8 Assignment

#1  > # Data for each group > high_stress <- c(10, 9, 8, 9, 10, 8) > moderate_stress <- c(8, 10, 6, 7, 8, 8) > low_stress <- c(4, 6, 6, 4, 2, 2) > > # Combine data into a data frame > reaction_time <- c(high_stress, moderate_stress, low_stress) > stress_level <- factor(rep(c("High_Stress", "Moderate_Stress", "Low_Stress"), each=6)) > > # Create a data frame > data <- data.frame(Stress_Level = stress_level, Reaction_Time = reaction_time) > > # Perform ANOVA > anova_model <- aov(Reaction_Time ~ Stress_Level, data=data) > > # Summary of ANOVA > summary(anova_model) Df Sum Sq Mean Sq F value Pr(>F) Stress_Level 2 82.11 41.06 21.36 4.08e-05 Residuals 15 28.83 1.92 Stress_Level *** Residuals --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > > # Detailed ANOVA table > anova_table <- su...

LIS 4273 Module #7 Assignment

#1.1 Define the relationship model between the predictor (x) and the response (Y) variable: A simple linear regression can model the relationship between the predictor variable x and the response variable y. #1.2 Calculate the coefficients? > x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10) > y <- c(63, 81, 56, 91, 47, 57, 76, 72, 62, 48) > model <- lm(y ~ x) > summary(model) Call: lm(formula = y ~ x) Residuals: Min 1Q Median 3Q Max -11.435 -7.406 -4.608 6.681 16.834 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 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 10.48 on 8 degrees of freedom Multiple R-squared: 0.5303, Adjusted R-squared: 0.4716 F-statistic: 9.033 on 1 and 8 DF, p-value: 0.01693 #2.1 Define the relationship model between the predictor (x) and the respo...

LIS 4273 Module #6 Assignment

 #1 Ice Cream Purchases Population #A Define the population population <- c(8, 14, 16, 10, 11) #B Calculate the mean population_mean <- mean(population) population_mean [1] 11.8 #C Select a random sample of size 2 sample_size_2 <- sample(population, 2) sample_size_2 [1] 14 10 # Calculate the sample mean sample_mean <- mean(sample_size_2) sample_mean [1] 12 # Calculate the sample standard deviation sample_sd <- sd(sample_size_2) sample_sd [1] 2.828427 #D Calculate the population standard deviation population_sd <- sd(population) population_sd [1] 3.193744 #2 Sampling Distribution of Proportion Does the sample proportion  p   have approximately a normal distribution? Explain. Since both np n p and nq n q is greater than 5, the sampling distribution of p p will be approximately normal. What is the smallest value of  n  for which the sampling distribution of  p  is approximately normal? 100 # Given values n <- 100 p <- 0.95 q ...