mit <- read.table("mit.csv", header=TRUE,sep=";") library(lattice) library(lme4) xyplot(fat ~ rel_time_men, groups = ID,data=mit,type="l") mit$mentime <- ifelse(mit$rel_time_men > 0, mit$rel_time_men,0) mmod <- lmer(fat ~ rel_time_men + mentime + (1|ID), mit) summary(mmod) mmod <- lmer(fat ~ rel_time_men + mentime + (1 + rel_time_men + mentime|ID), mit) summary(mmod) #alternativni pristup - balik nlme library(nlme) fit <- lme( fat ~ rel_time_men, random = ~ 1 + rel_time_men| ID, data = mit) fit <- lme( fat ~ rel_time_men + mentime, random = ~ 1 + rel_time_men + mentime | ID, data = mit) summary(fit)