one_tm: Frequentist inference for the one thermal mass model (1TM)

Description Usage Arguments Details Value References Examples

Description

Brief description

Usage

1
2
3
4
one_tm(data, flux = c("in", "out", "both"), air = TRUE, init = NULL,
  tau = 1/12, hetero = TRUE, correlation = FALSE, sum_R = FALSE,
  ep = 1e-06, nls_control = NULL, gnls_control = NULL,
  use_gnls = FALSE, use_logs = FALSE, sim_data = NULL, ...)

Arguments

data

A dataset in the format of either cwall_east or cwall_north.

flux

A character scalar. Should we use: only internal heat fluxes (flux = "in"); only external heat fluxes (flux = "in"); both internal and external heat fluxes (flux = "both").

air

A logical scalar. Should we use air (TRUE) or surface (FALSE) temperatures?

init

A numeric vector of length 3. Optional initial estimates of the parameters R1, R2 and C1 of the 1TM. These will only be used if flux = "both", because when flux = "in" and flux = "out" non-iterative estimates of these parameters can be calculated.

tau

A numeric scalar. Time interval between successive measurements, in hours.

hetero

A logical scalar. Only relevant when flux = "both". Should we allow the error variance to be different for the Qin and Qout parts of the model (hetero = TRUE) or assume a constant error variance (hetero = FALSE)? The default is hetero = TRUE because Qout data tend to be much more variable than the Qin data.

correlation

Not working yet! A logical scalar. Should we estimate the correlation between the contemporaneous errors for Qin and Qout (correlation = TRUE) or assume that this correlation is equal to zero (correlation = FALSE)? If hetero = FALSE then correlation = FALSE is used by default.

sum_R

A logical scalar. Should we output results for the parameters (R1, R2, C1) [sum_R = FALSE] or for (R1 + R2, ratio of the Rs, C1) [sum_R = TRUE]. The ratio of the Rs is R1/R2 if the estimate of R1 is greater than the estimate of R2 and R2/R1 otherwise.

ep

A numeric scalar. Lower bound imposed on the (positive) parameters R1, R2 and C1. Passed to the lower argument of nls.

nls_control

An optional list of control settings to be passed to nls.

gnls_control

An optional list of control settings to be passed to gnls.

use_gnls

A logical scalar. In the (flux = "both", hetero = FALSE) case should we use gnls to fit the model (use_gnls == TRUE) or nls (use_gnls == FALSE)? This is provided as a means to check that these two functions give equivalent results.

use_logs

A logical scalar. Should the model fitting use the parameterisation (log R1, log R2, log C1) [use_logs = TRUE] or (R1, R2, C1) [use_logs = FALSE]. Not yet implemented fully or properly!

sim_data

Not implemented yet.

...

Further arguments to be pased to nls or gnls.

Details

The default value of nlsTol (100) is rather larger than the default in gnlsControl because experimentation with the example data in walls suggests that smaller values tend to trigger an error in gnls, that is, "step halving factor reduced below minimum in NLS step". Increasing nlsTol substantially seems to avoid early termination of the fitting algorithm and produce sensible estimates. As a sanity check the ...

Value

An object of class "nls" returned from nls.

References

Gori, V. (2017) A novel method for the estimation of thermophysical properties of walls from short and seasonally independent in-situ surveys. Doctoral thesis. UCL (University College London). http://discovery.ucl.ac.uk/1568418/

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
### cwall_east --------

## Qin only
in_air <- one_tm(data = cwall_east)
in_air

# Output from some methods available for nls objects
summary(in_air)
coef(in_air)
sigma(in_air)
vcov(in_air)
cov2cor(vcov(in_air))
confint(in_air)
logLik(in_air)
plot(in_air)
plot(in_air, form = resid(., type = "p") ~ x1)
qqnorm(in_air) # `wrong' way round!
qqnorm(residuals(in_air, type = "pearson"))

in_surface <- one_tm(data = cwall_east, air = FALSE)
in_surface

## Qout only
out_air <- one_tm(data = cwall_east, flux = "out")
out_air
out_surface <- one_tm(data = cwall_east, flux = "out", air = FALSE)
out_surface

## Both Qin and Qout

# Common error variance for Qin and Qout
both_air_homo <- one_tm(data = cwall_east, flux = "both", hetero = FALSE)
both_air_homo
plot(both_air_homo, form = resid(., type = "p") ~ fitted(.) | in_out)

# Different error variances for Qin and Qout
both_air_hetero <- one_tm(data = cwall_east, flux = "both")
both_air_hetero
plot(both_air_hetero, form = resid(., type = "p") ~ fitted(.) | in_out)
plot(both_air_hetero, form = resid(., type = "p") ~ x1 | in_out)
plot(both_air_hetero, form = in_out ~ resid(., type = "p"))
plot(both_air_hetero, Qsp ~ fitted(.) | in_out, abline = c(0, 1))

# Plot contemporaneous residuals against each other
resids <- residuals(both_air_hetero)
res1 <- resids[both_air_hetero$data$in_out == "inside"]
res2 <- resids[both_air_hetero$data$in_out == "outside"]
plot(res1, res2)

### cwall_north --------

## Qin only
in_surface <- one_tm(data = cwall_north)
in_surface

## Qout only
out_surface <- one_tm(data = cwall_north, flux = "out")
out_surface

both_air_hetero <- one_tm(data = cwall_north, flux = "both")
# Plot contemporaneous residuals against each other
resids <- residuals(both_air_hetero)
res1 <- resids[both_air_hetero$data$in_out == "inside"]
res2 <- resids[both_air_hetero$data$in_out == "outside"]
plot(res1, res2)
cor(res1, res2)

# Inference for R1 + R2 [sum_R] and R1 / (R1 + R2) [frac_R]
both_air_hetero <- one_tm(data = cwall_north, flux = "both", sum_R = TRUE)

paulnorthrop/walls documentation built on May 15, 2019, 10:02 p.m.