Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dissolution_coefs docs to show nodematch(X, diff = TRUE) example #271

Closed
smjenness opened this issue Aug 10, 2018 · 1 comment
Closed
Assignees

Comments

@smjenness
Copy link
Collaborator

For example:

nw <- network.initialize(1000, directed = FALSE)
age.grp <- sample(1:5, 1000, TRUE)
nw %v% "age.grp" <- age.grp

# durations = non-matched, age.grp1 & age.grp1, age.grp2 & age.grp2, ...
durs <- c(60, 30, 80, 100, 125, 160)
fit <- netest(nw, ~edges + nodematch("age.grp", diff = TRUE), 
              target.stats = c(450, 100, 125, 40, 80, 100),
              coef.diss = dissolution_coefs(~offset(edges) + offset(nodematch("age.grp", diff = TRUE)), duration = durs)) 
dx <- netdx(fit, nsims = 8, ncores = 8, nsteps = 300)
print(dx)

dx <- netdx(fit, nsims = 1, nsteps = 5000, keep.tedgelist = TRUE)
names(dx)

te <- dx$tedgelist[[1]]

te <- te[which(te$onset.censored == FALSE & te$terminus.censored == FALSE), ]
te <- te[, c("head", "tail", "duration")]

head(te, 25)
te$ag.head <- age.grp[te$head]
te$ag.tail <- age.grp[te$tail]

summary(te$duration[te$ag.head != te$ag.tail])
summary(te$duration[te$ag.head == 1 & te$ag.tail == 1])
summary(te$duration[te$ag.head == 2 & te$ag.tail == 2])
summary(te$duration[te$ag.head == 3 & te$ag.tail == 3])
summary(te$duration[te$ag.head == 4 & te$ag.tail == 4])
summary(te$duration[te$ag.head == 5 & te$ag.tail == 5])
@smjenness smjenness added this to the EpiModel v1.6.6 milestone Oct 19, 2018
@smjenness smjenness self-assigned this Oct 23, 2018
@smjenness
Copy link
Collaborator Author

Will depend on Fixing #258 first, then update dissolution_coefs docs as above with working netdx example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant