Hi,

I have measured a variable called R1 now I what to create a mixed linear model describing the variable R1, with the fixed effect Group which have 2 levels, and two random effects, called fpIDX and VOIidx.

I want to calculate this model for a number of data sets therefore I tried to write a script with a for loop running over all data sets. When the loop is running I want to print the summery of the model. However, when I use the summary() function in the script there is no output, and I instead used the print() function (When I do it line by line in the console the summary() function works fine).

Then, I also what to calculate the mean and standard deviation of the estimated R1 for each group,  calculate 95% confidence the mean difference between the two groups, and calculate a post hoc t-test for the difference. Finally, I want to save the values of mean, SD of each group, the 95% conf.int. and the significance level to the t test in to a CSV file.

The for loop now looks like the following:
*** snip ***

for(i in 1:length(FileList)){



    # Read the dataset into object data
    data <- read.csv(FileList[i])

    # display the data



    str(data)

    # Calculate a mixed linear model with Group as fixed effect, VOIidx and fpIDX as random effects
    model <- lmer(R1 ~ 1 + Group + ( 1  | fpIDX ) + ( 1 | VOIidx), data)
    print(model)

    summary(model)    # this command do not yield any out put when I use it in the script file



 # Calculate mean R1 and SD for each Group

    #???

 # Calculate 95% of mean difference between Groups
    #???

 # Calculate post-hoc test between Groups
    #???

    # Save data to a result file

    # ???? How could I save the data


}

*** snip ***

I would be glad for help in both my questions:

1. How do I get the information presented with the summary command for a lmer model when I am using a script?

2. How do I calculate and save estimates of mean, confint, test, etc of a lmer model?

I'm using the R GUI for Mac OS version R 3.0.1 GUI 1.61 Snow Leopard build (6492)

Best regards
Anders




	[[alternative HTML version deleted]]

