# Challenge: Coefficients, Confidence Intervals, and X-matrix in R

Use what you've learned so far to complete the following challenge.

## We'll cover the following

## The Janka hardness data

The Janka data from the Australian forestry industry records the density and hardness of 36 samples of wood, presumably from 36 different tree species. This data frame contains the following columns:

`dens`

: This column provides the density measurements of the timber.`hardness`

: This column provides the Janka hardness (structural property) values of the timber.

## Problem statement

Write a piece of code in R that reads the Janka data frame from the `SemiPar`

package. Then, do the following operations:

- Compute the
*estimates of the coefficients*. - Find out the
*confidence intervals*. - Compute the $X-matrix$ and display it for the last six rows of the data frame.

## Output

```
# lm(formula = hardness ~ dens, data = janka)
# coef.est coef.se
# (Intercept) -1160.50 108.58
# dens 57.51 2.28
---
# n = 36, k = 2
# residual sd = 183.06, R-Squared = 0.95
# 2.5 % 97.5 %
# (Intercept) -1381.16001 -939.83940
# dens 52.87614 62.13721
# (Intercept) dens
# 31 1 59.8
# 32 1 66.0
# 33 1 67.4
# 34 1 68.8
# 35 1 69.1
# 36 1 69.1
```

## Coding exercise

This problem has been designed for you to practice freely, so try to solve it on your own first. Take some time and think about the different concepts that we’ve explored in this course so far.

If you’re feeling stuck, you can always check out the solution in the next lesson.

Good luck!

Get hands-on with 1400+ tech skills courses.