-
Notifications
You must be signed in to change notification settings - Fork 1
/
heightweight.R
67 lines (54 loc) · 1.48 KB
/
heightweight.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
67
# avg female (30-39) height & weight, US, 1975
height<-c(1.47,1.50, 1.52, 1.55, 1.57, 1.60, 1.63, 1.65, 1.68, 1.70, 1.73,
1.75, 1.78, 1.80, 1.83)
weight <- c(52.21, 53.12, 54.48, 55.84, 57.20, 58.57, 59.93, 61.29, 63.11,
64.47, 66.28, 68.10, 69.92, 72.19, 74.46)
# make a graph of the x & y dots:
png(filename="heightweight.png",
width=5, height=4, units="in",
pointsize=12, bg="white", res=300,
type="quartz"
)
plot(weight~height,
main="Avg Weights & Heights of US females, 30-39",
pch=21, col="black", bg="red"
)
dev.off()
# make a graph of the x & y dots, with regression line:
png(filename="heightweightregress.png",
width=5, height=4, units="in",
pointsize=12, bg="white", res=300,
type="quartz"
)
plot(weight~height,
main="Avg Weights & Heights of US females, 30-39",
pch=21, col="black", bg="red"
)
fit <-lm(weight~height)
abline(fit, col="blue")
dev.off()
# REgress height on weight:
lm.r=lm(weight~height)
summary(lm.r)
# make a graph of the x & y dots, with regression line:
png(filename="heightweightregressextrapolate.png",
width=5,
height=4,
units="in",
pointsize=12,
bg="white",
res=300,
# type="windows"
type="quartz"
)
plot(weight~height,
main="Avg Weights & Heights of US females, 30-39",
pch=21,
col="black",
bg="red",
xlim=c(0.5,2),
ylim=c(0,80)
)
fit <-lm(weight~height)
abline(fit, col="blue")
dev.off()