Last chance! 50% off unlimited learning
Sale ends in
twinlm(formula, data, id, zyg, DZ, OS, weight = NULL,
type = c("ace"), twinnum = "twinnum", binary = FALSE,
keep = weight, estimator = "gaussian",
constrain = TRUE, control = list(), ...)
data.frame
with one observation pr
row. In addition a column with the zygosity (DZ or MZ
given as a factor) of each individual much be specified
as well as a twin id variable giving a unique pair of
numbers/factors to each twin pair.data
it will automatically be created.TRUE
a liability model is fitted.
Note that if the right-hand-side of the formula is a
factor, character vector, og logical variable, then the
liability model is automatically chosen (wrapper of the
bptwin
function).data
that are
not specified in formula
, to be added to
data.frame of the SEMtwinlm
.bptwin
, twinsim
## Simulate data
set.seed(1)
d <- twinsim(1000,b1=c(1,-1),b2=c(),acde=c(1,1,0,1))
## E(y|z1,z2) = z1 - z2. var(A) = var(C) = var(E) = 1
## E.g to fit the data to an ACE-model without any confounders we simply write
ace <- twinlm(y1 ~ 1, data=d, DZ="DZ", zyg="zyg", id="id")
ace
## An AE-model could be fitted as
ae <- twinlm(y1 ~ 1, data=d, DZ="DZ", zyg="zyg", id="id", type="ae")
## LRT:
compare(ae,ace)
## AIC
AIC(ae)-AIC(ace)
## To adjust for the covariates we simply alter the formula statement
ace2 <- twinlm(y1 ~ x11+x12, data=d, DZ="DZ", zyg="zyg", id="id", type="ace")
## Summary/GOF
summary(ace2)
## An interaction could be analyzed as:
ace3 <- twinlm(y1 ~ x11+x12 + x11:I(x12<0), data=d, DZ="DZ", zyg="zyg", id="id", type="ace")
## Categorical variables are also supported
d2 <- transform(d,x12cat=cut(x12,3,labels=c("Low","Med","High")))
ace4 <- twinlm(y1 ~ x11+x12cat, data=d2, DZ="DZ", zyg="zyg", id="id", type="ace")
## plot the model structure
plot(ace4)
Run the code above in your browser using DataLab