2017-10-19 5 views
1

との3つの因子:ベスト構造 - 私は次のような問題に反復測定分析/縦方向のデータを実行したい1縦

「領域で分析した16本の木がありますし、 B領域では16である。各地域では、冬季に8本、夏季に8本の木が分析されたが、同じ樹木ではない。私はと各ツリー直径約5つの異なる深さでstarch's知覚的。」

tree Region season depth starch 
1  A  W  1  0.07 
1  A  W  2  0.10 
1  A  W  3  0.13 
1  A  W  4  0.16 
1  A  W  5  0.11 
2  A  W  1  0.07 
2  A  W  2  0.10 
2  A  W  3  0.13 
2  A  W  4  0.16 
2  A  W  5  0.11 
...  ...  ...  ...  ... 
17  B  S  1  0.06 
...  ...  ...  ...  ... 

私が考えるにはR.でガンマ分布と一般化線形混合モデル(GLMM)でフィット感を得ることを考慮すると、 GLMMの初心者のようなものですが、リージョン、シーズン、デプスファクタがレスポンス変数に異なる影響を与えるかどうかを知るために、Rにどのように適合するかを尋ねたいと思います。

私が実行した場合には、正しい次のようになります。

require(lme4) 
Mod1=glmer(starch~Region*season*depth+(1|tree),data=data,family="gamma") 
summary(Mod1) 
? 

ない場合は、何がそれについて手続きするための最良の方法だろうか?誰かが私に方向性または少なくとも参照を与えることができれば、とても感謝しています。

@Ben Bolkerと@fliesのご協力ありがとうございます。投稿された貢献は多くの助けになりました。 次に、深度を定性的に扱うことが可能かどうかを確認し、Region * stage * depthの対話を確認します。これを行う:

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) 
glmerMod] 
Family:Gamma(log) 
Formula: starch ~Region*season*depth+(1|tree) 
    Date: data 

    AIC  BIC logLik deviance df.resid 
    -1358.4 -1290.7 701.2 -1402.4 138 

Scaled residuals: 
    Min 1Q Median 3Q Max 
-2.3398 -0.6699 -0.1065 0.6683 3.2020 

Random effects: 
Groups Name Variance Std.Dev. 
tree (Intercept) 7.171e-05 0.008468 
Residual 6.020e-04 0.024536 
Number of obs: 160, groups: tree, 32 

Fixed effects: 
       Estimate  Std. Error t value Pr (> | z |) 
(Intercept) -2.593064  0.009621  -269.51  <2e-16 *** 
RegionRP  0.260453  0.013607  19.14 <2e-16 *** 
seasonV  -0.193693  0.013607  -14.23 <2e-16 *** 
depth2  0.409813  0.011894  34.46 <2e-16 *** 
depth3  0.594269  0.011893  49.97 <2e-16 *** 
depth4  0.779051  0.011893  65.50 <2e-16 *** 
depth5  0.432146  0.011893  36.34 <2e-16 *** 
RegionRP:seasonV 0.088320 0.019243 4.59 4.44e-06 *** 
localRP:depth2  -0.065211 0.016820 -3.88 0.000106 *** 
localRP:depth3  -0.130185 0.016819 -7.74 9.92e-15 *** 
localRP:depth4  -0.190743 0.016820 -11.34 <2e-16 *** 
localRP:depth5  -0.067266 0.016820 -4.00 6.35e-05 *** 
seasonV:depth2  0.031624 0.016821  1.88 0.060103. 
seasonV:depth3  0.139424 0.016820  8.29 <2e-16 *** 
seasonV:depth4  0.147717 0.016820  8.78 <2e-16 *** 
seasonV:depth5  0.107589 0.016820  6.40 1.59e-10 *** 
RegionRP:seasonV:depth2 -0.018490 0.023787 -0.78 0.436970 
RegionRP:seasonV:depth3 -0.113810 0.023786 -4.78 1.71e-06 *** 
RegionRP:seasonV:depth4 -0.112337 0.023787 -4.72 2.33e-06 *** 
RegionRP:seasonV:depth5 -0.121932 0.023787 -5.13 2.96e-07 *** 
--- 
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1 

