1
#AODtoPM2.5
library(readxl)
library(emmeans)
library(sjstats)
library(lme4)
library(lmerTest)
library(MuMIn)
library(nlme)
library(factoextra)
library(tidyverse)

data <- file.choose()
AQ1=read.csv("Sakon.csv")
# divide the months into four seasons
seasons = c( 'winter',
             'winter',
             rep('spring',3),
             rep('summer',3),
             rep('fall',3),
             'winter')

AQ1 = AQ1 %>%
  filter(!is.na(AQ1) & AQ1 > 0) %>%
  mutate(season=factor(month, 1:12, seasons)) 
# boxplot for response grouped by cbwd

boxplot(formular = PM2.5 ~ month + day + AOD + Tem + RH + WS + 
                   HPBL + NDVI, col=c("white","lightgray"), AQ1)
library(lme4)
library(lmerTest)
lmer1 = lmer(PM2.5 ~ month + day + AOD + Tem + RH + WS + 
             HPBL + NDVI, REML = TRUE, data = AQ1, 
             na.action=na.omit)
summary(lmer1)

lmer1 = lme(PM2.5 ~ month + day + AOD + Tem + RH + WS + 
            HPBL + NDVI, REML = TRUE, data = AQ1, 
            na.action=na.omit)

Error in lme(PM2.5 ~ month + day + AOD + Tem + RH + WS + HPBL + NDVI, : unused argument (REML = TRUE)

summary(lmer1)
 Length   Class    Mode 
      3 formula    call 
kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
user313026
  • 23
  • 2

1 Answers1

1

The function lme in the nlme package does not have a REML parameter. By default it uses restricted maximum likelihood anyway, but you can specify REML anyway (or ML) by using method = "REML" (or method = "ML")

lme(PM2.5 ~ month + day + AOD + Tem + RH + WS + 
    HPBL + NDVI, data = AQ1, method = "REML", 
    na.action=na.omit)
kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
Robert Long
  • 53,316
  • 10
  • 84
  • 148
  • Thank you but it's not work.> lmer1 = lmer(PM2.5 ~ month+day+AOD+Tem+RH+WS+HPBL+NDVI, data = AQ1, method = "REML", na.action=na.omit) Error in lmer(PM2.5 ~ month + day + AOD + Tem + RH + WS + HPBL + NDVI, : unused argument (method = "REML") > summary(lmer1) Length Class Mode 3 formula call – user313026 Mar 02 '21 at 09:14
  • Be careful which function you are using. `lmer` uses `REML = TRUE`, while `lme` uses `method = "REML"`. That was partly my fault for using `lmer` in my answer. I have changed it now. There also seems to be other problems with your models - in particular you are not speficying any random effects so that might produce another error. – Robert Long Mar 02 '21 at 09:18
  • yes you are right. how to fix it? – user313026 Mar 02 '21 at 09:29
  • You need to specify the random effects. That would be a completely different question so I would encourage you to ask a new question and give as much details as possible about your study, the data and your research question(s). Also please format any code or output using the 3 backticks, which @Pluviophile has kindly done for you in this question (take a look at the formatting by clicking the Edit button if you wish), but you need to ensure the question is statistical, not just about using the software (otherwise it will be closed as off topic here) – Robert Long Mar 02 '21 at 09:36