Read the data into R
tbl_data_beef <- readr::read_csv(file = s_data_url)
Rows: 16 Columns: 5
── Column specification ────────────────────────────────────────────────────────────────────────────────────────────────────────────
Delimiter: ","
dbl (5): Animal, Sire, Dam, Herd, Weaning Weight
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
tbl_data_beef
Animal model
\[y = X\beta + Zu + e\] ### Observations
vec_y <- tbl_data_beef$`Weaning Weight`
vec_y
[1] 2.61 2.31 2.44 2.41 2.51 2.55 2.14 2.61 2.34 1.99 3.10 2.81 2.14 2.41 2.54 3.16
mat_X <- matrix(data = c(1, 0,
1, 0,
1, 0,
1, 0,
0, 1,
0, 1,
0, 1,
0, 1,
1, 0,
1, 0,
1, 0,
1, 0,
0, 1,
0, 1,
0, 1,
0, 1), ncol = 2, byrow = TRUE)
mat_X
[,1] [,2]
[1,] 1 0
[2,] 1 0
[3,] 1 0
[4,] 1 0
[5,] 0 1
[6,] 0 1
[7,] 0 1
[8,] 0 1
[9,] 1 0
[10,] 1 0
[11,] 1 0
[12,] 1 0
[13,] 0 1
[14,] 0 1
[15,] 0 1
[16,] 0 1
tbl_data_beef$Herd
[1] 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2
mat_Z <- matrix(data = c(), ncol=27, byrow = TRUE)
Error in matrix(data = c(), ncol = 27, byrow = TRUE) :
'data' must be of a vector type, was 'NULL'