Analysis of Deviance Table (Type II Wald chisquare tests) 
    Response: starch 
          Chisq  Df Pr (> Chisq) 
    Region     872.9486 1 <2.2e-16 *** 
    season     282.9125 1 <2.2e-16 *** 
    depth    16726.2395 4 <2.2e-16 *** 
    Region:season   1.5641 1 0.2111 
    Region:depth   521.4171 4 <2.2e-16 *** 
    season:depth   85.5213 4 <2.2e-16 *** 
    Region:season:depth  49.1586 4 5.41e-10 *** 
    --- 
    Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1 

は、上記の分析を行うことができた。

data = within (data, { 
Region = factor (Region) 
season = factor (season) 
depth = factor (depth) }) 
require (lme4) 
Mod1 = glmer (starch~Region*season*depth+(1|tree),data=data,family=Gamma(link="log")) 

summary (Mod1) 
library (car) 
Anova(mod1) 

は、次のような結果を得ますか?推定されたパラメータの数を考えると、連続深さと加法モデルを考慮する必要がありますか?

+0

'Region'はランダム効果' tree'によって混乱しているようです。 'lme4'がこれをどのように処理するかをIDKに伝えます。いくつかのタイプミスを除いて、コードは大丈夫です( 'region'は' Region'、 'mod1_glmer'は' Mod1'でなければなりません)。 – flies

+0

このモデルから何を学ぼうとしていますか? – flies

+0

編集機能を使用して、(タグの下の)タイプミスを修正することができます – flies

答えて

2
  • ます(引用符はオプションですが、大文字のGでなければなりません)family="Gamma"を必要としています。私はしばしば(1)デフォルトの逆リンクではなくログリンク(family=Gamma(link="log"))を使用すること、および/または(2)ログリニア混合モデルを使用すること(lmer(log(starch)~...))を提案します。両方ともデフォルトのガンマモデルよりも数値的に安定しており、パラメータの解釈が容易です。
  • 上記のコメントの一部とは対照的に、デフォルトではglmerは、深さなどの数値変数を連続予測子として扱います。つまり、(ログ)線形の関係になり、単一のパラメータにのみ適合します。あなたは「どの深さが違うか」を検出することはできませんが、深みの変化としてデンプンの連続変化を検出することができます。
  • 合計が32本の場合、3以上4以下のパラメータ(最大パラメータ〜n/10; Harrellの回帰モデリング戦略を参照)を持つモデルに合うようにするのは危険です(低電力)。 )、あなたの測定値が非常に正確で、生物学的なばらつきが少ない場合は除きます。完全固定効果モデルRegion*season*depthは、8つのパラメータを提供します(2つのリージョンX 2シーズンX(インターセプト、スロープ):深さが連続的であるため、上記の20はありません)。
  • 各地域と季節で独立して深さを分析することは、すべての相互作用を伴うモデルを適合させることとほぼ同じです。あなたは各地域/シーズンの組み合わせで8つの樹木しか持たないので、信頼できるモデルに合うのは難しいでしょう。
  • あなたのインタラクションをあきらめて、添加物モデルRegion + season + depthが4つのパラメータ(季節と奥行きに渡って仮定される定数)+領域)+深度の影響(想定される定数...)とツリー間の変動性を推定するランダム効果のパラメータ(固定効果の調整後) - やや複雑すぎるかもしれませんが、おそらくそれを取り除くことができます(あまりにも複雑なモデルから始める段階的な手順を使用しないでください。これは妥当であると思われるものにトリミングします。これは賢明なようですが、災害のレシピです。
  • 忘れないでくださいデータをプロットし、モデルのグラフィカル診断を確認してください。
+0

ご協力いただきありがとうございます。投稿された貢献は多くの助けになりました。次に、深さを定性的、Region * stage * depthの相互作用として扱うことが可能かどうかを確認します。上記の質問に、使用したコマンドを追加しました。このように問題はありますか?前もって感謝します。 –

0

ご協力ありがとうございました@BenBと@flies。投稿された貢献は多くの助けになりました。

これで、深さを質的に扱うことができるかどうかを確認し、Region * stage * depthの対話を確認します。

data = within (data, { 
Region = factor (Region) 
season = factor (season) 
depth = factor (depth) }) 
require (lme4) 
Mod1 = glmer (starch~Region*season*depth+(1|tree),data=data,family=Gamma(link="log")) 

summary (Mod1) 
library (car) 
Anova(mod1) 

の入手以下の結果:このやっ

Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) 
glmerMod] 
Family:Gamma(log) 
Formula: starch ~Region*season*depth+(1|tree) 
    Date: data 

    AIC  BIC logLik deviance df.resid 
    -1358.4 -1290.7 701.2 -1402.4 138 

