Here is some R code that finds the point and 95% interval regression estimates for the population total. We first generate a example simple population.
For a sample we will calculate the regression estimate and find its absolute error as an estimate of the population total We will also find the usual 95% confidence interval, its length and check to see if it contains the true population total.
The command
set.seed lets you set the seed of the random number
generator in R so that you can generate the same population again
and again.