Write the model equation of clathrate formation regressed on both surfactant and time.
--> Here Y=responserFit the model in R without using the LM function. What is the dimensionality of Y? What is the dimensionality of X?
library(MASS)
data<-read.csv("C:\\Users\\18067\\Documents\\Fareeha Imam\\TTU R11767331\\Spring 2023\\SDA\\data-table-B8(2).csv")
X1<-data$x1
X2<-data$x2
ones<-rep(1,36)
X<-cbind(ones,X1,X2)
X
## ones X1 X2
## [1,] 1 0.00 10
## [2,] 1 0.00 50
## [3,] 1 0.00 85
## [4,] 1 0.00 110
## [5,] 1 0.00 140
## [6,] 1 0.00 170
## [7,] 1 0.00 200
## [8,] 1 0.00 230
## [9,] 1 0.00 260
## [10,] 1 0.00 290
## [11,] 1 0.00 10
## [12,] 1 0.00 30
## [13,] 1 0.00 62
## [14,] 1 0.00 90
## [15,] 1 0.00 150
## [16,] 1 0.00 210
## [17,] 1 0.00 270
## [18,] 1 0.02 10
## [19,] 1 0.02 30
## [20,] 1 0.02 60
## [21,] 1 0.02 90
## [22,] 1 0.02 120
## [23,] 1 0.02 210
## [24,] 1 0.02 30
## [25,] 1 0.02 60
## [26,] 1 0.02 120
## [27,] 1 0.02 150
## [28,] 1 0.05 20
## [29,] 1 0.05 40
## [30,] 1 0.05 130
## [31,] 1 0.05 190
## [32,] 1 0.05 250
## [33,] 1 0.05 60
## [34,] 1 0.05 90
## [35,] 1 0.05 120
## [36,] 1 0.05 150
y<-data$y
d<- t(y)
Y<-t(d)
Beta<-ginv(t(X)%*%X)%*%t(X)%*%y
t(X)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14]
## ones 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## X1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## X2 10 50 85 110 140 170 200 230 260 290 10 30 62 90
## [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26]
## ones 1 1 1 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## X1 0 0 0 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02 0.02
## X2 150 210 270 10.00 30.00 60.00 90.00 120.00 210.00 30.00 60.00 120.00
## [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
## ones 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
## X1 0.02 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05 0.05
## X2 150.00 20.00 40.00 130.00 190.00 250.00 60.00 90.00 120.00 150.00
dim(Y)
## [1] 36 1
dim(X)
## [1] 36 3
--> Here we can see, What are the least squares estimates of the regression parameters in the model?
Beta<-ginv(t(X)%*%X)%*%t(X)%*%y
Beta
## [,1]
## [1,] 11.0869804
## [2,] 350.1192457
## [3,] 0.1089344
--> Here we have 3x3 Matrix and the Least Square Estimates are given below