clone_model {glinvci}R Documentation

Clone a GLInv model

Description

The clone_model function is a S3 generic method for either the glinv or glinv_gauss class.

Usage

clone_model(mod, ...)

## S3 method for class 'glinv_gauss'
clone_model(mod, ...)

## S3 method for class 'glinv'
clone_model(mod, ...)

Arguments

mod

An object of either glinv or glinv_gauss class.

...

Further arguments to be passed to the S3 methods. Not used currently.

Details

Because glinv or glinv_gauss object is mutable, the assignment model2 = model1 will not make a copy your model. The correct way to copy a model is to use the clone_model function.

Value

A new model that is a clone of mod.

Examples

repar = get_restricted_ou(H=NULL, theta=c(0,0), Sig='diag', lossmiss=NULL)
mod1 = glinv(tree    = ape::rtree(10),
             x0      = c(0,0),
             X       = NULL,
             repar   = repar)
mod2 = mod1
mod3 = clone_model(mod1)
traits = matrix(rnorm(20), 2, 10)
set_tips(mod1, traits)
print(has_tipvals(mod1))  # TRUE
print(has_tipvals(mod2))  # TRUE
print(has_tipvals(mod3))  # FALSE

[Package glinvci version 1.2.4 Index]