check the following code:

# settings
n <- 100 # number of sample units
p <- 10 # number of repeated measurements
N <- n * p # total number of measurements
t.max <- 3

# parameter values
betas <- c(0.5, 0.4, -0.5, -0.8) # fixed effects (check also 'X' below)
sigma.b <- 2 # random effects variance

# id, treatment & time
id <- rep(1:n, each = p)
treat <- rep(0:1, each = n/2)
time <- seq(0, t.max, length.out = p)

# simulate random effects
b <- rnorm(n, sd = sigma.b)

# simulate longitudinal process conditionally on random effects
time.rep <- rep(time, n)
treat.rep <- rep(treat, each = p)
X <- cbind(1, treat.rep,
    time.rep, treat.rep * time.rep) # fixed effects design matrix
muY <- plogis(c(X %*% betas) + b[id]) # conditional probabilities
y <- rbinom(N, 1, muY) # simulate binary responses

# put the simulated data in a data.frame
simulData <- data.frame(
    id = id,
    y = y,
    treat = treat.rep,
    time = time.rep
)

# fit the model
library(glmmML)
fit <- glmmML(y ~ treat * time, data = simulData, cluster = id)
summary(fit)


I hope it helps.

Best,
Dimitris


Odette Gaston wrote:
Hi everybody,

I am currently working on glmmML() and wish to generate random number to do
some tests, however, glmm was hypothesized the mixed distributions with
normal  and binomial in terms of having a random effect. How would you be
able to generate random number in this case? Is there a function in R to
generate random number of  mixed distribution (normal+binomial)? Any
comments would be appreciated.

Many thanks,
Odette

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus Medical Center

Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to