hw5.template

pdf

School

San Francisco State University *

*We aren’t endorsed by this school

Course

119

Subject

Statistics

Date

Apr 3, 2024

Type

pdf

Pages

9

Uploaded by HighnessKingfisher388

Report
HW5 Maritza Romero 12/05/22 HW 05 - Introduction (100 pts). Assignment Overview The purpose of this assignment is to review ANOVA, correlation and simple linear regression. Instructions You will answer the questions directly in the Rmarkdown template file provided. Please change your name in the template file. How to insert R code chunks: You can quickly insert chunks into your R Markdown file with the keyboard shortcut Cmd + Option + I (Windows Ctrl + Alt + I). You can knit a PDF and upload the final pdf file to BB learn. Background information The American Psychological Association defines resilience as “the process of adapting well in the face of adversity, trauma, tragedy, threats or even significant sources of stress”. Resilience refers to a person’s capacity to resist adversity and is closely related to qualities such as self-confidence and persistence. Studies have suggested that resilience is an important factor in contributing to how medical students perceive their quality of life and educational environment. Survey data were collected from 1,350 students across 25 medical schools in the United States as part of a study examining the life of students and residents in healthcare professions. At each school, 54 students were randomly selected to participate in the study. Participants completed assessments measuring resilience, quality of life, perception of educational environment, depression symptoms, and anxiety symptoms. The variables related to this assignment are listed below. age . age in years. Resilience . Higher scores on the resilience assessment are indicative of greater resilience; possible scores range from 14 to 98. The scores are reported according to a standardized scale: very low (14 to 56 points), low (57 to 64 points), moderately low (65 to 73 points), moderately high (74 to 81 points), high (82 to 90 points), and very high (91 to 98 points). Depression Symptoms . The BDI questionnaire was used to assess depressive symptoms. Possible scores vary from 0 to 63, with higher scores indicating either more numerous or more severe depressive symptoms. Quality of Life . Quality of life was assessed via three measures: overall quality of life (overall QoL), medical school quality of life (MSQoL), and a questionnaire from the World Health Organization (WHOQOL). For the overall QoL and MSQoL, students were asked to rate, on a scale from 0 to 10 with a higher score indicating better QoL, their overall quality of life and their quality of life in medical school. The WHOQOL is a 26-question survey measuring quality of life in four domains (environment, 1
psychological health, social relationships, and physical health); participant responses to questions such as “Do you have enough energy for everyday life?” and “How well are you able to concentrate?” are converted to a 0 to 100 point score for each domain, with higher scores representing better quality of life. Part I: ANOVA (30 points) The question for this part is to investigate whether the mean scores for BDI (bdi) is the same across different levels of resilience groups (res). . Create a plot illustrating the relationship between resilience and depressive symptoms. Describe what you see. (Hint: try a boxplot) boxplot(resilience$bdi ~ resilience$res, ylab = "Depressive Symptoms" , xlab = "Resilience Levels" ) High Low ModHigh ModLow VeryHigh VeryLow 0 10 20 30 40 Resilience Levels Depressive Symptoms ii. Conduct a formal analysis of the relationship between resilience and depressive symptoms. Summarize your findings. You may proceed with ANOVA without checking assumptions for this sub-question. (Hint: use the aov() and summary() functions) summary(aov(resilience$bdi ~ resilience$res)) ## Df Sum Sq Mean Sq F value Pr(>F) 2
## resilience$res 5 20325 4065 118.1 <2e-16 *** ## Residuals 1344 46260 34 ## --- ## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1 iii. If the result from part I (ii) is significant, please proceed to pairwise comparisons to find out which pair(s) of groups have mean scores of BDI different from each other. (Hint: use the pairwise.t.test( ) function in R ) pairwise.t.test(resilience$bdi, resilience$res, p.adj = "none" ) ## ## Pairwise comparisons using t tests with pooled SD ## ## data: resilience$bdi and resilience$res ## ## High Low ModHigh ModLow VeryHigh ## Low < 2e-16 - - - - ## ModHigh 2.2e-06 3.0e-14 - - - ## ModLow < 2e-16 1e-04 6.2e-06 - - ## VeryHigh 4.6e-06 < 2e-16 2.5e-16 < 2e-16 - ## VeryLow < 2e-16 1.9e-11 < 2e-16 < 2e-16 < 2e-16 ## ## P value adjustment method: none Part II: Correlation (Total 25 points) Investigate whether there is a correlation between BDI (bdi) and quality of life as measured by the psychological health domain of the WHOQOL (whoqol.psych). i. Create a plot illustrating the relationship between bdi and whoqol.psych. Describe what you see. (5 pts) (Hint: try a scatter plot) x <- resilience$whoqol.psych y <- resilience$bdi plot(x,y, main = "Quality of life vs. BDI" , xlab = "BDI" , ylab = "Quality of life" ) 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
0 20 40 60 80 100 0 10 20 30 40 Quality of life vs. BDI BDI Quality of life ii. Calculate the pearson correlation coefficient r using R, and conduct a hypothesis test to see whether the population correlation between BDI and quality of life as measured by the psychological health domain of the WHOQOL (whoqol.psych) is equal to 0. Report the test statistic, p value, and your conclusion. (10 pts) (Hint: use the cor.test() function in R) cor.test(resilience$bdi, resilience$whoqol.psych) ## ## Pearson’s product-moment correlation ## ## data: resilience$bdi and resilience$whoqol.psych ## t = -40.243, df = 1348, p-value < 2.2e-16 ## alternative hypothesis: true correlation is not equal to 0 ## 95 percent confidence interval: ## -0.7620606 -0.7135140 ## sample estimates: ## cor ## -0.738744 iii. Find out the 95% confidence interval for population correlation between BDI and quality of life as mea- sured by the psychological health domain of the WHOQOL (whoqol.psych) and write your conclusion in a sentence. (10 pts) (hint: you should find your answer from the R output of part 1 (ii)) (-0.7620606, -0.7135140) 4
PART III: Simple linear regression (Total 35 points) Investigate whether there is a linear association between quality of life as measured by the physical health domain of the WHOQOL (whoqol.phys) and quality of life as measured by the psychological health domain of the WHOQOL (whoqol.psych). Quality of life as measured by the psychological health domain of the WHOQOL (whoqol.psych) is the response variable. i. Create a scatterplot illustrating the relationship between whoqol.phys and whoqol.psych. Describe what you see. (5 pts) x <- resilience$whoqol.phys y <- resilience$whoqol.psych plot(x,y, main = "Quality of Life Psychological Vs. Quality of Life Physical" , xlab = "Physical" , ylab = 20 40 60 80 100 0 20 40 60 80 100 Quality of Life Psychological Vs. Quality of Life Physical Physical Psychological ii. Create a scatterplot with fitted regression line illustrating the relationship between whoqol.phys and whoqol.psych. (5 pts) x <- resilience$whoqol.phys y <- resilience$whoqol.psych plot(x,y, main = "Quality of Life Psychological Vs. Quality of Life Physical" , xlab = "Physical" , ylab = abline(lm(y~x, data = resilience), col = "blue" ) 5
20 40 60 80 100 0 20 40 60 80 100 Quality of Life Psychological Vs. Quality of Life Physical Physical Psychological iii. Fit a linear regression model to investigate whether there is a linear association between quality of life as measured by the physical health domain (whoqol.phys) and quality of life as measured by the psychological health domain of the WHOQOL (whoqol.psych). Briefly discuss whether there is significant evidence of an association between whoqol.phys and quality of life as measured by the psychological health domain of the WHOQOL (whoqol.psych); be sure to report the relevant numerical evidence. (10 pts) lm(resilience$whoqol.psych ~ resilience$whoqol.phys)$coef ## (Intercept) resilience$whoqol.phys ## 15.0336348 0.7157915 lmresilience = lm(resilience$whoqol.psych ~ resilience$whoqol.phys) summary(lmresilience) ## ## Call: ## lm(formula = resilience$whoqol.psych ~ resilience$whoqol.phys) ## ## Residuals: ## Min 1Q Median 3Q Max ## -53.947 -7.159 0.223 8.110 37.618 ## ## Coefficients: 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 15.03363 1.44204 10.43 <2e-16 *** ## resilience$whoqol.phys 0.71579 0.02157 33.19 <2e-16 *** ## --- ## Signif. codes: 0 ’***’ 0.001 ’**’ 0.01 ’*’ 0.05 ’.’ 0.1 ’ ’ 1 ## ## Residual standard error: 11.65 on 1348 degrees of freedom ## Multiple R-squared: 0.4496, Adjusted R-squared: 0.4492 ## F-statistic: 1101 on 1 and 1348 DF, p-value: < 2.2e-16 iv. Please evaluate the assumptions (constant variability and normality of residuals) behind the analysis from part iii, and summarize your findings. (15 pts) lmresilience <- lm(resilience$whoqol.psych ~ resilience$whoqol.phys) plot(lmresilience$fitted.values, lmresilience$residuals) abline( h= 0 ) 30 40 50 60 70 80 -40 -20 0 20 40 lmresilience$fitted.values lmresilience$residuals qqnorm(lmresilience$residuals, cex.main = 0.8 ) qqline(lmresilience$residuals, col = "red" ) 7
-3 -2 -1 0 1 2 3 -40 -20 0 20 40 Normal Q-Q Plot Theoretical Quantiles Sample Quantiles Part IV: Continue to add to your computing guide in R (Total 10 pts) Please create a computing guide in R including the statistical tests that we have learned so far by adding statistical test functions for ANOVA, correlation, and simple linear regression to the homework assignment 4 part III. (Hint: you can put eval = FALSE, echo = TRUE in the brackets to display code without running it, as seen below) ## To create a boxplot boxplot(resilience$bdi ~ resilience$res, ylab = "Depressive Symptoms" , xlab = "Resilience Levels" ) ## To conduct a formal analysis summary(aov(resilience$bdi ~ resilience$res)) ## To conduct a pairwise comparasion pairwise.t.test(resilience$bdi, resilience$res, p.adj = "none" ) ## To create a plot illustrating the relationship between bdi and whoqol.psych x <- resilience$whoqol.psych y <- resilience$bdi plot(x,y, main = "Quality of life vs. BDI" , xlab = "BDI" , ylab = "Quality of life" ) ##To calculate the correlation coefficient 8
cor.test(resilience$bdi, resilience$whoqol.psych) ## To create a scatterplot with a fitted regression line illustrating the relationship between whoqol.ph x <- resilience$whoqol.phys y <- resilience$whoqol.psych plot(x,y, main = "Quality of Life Psychological Vs. Quality of Life Physical" , xlab = "Physical" , ylab = abline(lm(y~x, data = resilience), col = "blue" ) ## To create linear regression model lm(resilience$whoqol.psych ~ resilience$whoqol.phys)$coef lmresilience = lm(resilience$whoqol.psych ~ resilience$whoqol.phys) summary(lmresilience) ## Constant variability and normality of residuals lmresilience <- lm(resilience$whoqol.psych ~ resilience$whoqol.phys) lmresilience$residuals lmresilience$fitted.values plot(lmresilience$fitted.values, lmresilience$residuals) abline( h= 0 ) qqnorm(lmresilience$residuals, cex.main = 0.8 ) qqline(lmresilience$residuals, col = "red" ) Part V: Bonus (Optional) a. Attend community coding or office hours: please list the date, time and the faculty/student assistant you met. b. Successfully answer peer’s questions in Discord: please take a screenshot and insert each one below. Meet with instructor on Thursday at @10am (12/01/22) 9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help