Docsity

Computing in Statistics - Assignment Exercise 1 | STAT 517, Assignments of Statistics

Toggle sidebar
bg1
STAT 517: Exercise 1
We will work with two separate datasets, LakeHuron and Loblolly. The dataset LakeHuron
measures Lake Huron’s water level from 1875 to 1972. Loblolly measures the growth and
age of different loblolly seed varieties. “Loblollies” are loblolly pines, a fast-growing species
important to the commercial timber industry.
Let’s look at LakeHuron first:
data(LakeHuron)
LakeHuron
Does LakeHuron look like any of the data types we have already seen? Why or why not?
LakeHuron is actually a time series with data type ts; try the following query:
is.ts(LakeHuron)
We can confirm this by looking at its class attribute:
attributes(LakeHuron)
Note that the attribute tsp tells us when the series starts, when it ends, and its increment;
the class attribute identifies the data type. Both of these attributes are used by the plot
command to create a time series plot with the proper time scale. Note that the command
itself is quite simple, but uses built-in rules for plotting a ts object:
plot(LakeHuron)
Let’s try plotting every 5 years’ data. Notice how easily multiple commands can be nested
in R.
plot(LakeHuron[seq(1,100,by=5)])
Notice anything unusual in the time series? Lake Huron’s outlet, the St. Clair River, has
been extensively dredged over the years, creating a long-term decrease in lake level that
apparently leveled off decades ago. Concerns over a continuing decrease in the levels of
Lakes Michigan, Superior and Huron continue to this day.
Next we will work with the Loblolly data set.
data(Loblolly)
Loblolly
What kind of data set is this? Is it a matrix or a data frame?
1
pf2

Partial preview of the text

Download Computing in Statistics - Assignment Exercise 1 | STAT 517 and more Assignments Statistics in PDF only on Docsity!

STAT 517: Exercise 1

We will work with two separate datasets, LakeHuron and Loblolly. The dataset LakeHuron measures Lake Huron’s water level from 1875 to 1972. Loblolly measures the growth and age of different loblolly seed varieties. “Loblollies” are loblolly pines, a fast-growing species important to the commercial timber industry.

Let’s look at LakeHuron first:

data(LakeHuron) LakeHuron

Does LakeHuron look like any of the data types we have already seen? Why or why not? LakeHuron is actually a time series with data type ts; try the following query:

is.ts(LakeHuron)

We can confirm this by looking at its class attribute:

attributes(LakeHuron)

Note that the attribute tsp tells us when the series starts, when it ends, and its increment; the class attribute identifies the data type. Both of these attributes are used by the plot command to create a time series plot with the proper time scale. Note that the command itself is quite simple, but uses built-in rules for plotting a ts object:

plot(LakeHuron)

Let’s try plotting every 5 years’ data. Notice how easily multiple commands can be nested in R.

plot(LakeHuron[seq(1,100,by=5)])

Notice anything unusual in the time series? Lake Huron’s outlet, the St. Clair River, has been extensively dredged over the years, creating a long-term decrease in lake level that apparently leveled off decades ago. Concerns over a continuing decrease in the levels of Lakes Michigan, Superior and Huron continue to this day.

Next we will work with the Loblolly data set.

data(Loblolly) Loblolly

What kind of data set is this? Is it a matrix or a data frame?

is.matrix(Loblolly) is.data.frame(Loblolly)

Since it is not a matrix, you might anticipate that commands commonly used with matrices would not work. Try these:

dim(Loblolly) Loblolly[1:5,]

Did they work? Clearly, some matrix commands can be applied to data frames.

Next we confirm that Loblolly$Seed is a factor; here we first type the variable name by itself; does the way in which R prints the variable provide clues to the data type?

Loblolly$Seed is.factor(Loblolly$Seed)

Type

names(Loblolly)

These names are not particularly descriptive; we can change them (not in the datasets li- brary, but in our local workspace) if we’d like. Are the resulting names more satisfactory?

names(Loblolly)=c("Height (Ft)","Age (Yrs)","Seed Variety") names(Loblolly) Loblolly