线没有出现在交互图中 - y 轴太短?
Line not showing up in interactionplot - y-axis too short?
我正在尝试根据因子设计的数据创建交互图,但线条没有显示出来。我的数据框是
dr
Nr. Bruch Keimf Einw Temp Zeit
1 h1 2.63 54 0 30 4
2 h2 1.71 51 4 30 4
3 h3 2.37 56 0 50 4
4 h4 4.00 51 4 50 4
5 h5 1.63 55 0 30 10
6 h6 1.47 55 4 30 10
7 h7 3.11 43 0 50 10
8 h8 2.42 60 4 50 10
9 c1 2.07 51 2 40 7
10 c2 2.37 46 2 40 7
11 c3 2.48 39 2 40 7
我的剧情代码是
dr$temp=factor(dr$Temp)
interaction.plot(dr$Zeit,dr$Temp,dr$Keimf,
main="Interactionplot Zeit*Temp",
xlab="Zeit (h)", ylab="Keimf (%)", col="olivedrab3", lwd=3, trace.label=deparse(substitute(Temperatur)))
我得到了预期的下图,但没有显示线条
[][1]
[1]: https://i.stack.imgur.com/u18KA.png
我检查了 https://rdrr.io/r/stats/interaction.plot.html 并认为问题可能在于 yaxis 没有涵盖所有值,但是添加
ylim=c(30,65)
导致出现错误消息并且无法正常工作。我在论坛 中找到了另一个 interactionplot 的例子,但是整个代码太嵌套太复杂而无法通过它,因为它是 r 的新手。您认为 yaxis 是问题所在还是我监督了其他事情?
根据您的评论,是的,这是缺少数据。这是一个模拟数据示例,显示您的代码很好,还有您可能喜欢的自定义交互绘图功能。
伪造一些数据。使用您的代码。
mock_dr <- data.frame(
Temp = sample(x = c(30, 40, 50), size = 45, replace = TRUE),
Zeit = sample(x = c(4, 7, 10), size = 45, replace = TRUE),
Keimf = sample(x = 39:60, size = 45, replace = TRUE)
)
interaction.plot(mock_dr$Zeit, mock_dr$Temp, mock_dr$Keimf,
main="Interactionplot Zeit*Temp",
xlab="Zeit (h)", ylab="Keimf (%)", col="olivedrab3", lwd=3, trace.label=deparse(substitute(Temperatur)))
您认为将来有用的自定义函数
CGPfunctions::Plot2WayANOVA(Keimf ~ Zeit * Temp, mock_dr)
#> Converting Zeit to a factor --- check your results
#>
#> Converting Temp to a factor --- check your results
#> Warning in qt(confidence/2 + 0.5, n() - 1): NaNs produced
#>
#> --- WARNING! ---
#> You have an unbalanced design. Using Type II sum of
#> squares, to calculate factor effect sizes eta and omega.
#> Your two factors account for 0.204 of the type II sum of
#> squares.
#> term sumsq meansq df statistic p.value etasq partial.etasq
#> Zeit Zeit 203.060 101.530 2 2.818 0.073 0.125 0.135
#> Temp Temp 102.773 51.386 2 1.426 0.253 0.063 0.073
#> Zeit:Temp Zeit:Temp 27.253 6.813 4 0.189 0.943 0.017 0.021
#> ...4 Residuals 1297.086 36.030 36 NA NA NA NA
#> omegasq partial.omegasq epsilonsq cohens.f power
#> Zeit 0.079 0.075 0.080 0.396 0.554
#> Temp 0.018 0.019 0.019 0.281 0.307
#> Zeit:Temp -0.070 -0.078 -0.072 0.145 0.091
#> ...4 NA NA NA NA NA
#>
#> Measures of overall model fit
#> # A tibble: 1 x 5
#> logLik AIC BIC deviance nobs
#> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 -139. 299. 317. 1297. 45
#>
#> Table of group means
#> # A tibble: 9 x 15
#> # Groups: Zeit [3]
#> Zeit Temp TheMean TheSD TheSEM CIMuliplier LowerBoundCI UpperBoundCI
#> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 4 30 53.2 3.27 1.46 2.78 49.1 57.3
#> 2 4 40 49 NA NA NaN NA NA
#> 3 4 50 54.3 3.21 1.86 4.30 46.3 62.3
#> 4 7 30 48.7 5.05 2.06 2.57 43.4 54.0
#> 5 7 40 48 6.32 2.58 2.57 41.4 54.6
#> 6 7 50 52.6 4.83 2.16 2.78 46.6 58.6
#> 7 10 30 47.9 7.54 2.85 2.45 40.9 54.8
#> 8 10 40 44.7 7.59 2.87 2.45 37.7 51.7
#> 9 10 50 47.8 5.63 2.52 2.78 40.8 54.8
#> # … with 7 more variables: LowerBoundSEM <dbl>, UpperBoundSEM <dbl>,
#> # LowerBoundSD <dbl>, UpperBoundSD <dbl>, N <int>, LowerBound <dbl>,
#> # UpperBound <dbl>
#>
#> Post hoc tests for all effects that were significant
#> [1] "No signfiicant effects"
#>
#> Testing Homogeneity of Variance with Brown-Forsythe
#> Levene's Test for Homogeneity of Variance (center = median)
#> Df F value Pr(>F)
#> group 8 0.5877 0.7812
#> 36
#>
#> Testing Normality Assumption with Shapiro-Wilk
#>
#> Shapiro-Wilk normality test
#>
#> data: MyAOV_residuals
#> W = 0.95464, p-value = 0.07623
#>
#> Interaction graph plotted...
我正在尝试根据因子设计的数据创建交互图,但线条没有显示出来。我的数据框是
dr
Nr. Bruch Keimf Einw Temp Zeit
1 h1 2.63 54 0 30 4
2 h2 1.71 51 4 30 4
3 h3 2.37 56 0 50 4
4 h4 4.00 51 4 50 4
5 h5 1.63 55 0 30 10
6 h6 1.47 55 4 30 10
7 h7 3.11 43 0 50 10
8 h8 2.42 60 4 50 10
9 c1 2.07 51 2 40 7
10 c2 2.37 46 2 40 7
11 c3 2.48 39 2 40 7
我的剧情代码是
dr$temp=factor(dr$Temp)
interaction.plot(dr$Zeit,dr$Temp,dr$Keimf,
main="Interactionplot Zeit*Temp",
xlab="Zeit (h)", ylab="Keimf (%)", col="olivedrab3", lwd=3, trace.label=deparse(substitute(Temperatur)))
我得到了预期的下图,但没有显示线条
[][1]
[1]: https://i.stack.imgur.com/u18KA.png
我检查了 https://rdrr.io/r/stats/interaction.plot.html 并认为问题可能在于 yaxis 没有涵盖所有值,但是添加
ylim=c(30,65)
导致出现错误消息并且无法正常工作。我在论坛
根据您的评论,是的,这是缺少数据。这是一个模拟数据示例,显示您的代码很好,还有您可能喜欢的自定义交互绘图功能。
伪造一些数据。使用您的代码。
mock_dr <- data.frame(
Temp = sample(x = c(30, 40, 50), size = 45, replace = TRUE),
Zeit = sample(x = c(4, 7, 10), size = 45, replace = TRUE),
Keimf = sample(x = 39:60, size = 45, replace = TRUE)
)
interaction.plot(mock_dr$Zeit, mock_dr$Temp, mock_dr$Keimf,
main="Interactionplot Zeit*Temp",
xlab="Zeit (h)", ylab="Keimf (%)", col="olivedrab3", lwd=3, trace.label=deparse(substitute(Temperatur)))
您认为将来有用的自定义函数
CGPfunctions::Plot2WayANOVA(Keimf ~ Zeit * Temp, mock_dr)
#> Converting Zeit to a factor --- check your results
#>
#> Converting Temp to a factor --- check your results
#> Warning in qt(confidence/2 + 0.5, n() - 1): NaNs produced
#>
#> --- WARNING! ---
#> You have an unbalanced design. Using Type II sum of
#> squares, to calculate factor effect sizes eta and omega.
#> Your two factors account for 0.204 of the type II sum of
#> squares.
#> term sumsq meansq df statistic p.value etasq partial.etasq
#> Zeit Zeit 203.060 101.530 2 2.818 0.073 0.125 0.135
#> Temp Temp 102.773 51.386 2 1.426 0.253 0.063 0.073
#> Zeit:Temp Zeit:Temp 27.253 6.813 4 0.189 0.943 0.017 0.021
#> ...4 Residuals 1297.086 36.030 36 NA NA NA NA
#> omegasq partial.omegasq epsilonsq cohens.f power
#> Zeit 0.079 0.075 0.080 0.396 0.554
#> Temp 0.018 0.019 0.019 0.281 0.307
#> Zeit:Temp -0.070 -0.078 -0.072 0.145 0.091
#> ...4 NA NA NA NA NA
#>
#> Measures of overall model fit
#> # A tibble: 1 x 5
#> logLik AIC BIC deviance nobs
#> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 -139. 299. 317. 1297. 45
#>
#> Table of group means
#> # A tibble: 9 x 15
#> # Groups: Zeit [3]
#> Zeit Temp TheMean TheSD TheSEM CIMuliplier LowerBoundCI UpperBoundCI
#> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 4 30 53.2 3.27 1.46 2.78 49.1 57.3
#> 2 4 40 49 NA NA NaN NA NA
#> 3 4 50 54.3 3.21 1.86 4.30 46.3 62.3
#> 4 7 30 48.7 5.05 2.06 2.57 43.4 54.0
#> 5 7 40 48 6.32 2.58 2.57 41.4 54.6
#> 6 7 50 52.6 4.83 2.16 2.78 46.6 58.6
#> 7 10 30 47.9 7.54 2.85 2.45 40.9 54.8
#> 8 10 40 44.7 7.59 2.87 2.45 37.7 51.7
#> 9 10 50 47.8 5.63 2.52 2.78 40.8 54.8
#> # … with 7 more variables: LowerBoundSEM <dbl>, UpperBoundSEM <dbl>,
#> # LowerBoundSD <dbl>, UpperBoundSD <dbl>, N <int>, LowerBound <dbl>,
#> # UpperBound <dbl>
#>
#> Post hoc tests for all effects that were significant
#> [1] "No signfiicant effects"
#>
#> Testing Homogeneity of Variance with Brown-Forsythe
#> Levene's Test for Homogeneity of Variance (center = median)
#> Df F value Pr(>F)
#> group 8 0.5877 0.7812
#> 36
#>
#> Testing Normality Assumption with Shapiro-Wilk
#>
#> Shapiro-Wilk normality test
#>
#> data: MyAOV_residuals
#> W = 0.95464, p-value = 0.07623
#>
#> Interaction graph plotted...