bhm: Bayesian Heating Model

Description Usage Arguments Details Value Examples

Description

Estimates the parameters of a building's heating model.

Usage

1
bhm(formula, data, baseLoad = NULL)

Arguments

formula

an object of class "formula": a description of which variable holds the energy readouts and which variable holds the daily temperatures.

data

a data frame in which the energy and daily temperatures are to be found.

baseLoad

a optional constant base load, e.g. for domestic hot water preparation.

Details

bhm assumes that the heating energy for a building has been measured over several time periods (not necessarily of equal length). The data data frame should have one row per measurement period. The energy vector (whose name is given on the left-hand side of the formula) will have the total energy measured during each period. The daily temperature vector (whose name is given on the right-hand side of the formula) will have either a vector of average daily temperatures (when each measurement period is just one day) or a list of vectors (when each measurement period can be an arbitrary number of days).

Value

bhm returns an object of class "bhm". The generic accessor functions coefficients, vcov and residuals extract the usual information from the fitted model, while logposterior will return a function that evaluates the log-posterior as a function of the parameters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
set.seed(1111)

# Simple, but unrealistic parameters
K <- 1
tb <- 1
DHW <- 1
sigma <- 1e-2
temps <- tb + c(-2, -1, 0, 1)

# With daily measurements
E <- K * pmax(tb - temps, 0) + DHW + rnorm(length(temps), 0, sigma)
fourDayData <- data.frame(E = E, T = temps)
fourDayData
## Not run: 
fit <- bhm(E ~ T, fourDayData)
coef(fit)
resid(fit)

## End(Not run)

# With two-day measurements
fourTimesTwoDayData <- with(fourDayData,
                            data.frame(E = 2 * E,
                            T = I(lapply(T, function(x) c(x, x)))))
fit2 <- bhm(E ~ T, fourTimesTwoDayData)
coef(fit2)
resid(fit2)

Example output

         E  T
1 2.999134 -1
2 2.013225  0
3 1.006397  1
4 1.011748  2
          K          tb         DHW       sigma 
0.995861220 1.000000001 1.010737250 0.003872119 
[1] -0.003325492  0.006626773 -0.004340231  0.001010615
          K          tb         DHW       sigma 
0.995952813 1.000000000 1.010799038 0.005573358 
[1] -0.007140928  0.012946788 -0.008804035  0.001897656

homeR documentation built on May 2, 2019, 9:43 a.m.

Related to bhm in homeR...