Scaled residuals: 
    Min 1Q Median 3Q Max 
-2.3398 -0.6699 -0.1065 0.6683 3.2020 

Random effects: 
Groups Name Variance Std.Dev. 
tree (Intercept) 7.171e-05 0.008468 
Residual 6.020e-04 0.024536 
Number of obs: 160, groups: tree, 32 

Fixed effects: 
       Estimate  Std. Error t value Pr (> | z |) 
(Intercept) -2.593064  0.009621  -269.51  <2e-16 *** 
RegionRP  0.260453  0.013607  19.14 <2e-16 *** 
seasonV  -0.193693  0.013607  -14.23 <2e-16 *** 
depth2  0.409813  0.011894  34.46 <2e-16 *** 
depth3  0.594269  0.011893  49.97 <2e-16 *** 
depth4  0.779051  0.011893  65.50 <2e-16 *** 
depth5  0.432146  0.011893  36.34 <2e-16 *** 
RegionRP:seasonV 0.088320 0.019243 4.59 4.44e-06 *** 
localRP:depth2  -0.065211 0.016820 -3.88 0.000106 *** 
localRP:depth3  -0.130185 0.016819 -7.74 9.92e-15 *** 
localRP:depth4  -0.190743 0.016820 -11.34 <2e-16 *** 
localRP:depth5  -0.067266 0.016820 -4.00 6.35e-05 *** 
seasonV:depth2  0.031624 0.016821  1.88 0.060103. 
seasonV:depth3  0.139424 0.016820  8.29 <2e-16 *** 
seasonV:depth4  0.147717 0.016820  8.78 <2e-16 *** 
seasonV:depth5  0.107589 0.016820  6.40 1.59e-10 *** 
RegionRP:seasonV:depth2 -0.018490 0.023787 -0.78 0.436970 
RegionRP:seasonV:depth3 -0.113810 0.023786 -4.78 1.71e-06 *** 
RegionRP:seasonV:depth4 -0.112337 0.023787 -4.72 2.33e-06 *** 
RegionRP:seasonV:depth5 -0.121932 0.023787 -5.13 2.96e-07 *** 
--- 
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1 

Analysis of Deviance Table (Type II Wald chisquare tests) 
    Response: starch 
          Chisq  Df Pr (> Chisq) 
    Region     872.9486 1 <2.2e-16 *** 
    season     282.9125 1 <2.2e-16 *** 
    depth    16726.2395 4 <2.2e-16 *** 
    Region:season   1.5641 1 0.2111 
    Region:depth   521.4171 4 <2.2e-16 *** 
    season:depth   85.5213 4 <2.2e-16 *** 
    Region:season:depth  49.1586 4 5.41e-10 *** 
    --- 
    Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 '' 1 

は、上記の分析を行っていませんか?推定されたパラメータの数を考えると、連続深さと加法モデルを考慮する必要がありますか?

関連する問題