https://github.com/cran/aster
Tip revision: d150687fca407ce91f0fbdb5abd5b7fc6a66ad63 authored by Charles J. Geyer on 06 September 2005, 00:00:00 UTC
version 0.3-1
version 0.3-1
Tip revision: d150687
formula.Rout.save
R : Copyright 2004, The R Foundation for Statistical Computing
Version 2.0.1 (2004-11-15), ISBN 3-900051-07-0
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.
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 a HTML browser interface to help.
Type 'q()' to quit R.
>
> library(aster)
>
> set.seed(42)
>
> nind <- 25
>
> vars <- c("l2", "l3", "f2", "f3", "h2", "h3")
> pred <- c(0, 1, 1, 2, 3, 4)
> fam <- c(1, 1, 1, 1, 3, 3)
> length(pred) == length(fam)
[1] TRUE
> nnode <- length(pred)
>
> famnam <- families()
> print(famnam[fam])
[1] "bernoulli" "bernoulli" "bernoulli" "bernoulli"
[5] "non.zero.poisson" "non.zero.poisson"
>
> theta <- matrix(0, nind, nnode)
> root <- matrix(1, nind, nnode)
> x <- raster(theta, pred, fam, root)
> dimnames(x) <- list(NULL, vars)
>
> data <- as.data.frame(x)
> site <- factor(sample(LETTERS[1:4], nind, replace = TRUE))
> foo <- rnorm(nind)
> data <- data.frame(x, site = site, foo = foo, root = 1)
>
> redata <- reshape(data, varying = list(vars),
+ direction = "long", timevar = "varb", times = as.factor(vars),
+ v.names = "resp")
>
> out <- aster(resp ~ foo + site, pred, fam, varb, id, root, data = redata)
> summary(out, show.graph = TRUE)
Call:
aster.formula(formula = resp ~ foo + site, pred = pred, fam = fam,
varvar = varb, idvar = id, root = root, data = redata)
Graphical Model:
variable predecessor family
l2 root bernoulli
l3 l2 bernoulli
f2 l2 bernoulli
f3 l3 bernoulli
h2 f2 non.zero.poisson
h3 f3 non.zero.poisson
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.16214 0.21876 -0.741 0.459
foo 0.09494 0.11920 0.796 0.426
siteB 0.17028 0.28481 0.598 0.550
siteC -0.31451 0.26409 -1.191 0.234
siteD -0.44272 0.38470 -1.151 0.250
>
> out <- aster(resp ~ foo + site + varb, pred, fam, varb, id, root,
+ data = redata)
> summary(out)
Call:
aster.formula(formula = resp ~ foo + site + varb, pred = pred,
fam = fam, varvar = varb, idvar = id, root = root, data = redata)
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.10940 0.99528 1.115 0.265
foo 0.07857 0.10960 0.717 0.473
siteB 0.14573 0.26619 0.547 0.584
siteC -0.25967 0.24569 -1.057 0.291
siteD -0.35936 0.35182 -1.021 0.307
varbf3 -0.96858 1.43012 -0.677 0.498
varbh2 -1.95067 1.60196 -1.218 0.223
varbh3 -0.99839 1.09216 -0.914 0.361
varbl2 -1.87307 1.24891 -1.500 0.134
varbl3 -1.80743 1.19680 -1.510 0.131
>
>