[R] Simulate type I error
Jeff Newmiller
jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Wed Jan 26 20:49:22 CET 2022
You might get a response here, but the R-sig-mixed-models mailing list is a more appropriate place for this. See the Posting Guide mentioned in the footer.
Also, post using plain text... formatted email may not communicate what you expected it to communicate.
On January 26, 2022 11:12:36 AM PST, Chao Liu <psychaoliu using gmail.com> wrote:
>Dear R-help community,
>
>I would like to simulate type I error for a random-effects model I
>generated.
>
>The statistic of interest is standard deviations of the random intercept
>and random slope. Specifically, for random intercept, H_{0}: lambda_{0} =2
>and H_{1}: lambda_{0} not equal to 2; for random slope, H_{0}: lambda_{1}
>=1 and H_{1}: lambda_{1} not equal to 1. I assume the test would be
>likelihood ratio test but please correct me if I am wrong. How do I assess
>type I error for the random-effects model I specified below:
>
>set.seed(323)
>#The following code is to specify the structure and parameters of the
>random-effects model
>dtfunc = function(nsub){
> time = 0:9
> rt = c()
> time.all = rep(time, nsub)
> subid.all = as.factor(rep(1:nsub, each = length(time)))
>
> # Step 1: Specify the lambdas.
> G = matrix(c(2^2, 0, 0, 1^2), nrow = 2)
> int.mean = 251
> slope.mean = 10
> sub.ints.slopes = mvrnorm(nsub, c(int.mean, slope.mean), G)
> sub.ints = sub.ints.slopes[,1]
> time.slopes = sub.ints.slopes[,2]
>
> # Step 2: Use the intercepts and slopes to generate RT data
> sigma = 30
> for (i in 1:nsub){
> rt.vec = sub.ints[i] + time.slopes[i]*time + rnorm(length(time), sd =
>sigma)
> rt = c(rt, rt.vec)
> }
>
> dat = data.frame(rt, time.all, subid.all)
> return(dat)
>}
>
>#Here I run one random-effects model
>set.seed(10)
>dat = dtfunc(16)
>lmer(rt~time.all + (1+time.all |subid.all), dat)
>
>Assuming the test for significance is likelihood ratio test and so in the
>end, I want to see if I run the test 1000 times, what is the probability of
>rejecting null hypothesis when it is TRUE. Also, how do I plot the behavior
>of type I error if I change the values of standard deviations?
>
>Any help is appreciated!
>
>Best,
>
>Chao
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.
--
Sent from my phone. Please excuse my brevity.
More information about the R-help
mailing list