2015-03-13 1 views
1

У меня возникла проблема с функцией sem() в пакете lavaan в R, и я надеялся, что у кого-то здесь могут быть мысли о том, как я могу это исправить ,R sem function in lavaan ПРЕДУПРЕЖДЕНИЕ: не удалось вычислить стандартные ошибки

Моя модель устанавливается следующим образом:

mod <- 'trait ~ historical1 + historical 2 + contemporary1 + contemporary2 
abundance ~ contemporary1 + contemporary2 + trait 
bacteria ~ historical1 + historical 2 + contemporary1 + contemporary2 + trait + abundance' 

Мои экзогенные переменные (historical1, исторические 2, contemporary1 и contemporary2) являются категориальные переменные, которые я манипулируют для моего эксперимента с двумя возможными уровнями. Я рассматриваю их как фиктивные переменные с 0 и 1. Все остальное - это числовое измерение.

У меня есть три разных переменных для «бактерий», которые я пытаюсь посмотреть отдельно. Когда я использую первый (bacter1), модель работает плавно.

> modA<-'trait ~ historical1 + historical 2 + contemporary1 + contemporary2 
+ abundance ~ contemporary1 + contemporary2 + trait 
+ bacteria1 ~ historical1 + historical 2 + contemporary1 + contemporary2 + trait + abundance' 
> fit<-sem(modA,data=data,meanstructure=T) 
Warning message: 
In lav_data_full(data = data, group = group, group.label = group.label, : 
    lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate 
> fitmeasures(fit) 
       fmin    chisq     df    pvalue 
       0.154    24.028    2.000    0.000 
    baseline.chisq   baseline.df  baseline.pvalue     cfi 
      114.474    15.000    0.000    0.779 
       tli    nnfi     rfi     nfi 
      -0.661    -0.661    1.000    0.790 
       pnfi     ifi     rni    logl 
       0.105    0.804    0.779   -1605.897 
    unrestricted.logl    npar     aic     bic 
      -1593.883    19.000   3249.794   3294.572 
      ntotal    bic2    rmsea  rmsea.ci.lower 
      78.000   3234.670    0.376    0.251 
    rmsea.ci.upper  rmsea.pvalue     rmr   rmr_nomean 
       0.517    0.000    40.988    45.826 
       srmr  srmr_bentler srmr_bentler_nomean   srmr_bollen 
       0.080    0.080    0.089    0.080 
srmr_bollen_nomean   srmr_mplus srmr_mplus_nomean    cn_05 
       0.089    0.080    0.089    20.450 
       cn_01     gfi    agfi    pgfi 
      30.899    0.997    0.946    0.057 
       mfi    ecvi 
       0.868     NA 
> summary(fit) 
lavaan (0.5-16) converged normally after 145 iterations 

    Number of observations       78 

    Estimator           ML 
    Minimum Function Test Statistic    24.028 
    Degrees of freedom         2 
    P-value (Chi-square)       0.000 

Parameter estimates: 

    Information         Expected 
    Standard Errors        Standard 

        Estimate Std.err Z-value P(>|z|) 
Regressions: 
    trait ~ 
    historical1  8.722 39.607 0.220 0.826 
    historical2  89.529 39.607 2.260 0.024 
    contemporary1  6.737 39.621 0.170 0.865 
    contemporary2 411.556 39.621 10.387 0.000 
    abundance ~ 
    contemporary1 -36.390 81.354 -0.447 0.655 
    contemporary2 424.993 123.301 3.447 0.001 
    trait   -0.251 0.225 -1.116 0.265 
    bacteria1 ~ 
    historical1  -2.342 2.455 -0.954 0.340 
    historical2  -2.142 2.533 -0.845 0.398 
    contemporary1 -0.268 2.459 -0.109 0.913 
    contemporary2  3.410 4.059 0.840 0.401 
    trait    0.000 0.007 0.031 0.975 
    abundance  -0.008 0.003 -2.451 0.014 

Intercepts: 
    trait   1299.789 44.285 29.351 0.000 
    abundance  1438.077 311.643 4.614 0.000 
    bacteria1  26.805 10.717 2.501 0.012 

Variances: 
    trait   30569.613 4895.056 
    abundance  128842.663 20631.338 
    bacteria1  117.383 18.796 

Однако, когда я использую одну из двух других бактериальных переменных, я получаю предупреждение «не может вычислить стандартные ошибки!».

> modB<-'trait ~ historical1 + historical 2 + contemporary1 + contemporary2 
    + abundance ~ contemporary1 + contemporary2 + trait 
    + bacteria2 ~ historical1 + historical 2 + contemporary1 + contemporary2 + trait + abundance' 
    > fit<-sem(modB,data=data,meanstructure=T) 
    Warning messages: 
    1: In lav_data_full(data = data, group = group, group.label = group.label, : 
     lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate 
    2: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : 
     lavaan WARNING: could not compute standard errors! 
> fitmeasures(fit) 
       fmin    chisq     df    pvalue  baseline.chisq 
       0.154    24.028    2.000    0.000    126.602 
     baseline.df  baseline.pvalue     cfi     tli    nnfi 
      15.000    0.000    0.803    -0.480    -0.480 
       rfi     nfi    pnfi     ifi     rni 
       1.000    0.810    0.108    0.823    0.803 
       logl unrestricted.logl    npar     aic     bic 
      -1277.674   -1265.660    19.000   2593.348   2638.126 
      ntotal    bic2    rmsea  rmsea.ci.lower  rmsea.ci.upper 
      78.000   2578.224    0.376    0.251    0.517 
     rmsea.pvalue     rmr   rmr_nomean    srmr  srmr_bentler 
       0.000    15.075    16.855    0.078    0.078 
srmr_bentler_nomean   srmr_bollen srmr_bollen_nomean   srmr_mplus srmr_mplus_nomean 
       0.087    0.078    0.087    0.078    0.087 
       cn_05    cn_01     gfi    agfi    pgfi 
      20.450    30.899    0.997    0.945    0.057 
       mfi    ecvi 
       0.868     NA 
> summary(fit) 
lavaan (0.5-16) converged normally after 115 iterations 

    Number of observations       78 

    Estimator           ML 
    Minimum Function Test Statistic    24.028 
    Degrees of freedom         2 
    P-value (Chi-square)       0.000 

Parameter estimates: 

    Information         Expected 
    Standard Errors        Standard 

        Estimate Std.err Z-value P(>|z|) 
Regressions: 
    trait ~ 
    historical1  8.723 
    historical2  89.530 
    contemporary1  6.737 
    contemporary2 411.556 
    abundance ~ 
    contemporary1 -36.390 
    contemporary2 424.993 
    trait   -0.251 
    bacteria2 ~ 
    historical1  0.020 
    historical2  -0.038 
    contemporary1 -0.075 
    contemporary2 -0.071 
    trait   -0.000 
    abundance  -0.000 

Intercepts: 
    trait   1299.788 
    abundance  1438.077 
    bacteria2   0.367 

Variances: 
    trait   30569.606 
    abundance  128842.668 
    bacteria2   0.026 

    > modC<-'trait ~ historical1 + historical 2 + contemporary1 + contemporary2 
    + abundance ~ contemporary1 + contemporary2 + trait 
    + bacteria3 ~ historical1 + historical 2 + contemporary1 + contemporary2 + trait + abundance' 
    > fit<-sem(modC,data=data,meanstructure=T) 
    Warning messages: 
    1: In lav_data_full(data = data, group = group, group.label = group.label, : 
     lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate 
    2: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : 
     lavaan WARNING: could not compute standard errors! 
> fitmeasures(fit) 
       fmin    chisq     df    pvalue  baseline.chisq 
       0.154    24.028    2.000    0.000    112.875 
     baseline.df  baseline.pvalue     cfi     tli    nnfi 
      15.000    0.000    0.775    -0.688    -0.688 
       rfi     nfi    pnfi     ifi     rni 
       1.000    0.787    0.105    0.801    0.775 
       logl unrestricted.logl    npar     aic     bic 
      -1414.328   -1402.314    19.000   2866.656   2911.434 
      ntotal    bic2    rmsea  rmsea.ci.lower  rmsea.ci.upper 
      78.000   2851.532    0.376    0.251    0.517 
     rmsea.pvalue     rmr   rmr_nomean    srmr  srmr_bentler 
       0.000    15.160    16.949    0.077    0.077 
srmr_bentler_nomean   srmr_bollen srmr_bollen_nomean   srmr_mplus srmr_mplus_nomean 
       0.086    0.079    0.086    0.079    0.086 
       cn_05    cn_01     gfi    agfi    pgfi 
      20.450    30.899    1.000    0.991    0.057 
       mfi    ecvi 
       0.868     NA 
> summary(fit) 
lavaan (0.5-16) converged normally after 119 iterations 

    Number of observations       78 

    Estimator           ML 
    Minimum Function Test Statistic    24.028 
    Degrees of freedom         2 
    P-value (Chi-square)       0.000 

Parameter estimates: 

    Information         Expected 
    Standard Errors        Standard 

        Estimate Std.err Z-value P(>|z|) 
Regressions: 
    trait ~ 
    historical1  8.723 
    historical2  89.530 
    contemporary1  6.737 
    contemporary2 411.556 
    abundance ~ 
    contemporary1 -36.390 
    contemporary2 424.993 
    trait   -0.251 
    bacteria3 ~ 
    historical1  0.098 
    historical2  0.095 
    contemporary1 -0.102 
    contemporary2  0.204 
    trait   -0.000 
    abundance  -0.000 

Intercepts: 
    trait   1299.788 
    abundance  1438.077 
    bacteria3  19.984 

Variances: 
    trait   30569.585 
    abundance  128842.707 
    bacteria3   0.864 

Я сделал некоторое исследование об этом предупреждении, но ничего не помогает. Отличается ли модель очень плохо с двумя другими переменными?

Любые идеи? Заранее спасибо.

> str(data) 
'data.frame': 78 obs. of 10 variables: 
$ X   : int 1 2 3 4 5 6 7 8 9 10 ... 
$ historical1 : int 0 0 1 1 0 0 1 1 1 1 ... 
$ historical2 : int 0 1 1 0 0 1 1 0 0 1 ... 
$ contemporary1: int 0 1 0 1 0 0 1 0 1 0 ... 
$ contemporary2: int 1 1 0 1 0 0 1 0 1 0 ... 
$ trait  : num 2202 1935 1371 1978 1130 ... 
$ abundance : num 1011 1757 1347 1578 1674 ... 
$ bacteria1 : num 30.39 6.69 7.58 6.05 8.47 ... 
$ bacteria2 : num -0.0356 0.0304 0.1344 -0.0497 0.265 ... 
$ bacteria3 : num 19.4 18.1 20 18.1 18.4 ... 

Erica

ответ

1

В случае, если кто задавался вопросом, я в конце концов выяснить это. По-видимому, проблема масштабирования между переменными в модели. Его можно исправить с помощью функции scale().

data[,c(19,21)]<-scale(data[,c(19,21)],center=FALSE,scale=c(100000000,0.01)) 

Если столбец 19 соответствует переменной «bacter2», а столбец 21 соответствует моей переменной «bacter3». Переменная бактерий2 составляла примерно 10^7, в то время как у бактерий 3 было примерно 10^-2. Изменение их до 10^1 или 10^2 исправляет оба предупреждения, выпущенные в приведенном выше коде, а sem() успешно вычисляет стандартные ошибки.

 Смежные вопросы

  • Нет связанных вопросов^_^