Processing math: 100%

Consider the model f6(t;a1,a2)=100+a1t+a2(1e0.0003t) where t0. The function f6 models the brightness of a lightbulb, measured as a percent of the original intensity of the lightbulb, given the number of hours the lightbulb as been on, t.

In order to fit f6 to a list of 44 measurements, (ti,yi) we need to find the first and second partial derivatives of the loglikelihood function for the residuals. Assuming the residuals (or errors) are independent and normally distributed (with mean 0 and standard deviation 1), the loglikelihood function for these errors is 6(a1,a2;t,y)=44ln(12π)+44i=1(12)(yi100a1tia2(1e0.0003ti))2.

Calculating 6a1

We compute 6a1 by treating a2 as a constant and differentiate with respect to a1 using the derivative rules.

6a1=a1(44ln(12π))+44i=1a1((12)(yi100a1tia2(1e0.0003ti))2)(sum/difference rule)=0+44i=1(12)a1((yi100a1tia2(1e0.0003ti))2)(constant and constant multiple rules)=44i=1(12)(2(yi100a1tia2(1e0.0003ti))(ti))(chain rule)=44i=1ti(yi100a1tia2(1e0.0003ti))(simplify; multiply 12, 2, and ti)

We can simplify 6a1 using the properties of sums.

6a1=44i=1ti(yi100a1tia2(1e0.0003ti))=44i=1ti(yi100)a1t2ia2ti(1e0.0003ti)(distribution inside the sum)=44i=1ti(yi100)+44i=1a1t2i+44i=1a2ti(1e0.0003ti)(break the sum into three sums)=44i=1ti(yi100)a144i=1t2ia244i=1ti(1e0.0003ti)(pull constant multiples out of the sums)

We see 6a1 is of the form a constant, subtract a constant multiple of a1, subtract a constant multiple of a2. 6a1=(44i=1ti(yi100))a1(44i=1t2i)a2(44i=1ti(1e0.0003ti))

These constants depend on our data and can be computed in R. Let A=44i=1ti(yi100)83738.9, B=44i=1t2i328767530, and C=44i=1ti(1e0.0003ti)59520.5.

library(data4led)
bulb <- led_bulb(1,seed=2021)

t <- bulb$hours
y <- bulb$percent_intensity

A <- sum((y-100)*t)
A
## [1] 83738.93
B <- sum(t^2)
B
## [1] 328767530
C <- sum((1-exp(-0.0003*t))*t)
C
## [1] 59520.54
C4.6 <- -sum((y-100)*(1-exp(-0.0003*t)))
C5.6 <- sum((1-exp(-0.0003*t))^2)

Calculating 6a2

We compute 6a2 by treating a1 as a constant and differentiate with respect to a2 using the derivative rules.

6a2=a2(44ln(12π))+44i=1a2((12)(yi100a1tia2(1e0.0003ti))2)(sum/difference rule)=0+44i=1(12)a2((yi100a1tia2(1e0.0003ti))2)(constant and constant multiple rules)=44i=1(12)(2(yi100a1tia2(1e0.0003ti))((1e0.0003ti)))(chain rule)=44i=1(1e0.0003ti)(yi100a1tia2(1e0.0003ti))(simplify; multiply 12, 2, and (1e0.0003ti))

We can simplify 6a2 using the properties of sums.

6a2=44i=1(1e0.0003ti)(yi100a1tia2(1e0.0003ti))=44i=1(1e0.0003ti)(yi100)a1ti(1e0.0003ti)a2(1e0.0003ti)2(distribution inside the sum)=44i=1(1e0.0003ti)(yi100)+44i=1a1ti(1e0.0003ti)+44i=1a2(1e0.0003ti)2(break the sum into three sums)=44i=1(1e0.0003ti)(yi100)a144i=1ti(1e0.0003ti)a244i=1(1e0.0003ti)2(pull constant multiples out of the sums)

We see 6a2 is of the form a constant, subtract a constant multiple of a1, subtract a constant multiple of a2. 6a2=(44i=1(1e0.0003ti)(yi100))a1(44i=1ti(1e0.0003ti))a2(44i=1(1e0.0003ti)2)

These constants depend on our data and can be computed in R. Let D=44i=1(1e0.0003ti)(yi100)15.691, C=44i=1ti(1e0.0003ti)59520.5, and E=44i=1(1e0.0003ti)210.998. Notice that C is a constant in 6a2 and 6a1.

D <- -sum((y-100)*(1-exp(-0.0003*t)))
D
## [1] -15.6911
C <- sum((1-exp(-0.0003*t))*t)
C
## [1] 59520.54
E <- sum((1-exp(-0.0003*t))^2)
E
## [1] 10.99773

We will use the first partials of 6 to calculate the second partials of 6. We only need to compute 26a21, 26a22 and 26a1a2 since the mix partials are equal for 6.

Calculating 26a21

We compute 26a21 by taking the derivative of 6a1 with respect to a1. 26a21=a1((44i=1ti(yi100))a1(44i=1t2i)a2(44i=1ti(1e0.0003ti)))=0(44i=1t2i)0 We see 26a21=44i=1t2i99542.

-B
## [1] -328767530

Calculating 26a22

We compute 26a22 by taking the derivative of 6a2 with respect to a2. 26a22=a2((44i=1(1e0.0003ti)(yi100))a1(44i=1ti(1e0.0003ti))a2(44i=1(1e0.0003ti)2))=0044i=1(1e0.0003ti)2 We see 26a22=44i=1(1e0.0003ti)210.998.

-E
## [1] -10.99773

Calculating 26a1a2

We compute 26a1a2 by taking the derivative of 6a2 with respect to a1. 26a1a2=a1((44i=1(1e0.0003ti)(yi100))a1(44i=1ti(1e0.0003ti))a2(44i=1(1e0.0003ti)2))=044i=1ti(1e0.0003ti)0 We see 26a22=44i=1ti(1e0.0003ti)59520.5.

-C
## [1] -59520.54