update.blm: Update a blm distribution

Description Usage Arguments Details Value Examples

Description

Updates a blm object, using new data, parameters or a new model formula.

Usage

1
2
3
## S3 method for class 'blm'
update(object, formula = object$formula, beta = object$beta,
  prior = object, data = object$frame, ...)

Arguments

object

a blm object.

formula

a formula for the updated object.

beta

precision estimate for the updated object.

prior

prior distribution of the updated object.

data

data of the updated object.

...

other arguments. These are passed to blm.

Details

Updates a blm object, using features of the input object, except, if provided otherwise. The prior for the updated object is typically the posterior distribution of the input object, but can be specified specifically (as for all other parameters). Importantly, new data will only be used when specified as named argument.
The function can also be used to update the model formula, as described for update.

Value

A object of class blm.

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
  w0 <- 0.3 ; w1 <- 1.1 ; b <- 1.3 
  x <- rnorm(50) 
  y <- rnorm(50, w1 * x + w0, 1/b) 
  mod <- blm(y~x, beta=b, data=data.frame(x=x, y=y)) 
  mod
  
  #use of a prior, typically from an existing model 
  x2 <- rnorm(50) 
  y2 <- rnorm(50, w1 * x2 + w0, 1/b)
  
  #using posterior of mod as prior 
  new_mod <- update(mod, data=data.frame(x=x2, y=y2)) 
  new_mod
  
  #using same prior for mod and new model 
  new_mod2 <- update(mod, prior=mod$prior, data=data.frame(x=x2, y=y2)) 
  new_mod2
  
  #update model formula 
  new_mod2 <- update(mod, y~x+0, prior=mod$prior, 
                     data=data.frame(x=x2, y=y2)) 
  new_mod2
  
  #also works with standard R formula update semantics 
  new_mod2 <- update(mod, ~.+0, prior=mod$prior, data=data.frame(x=x2, y=y2)) 
  new_mod2
   

manschmi/blmr documentation built on May 21, 2019, 11:25 a.m.