0% found this document useful (0 votes)
14 views1 page

Sleep Quality vs Academic Stress Analysis

The document contains code to analyze the relationship between academic stress and sleep quality. Descriptive statistics are calculated for the mean and standard deviation of sleep quality and academic stress. A scatter plot is generated with a regression line fitted between sleep quality and academic stress variables. The linear regression model finds a statistically significant negative relationship between academic stress and sleep quality.

Uploaded by

ayushiitesh423
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views1 page

Sleep Quality vs Academic Stress Analysis

The document contains code to analyze the relationship between academic stress and sleep quality. Descriptive statistics are calculated for the mean and standard deviation of sleep quality and academic stress. A scatter plot is generated with a regression line fitted between sleep quality and academic stress variables. The linear regression model finds a statistically significant negative relationship between academic stress and sleep quality.

Uploaded by

ayushiitesh423
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Your Workspace / RM Projects RAM AI Ayushi Itesh

File Edit Code View Plots Session Build Debug Profile Tools Help

Go to file/function Addins R 4.3.2


newdata_ Rm1.R Environment History Connections Tutorial
8 Run Source Import Dataset 487 MiB List
R Global Environment
9describe(data= AcademicStress_SleepQuality,
Data
10 mean_sleep1 = mean(Sleep1), model List of 12
11 mean_sleep2 = mean(Sleep2), newdata_ 37 obs. of 20 variables
12 mean_sleep3 = mean(Sleep3),
13 mean_sleep4 = mean(Sleep4),
14 mean_sleep5 = mean(Sleep5))
15
describe(data= AcademicStress_SleepQuality,
16 mean_sleep6 = mean(Sleep6),
17 mean_sleep7 = mean(Sleep7),
18 mean_sleep8 = mean(Sleep8),
19 mean_sleep9 = mean(Sleep9),
20 mean_sleep10 = mean(Sleep10))
21

22
# paired t test
23
scatterplot(AcademicStress_SleepQuality,
24 x= )
25

26

27

28

29

30
glimpse(AcademicStress_SleepQuality)
31

32
SQ <- select(AcademicStress_SleepQuality, Sleep1, Sleep2,Sleep3,Sleep4,Sleep5,Sleep6,Sleep7,Sleep8,Sleep9,Sleep10)
33
View(SQ)
34
AS <- select(AcademicStress_SleepQuality, Stress1,Stress2,Stress3,Stress4,Stress5,Stress6,Stress7,Stress8)
35
View(AS)
36

37
scatterplot(data= SQ,
38 x= Sleep2,
39 Y= Sleep1,
40 best_fit_line = TRUE)
41
Files Plots Packages Help Viewer Presentation
42
Zoom Export Publish
43

44

45
## # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # ### ## # # # #
46
# descriptive stats -> mean, SD
47
describe(data = newdata_,
48 mean_sleep = mean(SleepQualityAverage),
49 sd_sleep = sd(SleepQualityAverage),
50 mean_stress = mean(AcademicStressAverage),
51 sd_stress = sd(AcademicStressAverage))
52
## # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # ### ## # # # #
53
scatterplot(data= newdata_,
54 y= SleepQualityAverage,
55 x= AcademicStressAverage,
56 best_fit_line = TRUE,
57 ylab = "SleepQualityAverage",
58 xlab = "AcademicStressAverage")
59
model <- lm(SleepQualityAverage ~AcademicStressAverage, data = newdata_)
60
summary(model)
61
## # # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # # # # # # # #

38:23 (Top Level) R Script


Console
R 4.3.2Terminal Background Jobs
· /cloud/project/
R 4.3.2 · /cloud/project/
> describe(data = newdata_,
+ mean_sleep = mean(SleepQualityAverage),
+ sd_sleep = sd(SleepQualityAverage),
+ mean_stress = mean(AcademicStressAverage),
+ sd_stress = sd(AcademicStressAverage))
# A tibble: 1 × 4
mean_sleep sd_sleep mean_stress sd_stress
<dbl> <dbl> <dbl> <dbl>
1 1.22 0.652 2.69 0.636
> scatterplot(data= newdata_,
+ y= SleepQualityAverage,
+ x= AcademicStressAverage,
+ best_fit_line = TRUE,
+ ylab = "SleepQualityAverage",
+ xlab = "AcademicStressAverage")
> model <- lm(SleepQualityAverage ~AcademicStressAverage, data = n
ewdata_)
> summary(model)

Call:
lm(formula = SleepQualityAverage ~ AcademicStressAverage, data = n
ewdata_)

Residuals:
Min 1Q Median 3Q Max
-1.0201 -0.4002 -0.1427 0.3473 1.5798

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.3551 0.4364 5.396 4.83e-06
AcademicStressAverage -0.4199 0.1579 -2.660 0.0117

(Intercept) ***
AcademicStressAverage *
---
Signif. codes:
0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.6028 on 35 degrees of freedom


Multiple R-squared: 0.1682, Adjusted R-squared: 0.1444
F-statistic: 7.077 on 1 and 35 DF, p-value: 0.0117

You might also like