
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ouch)
> 
> ouBirth <- read.csv("bergmann.csv",stringsAsFactors=TRUE)
> tree <- with(ouBirth,ouchtree(nodes,ancestors,times,labels))
> 
> ouModelFX <- hansen(ouBirth['fakeX'],tree,ouBirth['OU2c'],sqrt.alpha=1,sigma=1,fit=FALSE)
> ouModelFX@sigma <- 1
> ouModelFX@theta$fakeX <- c(-2,2)
> ouModelFX@sqrt.alpha <- sqrt(1)
> fXlo <- simulate(ouModelFX,nsim=1,seed=1066L)
> ouModelFX@sqrt.alpha <- sqrt(50)
> fXhi <- simulate(ouModelFX,nsim=1,seed=1929L)
> 
> ouModelFY <- hansen(ouBirth['fakeY'],tree,ouBirth['OU2c'],sqrt.alpha=1,sigma=1,fit=FALSE)
> ouModelFY@sigma <- 1
> ouModelFY@theta$fakeY <- c(-2,2)
> ouModelFY@sqrt.alpha <- sqrt(1)
> fYlo <- simulate(ouModelFY,nsim=1,seed=1066L)
> ouModelFY@sqrt.alpha <- sqrt(50)
> fYhi <- simulate(ouModelFY,nsim=1,seed=1929L)
> 
> ouFakeData <- data.frame(
+                          xlo=fXlo$rep.1[[1]],
+                          xhi=fXhi$rep.1[[1]],
+                          ylo=fYlo$rep.1[[1]],
+                          yhi=fYhi$rep.1[[1]]
+                          )
> 
> print(with(ouFakeData,max(abs(xlo-ylo),na.rm=TRUE)))
[1] 0
> print(with(ouFakeData,max(abs(xhi-yhi),na.rm=TRUE)))
[1] 0
> 
> ouModelFXY <- hansen(
+                      data=ouBirth[c("fakeX","fakeY")],
+                      tree=tree,
+                      regimes=ouBirth["OU2c"],
+                      sqrt.alpha=c(1,0,1),
+                      sigma=c(1,0,1),
+                      fit=FALSE
+                      )
> ouModelFXY@sigma <- c(2,-3,1)
> ouModelFXY@theta <- list(
+                          fakeX=c(-2,2),
+                          fakeY=c(-8,8)
+                          )
> ouModelFXY@sqrt.alpha <- c(1,0,2)
> coef(ouModelFXY)
$sqrt.alpha
[1] 1 0 2

$sigma
[1]  2 -3  1

$theta
$theta$fakeX
[1] -2  2

$theta$fakeY
[1] -8  8


$alpha.matrix
     [,1] [,2]
[1,]    1    0
[2,]    0    4

$sigma.sq.matrix
     [,1] [,2]
[1,]    4   -6
[2,]   -6   10

> 
> fXY <- simulate(ouModelFXY,nsim=2,seed=1929L)
> plot(do.call(cbind,fXY))
> 
