-
Notifications
You must be signed in to change notification settings - Fork 2
/
datarun.R
67 lines (37 loc) · 1.38 KB
/
datarun.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ANOVA code for PSQI Data
survey = read.csv('PSQI.csv')
PSQIGlobal = survey$PSQIGlobal
PSQIDURAT = survey$PSQIDURAT
PSQIDISTB = survey$PSQIDISTB
PSQILATEN = survey$PSQILATEN
PSQIDAYSDYS = survey$PSQIDAYSDYS
PSQIHSE = survey$PSQIHSE
PSQISLPQUAL = survey$PSQISLPQUAL
PSQIMEDS = survey$PSQIMEDS
gender = survey$Gender
div = survey$Division
weight = survey$Weight
height = survey$Height
bmi = weight/(height^2)
bed = survey$Smartphone.in.Bed
usage = survey$Smartphone.Usage
activity = rep(0,nrow(survey))
activity[survey$Social.Media == 1] = 'Social Media'
activity[survey$Videos == 1] = 'Videos'
activity[survey$Gaming == 1] = 'Gaming'
activity[survey$Internet == 1] = 'Internet'
activity[survey$Instant.Messaging == 1] = 'Instant Messaging'
activity[survey$Online.Shopping == 1] = 'Online Shopping'
survey = data.frame(gender, div, bmi, PSQIDURAT, PSQIDISTB, PSQILATEN,PSQIDAYSDYS, PSQIHSE, PSQISLPQUAL, PSQIMEDS, PSQIGlobal, usage, bed, activity)
survey.nonsu = survey[survey$bed == 'No',]
survey.su = survey[survey$bed == 'Yes',]
model1 = lm(PSQIGlobal ~ usage + gender, data = survey.su)
model2 = lm(PSQIGlobal ~ usage + div, data = survey.su)
model3 = lm(PSQIGlobal ~ usage + activity, data = survey.su)
model4 = lm(PSQIGlobal ~ usage + bmi, data = survey.su)
model5 = lm(PSQIGlobal ~ usage, data = survey.su)
summary(model5)
anova(model4)
anova(model3)
anova(model2)
anova(model1)