Problem 2 ln(R)=ln(b)+aln(W) log R = log b + alog(W) Y = B +aX for log R = Y B = log b and X = log(W)

W=c(0.017,0.025,0.020,0.020,0.025,0.087,0.111,0.085,0.119,0.233,0.174,0.211,0.171,0.210,0.783,
1.110,0.999,1.290,1.320,1.350,1.740,3.020,3.040,3.340,1.690,4.090,4.280,4.290,5.480,2.750,
5.450,4.580,5.300,4.830,5.960,4.680,5.530)
R=c(0.154,0.230,0.181,0.180,0.234,0.296,0.357,0.260,0.299,0.537,0.363,0.366,0.334,0.428,1.470,
0.531,0.771,0.870,1.150,2.480,2.230,2.010,3.590,2.830,1.440,3.580,3.280,3.400,4.150,1.840,
3.520,2.960,3.880,4.660,2.400,5.100,6.940)

n = length(R)
X = cbind(rep(1,n), log(W))
Y = cbind(log(R))

beta = round(solve(t(X)%*%X)%*%(t(X)%*%Y),4)
library(pander)
## Warning: package 'pander' was built under R version 4.2.3
pander(beta)
0.2646
0.5756

so ln(R) = ln(.2646) + .5756ln(W)

Problem 3

cab = read.csv("https://raw.githubusercontent.com/pengdsci/MAT325/main/w11/cab-dataset.txt")
timeHours = cab$TimeMin/60 # x-coordinate: converted to hours
pickupCount = cab$PickupCount # y-coordinate
n = length(pickupCount)
X = cbind(rep(1,n), timeHours)
Y = cbind(pickupCount)
beta = round(solve(t(X)%*%X)%*%(t(X)%*%Y),4)
pander(beta)
  pickupCount
16.9
timeHours 1.395

y=1.395x+16.9 where x represents the duration and y represents the number of pickups

Y = matrix(c(pickupCount), ncol=1)
cabs = c(timeHours)
X = as.matrix(cbind(intercept = rep(1, length(Y)), time = cabs, time.sq = cabs**2, time.cu = cabs**3))
beta = solve(t(X)%*%X)%*%(t(X)%*%Y)
pander(round(beta,4))
intercept 41.34
time -9.159
time.sq 1.016
time.cu -0.0267

y= 41.34 + -9.159x+1.016x2-.0267x3

plot(timeHours, pickupCount)

curve(1.395*x+16.9)

curve(-.0267*x**3+1.016*x**2-9.159*x+41.34)

cab = read.csv("https://raw.githubusercontent.com/pengdsci/MAT325/main/w11/cab-dataset.txt")
timeHours = cab$TimeMin/60 # x-coordinate: converted to hours
pickupCount = cab$PickupCount # y-coordinate

par(mfrow = c(1,2)) # setting up the layout of the graphical page
plot(timeHours, pickupCount, pch = 19, col = "blue", main = "")
curve(-.0267*x**3+1.016*x**2-9.159*x+41.34, add = TRUE)
curve(1.395*x+16.9, add = TRUE)

The cubic approximation is a better representation as it follows the curve of the data. The linear approximation does not account for the data curving but it does go up in a positive upwards trend in accordance with the data.