# r code help

1. ### Efficient R coding

Consider the following data frame: dat <- data.frame(x=c(0,128.96,0,397.37,56.80,0,801.79,340.79), y=c(40,97,172,186,210,246,327,432), d=c(1,0,0,0,0,1,0,1), A=c(0,1,0,1,1,0,1,1), B=c(0,1,0,1,1,0,1,1)) For each value of the column y which satisfies...
2. ### How is to define the lme model syntax .

The following model assumes that the covariance between the random intercepts and random slopes across Subjects is Zero . lmer(Reaction ~ Days + (Days||Subject), sleepstudy) How can I write the same model by "lme" function under nlme pacakge assuming zero covariance between the random...
3. ### Specifying the variance component model "varComp" in R .

I am trying to fit a random slope model by "varComp" in R . For the following example , that is in "lmer" syntax , how can I write it in "varComp" syntax : library(lme4) library(varComp) fm1 <- lmer(Reaction ~ Days + (Days||Subject), sleepstudy) I am not understanding...
4. ### Indices with data bound between -1 and +1

Hi all, I would really appreciate some advice on how to deal with my data. I would like to compare data calculated from an index which is bounded by -1 and +1. I was surprised to see that previously published use of this index has been analysed using standard ANOVA, because I was led to...
5. ### How can I calculate Standard Errors of Variance Estimates .

I want to extract the "standard error" of variance component from the output of "lmer" . In Chapter 12 , Experiments with Random Factors , of the book Design and Analysis of Experiments, written by Douglas C. Montgomery , at the end of the chapter , Example 12-2 is done by SAS . In Example...
6. ### Specifying formula of lmer() function in R .

Am I specifying my lmer model correctly ? Say I have one independent variable (X) at individual level and one independent variable (Z) at group level. Both are continuous variable . If the model is...
7. ### How to compute the residual standard deviation from glmer() function in R?

I want to extract standard deviation of residual from glmer() function in R . So I wrote : lmer_obj = glmer(Y ~ X1 + X2 + (1|Subj), data = D, family = binomial) sigma(lmer_obj) I noticed that the last command sigma(lmer_obj) returns always "1" irrespective of data ...
8. ### Simple probability in R

Hello, newbie here. I have just started with R and am having trouble with how to enter a seemingly very simple probability question in R. The question is: There is a big court case, and 20% of the adult population believe the accused is innocent prior to jury selection. Assume that the 12...
9. ### Fitting confidence interval lines in R using the predict function

Hi everyone, I am currently attempting to fit confidence interval lines to a regression model in R, but every time I try to for example add a +2 confidence interval line, I end up with two of them! I have been over my code many times and can't find any obvious mistakes. This is the code I...