mixed model help

Hi, I am trying to run a mixed model analysis in Rstudio. I am a novice and have tried several syntax to start with but each time I get some error.

The idea is to analyse if "VCF" (y variable) is significantly influenced by the fixed factor (Area) and random factors ("Year" and "Observer.FW").

Can anybody help? Thanks !

There are no missing values, but for some syntax i get missing value error

str(Observers_Bias)
'data.frame':	286 obs. of  14 variables:
 $ Year                : int  2011 2011 2011 2011 2011 2011 2011 2011 2011 2011 ...
 $ FW.Tibs             : int  4 4 12 12 9 4 12 21 8 13 ...
 $ Helo.TIBS           : int  20 16 43 24 37 16 35 67 61 32 ...
 $ Area                : Factor w/ 2 levels "LA","TX": 1 1 1 1 1 1 1 1 1 1 ...
 $ FW.Tibs.1           : int  4 4 12 12 9 4 12 21 8 13 ...
 $ VCF                 : num  5 4 3.58 2 4.11 ...
 $ LogVCF              : num  0.699 0.602 0.554 0.301 0.614 ...
 $ SegiD               : num  10202 10203 10301 10302 10402 ...
 $ LogFW               : num  0.602 0.602 1.079 1.079 0.954 ...
 $ Helo.Log            : num  1.3 1.2 1.63 1.38 1.57 ...
 $ Observer.Helo       : Factor w/ 8 levels "ALF_DB","DB_ME",..: 4 4 4 4 4 4 4 4 4 4 ...
 $ Observer.FW         : Factor w/ 10 levels "CA_DB_MJR","CLAY_SKM",..: 4 4 4 4 4 4 4 4 4 4 ...
 $ Observer.number.Helo: int  1 1 1 1 1 1 1 1 1 1 ...
 $ Observer.number.FW  : int  2 2 2 2 2 2 2 2 2 2 ...
> mixed.mod <- lme(VCF ~ Year + Area + (1|Observer.FW), data = Observers_Bias)
Error in getGroups.data.frame(dataMix, groups) : 
  invalid formula for groups
> mixed.mod <- lme(LogVCF ~ Year + Area, data = Observers_Bias,random = ~ 1)
Error in na.fail.default(list(LogVCF = c(0.698970004, 0.602059991, 0.55428721,  : 
  missing values in object
> mixed.mod <- lme(LogVCF ~ Year + Area + (1|Observer.FW), data = Observers_Bias,na.action = na.exclude)
Error in getGroups.data.frame(dataMix, groups) : 
  invalid formula for groups
> mixed.mod <- lme(VCF ~ Year + Area + (1|Observer.FW), data = Observers_Bias,na.action = na.exclude)
Error in getGroups.data.frame(dataMix, groups) : 
  invalid formula for groups
> mixed.mod <- lme4(VCF ~ Year + Area + (1|Observer.FW), data = Observers_Bias,na.action = na.exclude)
Error in lme4(VCF ~ Year + Area + (1 | Observer.FW), data = Observers_Bias,  : 
  could not find function "lme4"
> mixed.mod <- lme(VCF ~ Year + Area + Observer.FW, data = Observers_Bias,na.action = na.exclude)
Error in getGroups.data.frame(dataMix, groups) : 
  invalid formula for groups
> mixed.mod <- lme(VCF ~ Year + Area + Observer.FW, data = Observers_Bias,na.action = na.exclude)
Error in getGroups.data.frame(dataMix, groups) : 
  invalid formula for groups
> mixed.mod <- lme(VCF ~ Year + Area + Observer.FW, data = Observers_Bias, na.action = na.exclude)
Error in getGroups.data.frame(dataMix, groups) : 
  invalid formula for groups

does this work any better ?

mixed.mod <- lme(VCF ~ Year + Area , random = ~ 1|Observer.FW, data = Observers_Bias)

Nir, Thank you. It worked! I really appreciate your help. Just had a question:

Does your code below include the random effect of year also? or only the Observer.FW? Thanks.

mixed.mod <- lme(VCF ~ Year + Area , random = ~ 1|Observer.FW, data = Observers_Bias)

@Kabali Can you mark the issue as solved?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.