energy_build: Energy Matrix Interpolating Function

Description Usage Arguments Author(s) See Also Examples

View source: R/energy_build.R

Description

Creates a matrix interpolating energy consumption from measurements at specific moments in time.

Usage

1
energy_build(energy, time, interpolation = "Brownian")

Arguments

energy

(matrix) Matrix with each row representing an individual and each column a moment in time in which energy was measured. Energy is assumed to be measured at time 0 initially.

time

(vector) Vector of times at which the measurements (columns of energy) were made. Note that first element of time most always be 0.

Optional

interpolation

(string) Way to interpolate the values between measurements. Currently supporting "Linear", "Exponential", "Stepwise_R", "Stepwise_L", "Logarithmic" and "Brownian".

Author(s)

Dalia Camacho-García-Formentí daliaf172@gmail.com

Rodrigo Zepeda-Tello rzepeda17@gmail.com

See Also

adult_weight for weight change in adults and child_weight for children weight change.

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
#EXAMPLE 1: INDIVIDUAL MODELLING
#--------------------------------------------------------

#Get energy consumption
myconsumption <- energy_build(c(0, 200, -500), c(0, 365*2, 365*4), "Linear")
plot(1:(365*4), myconsumption, type = "l")

#Change interpolation to exponential
myexponential <- energy_build(c(0, 200, -500), c(0, 365*2, 365*4), "Exponential")
lines(1:(365*4), myexponential, type = "l", col = "red")

mystepwise    <- energy_build(c(0, 200, -500), c(0, 365*2, 365*4), "Stepwise_R")
lines(1:(365*4), mystepwise, type = "l", col = "blue")

mystepwise2    <- energy_build(c(0, 200, -500), c(0, 365*2, 365*4), "Stepwise_L")
lines(1:(365*4), mystepwise2, type = "l", col = "green")

mylogarithmic <- energy_build(c(0, 200, -500), c(0, 365*2, 365*4), "Logarithmic")
lines(1:(365*4), mylogarithmic, type = "l", col = "purple")

mybrownian    <- energy_build(c(0, 200, -500), c(0, 365*2, 365*4), "Brownian")
lines(1:(365*4), mybrownian, type = "l", col = "forestgreen")

#EXAMPLE 2: GROUP MODELLING
#--------------------------------------------------------

#Get energy consumption
multiple <- energy_build(cbind(runif(10,1000,2000), 
                                 runif(10,1000,2000), 
                                 runif(10,1000,2000)), c(0, 142, 365),
                                 "Brownian")
matplot(1:365, t(multiple), type = "l")

bw documentation built on July 5, 2018, 5:03 p.m.