swh:1:snp:bbee81fcdc4b36c131a8db323aa6b1ea43209e9a
Tip revision: 1cc05f63437c1a519a5bdc24b3cc669980d81d48 authored by Charles J. Geyer on 13 May 2019, 18:20:03 UTC
version 1.0-3
version 1.0-3
Tip revision: 1cc05f6
mlogl-c-export.Rout.save
R Under development (unstable) (2017-03-08 r72321) -- "Unsuffered Consequences"
Copyright (C) 2017 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.
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.
>
> # copied from ../man/aster.Rd examples section
>
> library(aster)
Loading required package: trust
> data(echinacea)
> vars <- c("ld02", "ld03", "ld04", "fl02", "fl03", "fl04",
+ "hdct02", "hdct03", "hdct04")
> redata <- reshape(echinacea, varying = list(vars), direction = "long",
+ timevar = "varb", times = as.factor(vars), v.names = "resp")
> redata <- data.frame(redata, root = 1)
> pred <- c(0, 1, 2, 1, 2, 3, 4, 5, 6)
> fam <- c(1, 1, 1, 1, 1, 1, 3, 3, 3)
> hdct <- grepl("hdct", as.character(redata$varb))
> redata <- data.frame(redata, hdct = as.integer(hdct))
> level <- gsub("[0-9]", "", as.character(redata$varb))
> redata <- data.frame(redata, level = as.factor(level))
> aout <- aster(resp ~ varb + level : (nsloc + ewloc) + hdct : pop,
+ pred, fam, varb, id, root, data = redata)
>
> # redo with new function
>
> theta <- predict(aout, parm.type = "canonical", model.type = "conditional")
> phi <- predict(aout, parm.type = "canonical", model.type = "unconditional")
>
> nind <- nrow(echinacea)
> nnode <- length(pred)
>
> aster:::setfam(fam.default())
>
> val.theta <- .C(aster:::C_aster_export_exerciser,
+ nind = as.integer(nind),
+ nnode = as.integer(nnode),
+ pred = as.integer(pred),
+ fam = as.integer(fam),
+ parm = as.double(theta),
+ root = as.double(redata$root),
+ response = as.double(redata$resp),
+ is.unco = FALSE,
+ value = double(1))$value
>
> val.phi <- .C(aster:::C_aster_export_exerciser,
+ nind = as.integer(nind),
+ nnode = as.integer(nnode),
+ pred = as.integer(pred),
+ fam = as.integer(fam),
+ parm = as.double(phi),
+ root = as.double(redata$root),
+ response = as.double(redata$resp),
+ is.unco = TRUE,
+ value = double(1))$value
>
> aster:::clearfam()
>
> all.equal(val.theta, aout$deviance / 2)
[1] TRUE
> all.equal(val.phi, aout$deviance / 2)
[1] TRUE
>
>
> proc.time()
user system elapsed
1.300 0.020 1.316