We are interested in predicting bulb intensity as a function of time. We will fit a general model \(f_2(t) = a_0 + a_1t + a_2 t^2\) where \(t \geq 0\) to the data provided. This means will will assume that bulb intensity can be modeled by the general function \(f_2\) for some choice of parameter values \(a_0\), \(a_1\), and \(a_2\).We use the seed 2021 which gives us 44 measurements for light bulb 135. We will visually fit \(f_2\) to this data by selecting parameter values \(a_0\), \(a_1\), and \(a_2\) so that \(f_2\) looks like the data. There is variability in the measurements of light bulb intensity so the fitted \(f_2\) curve will not go through each the individual points but we would like to find a curve that looks like the data. We will look for a curve that stays within the cloud of measurements.

We selected the parameter values \(a_0 = 100\), \(a_1 = 0.0004\), and \(a_2 = -0.000000039\). Thus the fitted function is \(f_2(t) = 100 + 0.0004t - 0.000000039t^2\) where \(t \geq 0\).

The intensity of the bulb as a percent of its original brightness is recorded at each time point. This means the bulb intensity measured at each time point has been normalized, multiplied by \(\frac{100}{\text{initial bulb intensity}}\). Thus the percent intensity calculated in this way at \(t=0\) will be 100, or \(f_2(0) = 100\). The value \(a_0 = 100\) is selected to meet this condition. Selecting \(a_0\) in this way guarantees that the fitted function will match the way the data has been normalized.

The values for \(a_1\) and \(a_2\) were then selected so the curve is in the cloud of data points for light bulb 135. This visually fitted function \(f_2\) and the data are shown in the figure below.

    library(data4led)
    bulb <- led_bulb(1,seed = 2021)
    
    t <- bulb$hours
    y1 <- bulb$percent_intensity
    
    f <- function(x,a0=0,a1=0,a2=1){
      a0 + a1*x + a2*x^2
    }
    
    a0=100
    a1=0.0004
    a2=-3.9e-8
    
    x <- seq(0,100000,5)
    y2 <- f(x,a0,a1,a2)
    
    par(mfrow=c(1,2),mar=c(2.5,2.5,1,0.25))
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16)
    lines(x,y2,col=2)
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16, xlim = c(0,80000),ylim = c(-10,120))
    lines(x,y2,col=2)

On the right we have a zoomed in view of the fitted function and data. We see the visually fitted function is within the cloud of data points. On the left we have a zoomed in view of the fitted function and the data. Using the fitted function we can make predictions about the bulb intensity that depend on the data and our assumption that bulb intensity can be modeled by the general function \(f_2(t; a_0, a1, a2) = a0 + a1t + a2t^2\) where \(t \geq 0\) for some choice of parameter values \(a_0\), \(a_1\), and \(a_2\).

Below we show some examples of poor visual fits for comparison.

For example 1 we selected parameter values \(a_0 = 100\), \(a_1 = 0.0001\), and \(a_2 = -0.00000003\).

    a0=100
    a1=0.0001
    a2=-3e-8
    
    x <- seq(0,100000,5)
    y2 <- f(x,a0,a1,a2)
    
    par(mfrow=c(1,2),mar=c(2.5,2.5,1,0.25))
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16)
    lines(x,y2,col=2)
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16, xlim = c(0,80000),ylim = c(-10,120))
    lines(x,y2,col=2)

Example 1 is a poor fit because \(f_{2.1}(t) = 100 + 0.0001t - 0.00000003t^2\) where \(t \geq 0\) is mostly below the cloud of data.

For example 2 we selected parameter values \(a_0 = 100\), \(a_1 = 0.001\), and \(a_2 = -0.0000000152\).

    a0=100
    a1=0.001
    a2=-1.52e-8
    
    x <- seq(0,100000,5)
    y2 <- f(x,a0,a1,a2)
    
    par(mfrow=c(1,2),mar=c(2.5,2.5,1,0.25))
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16)
    lines(x,y2,col=2)
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16, xlim = c(0,80000),ylim = c(-10,120))
    lines(x,y2,col=2)

Example 2 is a poor fit because \(f_{2.2}(t) = 100 + 0.001t - 0.0000000152t^2\) where \(t \geq 0\) is mostly above the cloud of data.

For example 3 we selected parameter values \(a_0 = 100\), \(a_1 = 0.0027\), and \(a_2 = -0.0000008\).

    a0=100
    a1=0.0027
    a2=-8e-7
    
    x <- seq(0,100000,5)
    y2 <- f(x,a0,a1,a2)
    
    par(mfrow=c(1,2),mar=c(2.5,2.5,1,0.25))
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16)
    lines(x,y2,col=2)
    plot(t,y1,xlab="Hour", ylab="Intensity(%) ", pch=16, xlim = c(0,80000),ylim = c(-10,120))
    lines(x,y2,col=2)

Example 3 is a poor fit because \(f_{2.3}(t) = 100 + 0.0027t - 0.0000008t^2\) where \(t \geq 0\) passes through the cloud of data but does not stay within the cloud of data. For this choice of parameters \(f\) increases and then decreases too quickly.

Now that we have a fitted model, \(f_2(t) = 100 + 0.0004t - 0.000000039t^2\) where \(t \geq 0\), we can use this model to make predictions and answer questions about bulb intensity as of function of time. Of course we must remember those predictions (and answers) depend on our assumption that that bulb intensity can be modeled by the general function \(f_2(t; a_0, a1, a2) = a0 + a1t + a2t^2\) where \(t \geq 0\) for some choice of parameter values \(a_0\), \(a_1\), and \(a_2\). If this assumption is incorrect then our predictions will also be incorrect.