Posts

Showing posts from October, 2023

Module #10

Module #10  ### Exercise 9.1: Conducting ANOVA and Regression on "cystfibr" Data In this exercise, you want to perform analysis of variance (ANOVA) and regression analysis on the "cystfibr" dataset, and then interpret the results. **Step 1: Load the Data and Define the Model** First, load the "cystfibr" dataset and define your regression model. ```R # Load the dataset data(cystfibr) # Define the regression model model <- lm(spemax ~ age + weight + bmp + fev1, data = cystfibr) ``` **Step 2: Perform ANOVA** Next, conduct an ANOVA to assess the overall significance of the model. ```R anova_result <- anova(model) ``` **Step 3: Interpret ANOVA Results** An ANOVA table will be generated. Look for the "Pr(>F)" column. This column contains p-values. For the main effects (variables) in your model, if the p-value is less than your chosen significance level (e.g., 0.05), it suggests that the variable is statistically significant. **Step 4: Interpre...

Module # 9

Module #9 Assignment  Question 1: Creating a Simple Table ```R # Create the data frame 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, 7000, 6000, 8000, 5000, 7000),   Purchased = c("No", "Yes", "No", "No", "Yes", "Yes", "No", "Yes", "No", "Yes") ) # Create a simple table simple_table <- as.table(assignment_data) # Print the simple table print(simple_table) ``` Question 2: Generating a Contingency Table and Adding Margins ```R # Load the mtcars dataset (if not already loaded) data(mtcars) # Generate a contingency table for gear and cyl columns assignment9 <- table(mtcars$gear, mtcars$cyl, dnn...

Module 8 Assignment

Amanda Hidalgo  10/14/23 LIS 4273: Advanced Stats & Analytics  Module 8 Assignment    1. Analysis of Variance (ANOVA) for Drug and Stress Level: ```R # Create a data frame with the given data data <- data.frame(   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) ) # Perform a one-way ANOVA result <- aov(data ~ stress_level) # Summary of the ANOVA result summary(result) ``` This R code performs a one-way ANOVA to test the effects of different stress levels on drug reactions. The output of the ANOVA test will provide you with the degrees of freedom (Df), sum of squares (Sum Sq), mean squares (Mean Sq), F-value, and the p-value (Pr(>F)). You can use these values to interpret the results. 2. Analysis of Zelazo Dataset with ANOVA: ```R # Load the ISwR package and the zelazo dataset install.packages("ISwR") library(ISwR) data("zelazo") # Convert the data to a suitable format for AN...

Module #7

Amanda Hidalgo  Module #7 1.1 Define the relationship model between the predictor and the response variable:    - In this case, the relationship model between the predictor (x) and the response variable (y) can be defined as:      `y = a + bx + e`      Where:      - y is the response variable (value of the Dependent variable).      - x is the predictor variable (value of the Independent variable).      - a is the intercept or constant (the value of y when x=0).      - b is the coefficient of x (the slope of the regression line).      - e is the error term (the error in predicting y given x). 1.2 Calculate the coefficients?    - To calculate the coefficients a and b, you can use the lm() function in R. Here's the code to calculate them for your data:        ```R    x <- c(16, 17, 13, 18, 12, 14, 19, 11, 11, 10)    y ...