R/elev.com.R
elev.com.Rd
Test if several major axis or standardised major axis lines share a common
elevation. This can now be done via sma(y~x+groups)
, see help on the
sma
function.
The Y-variable for all observations (as a vector).
The X-variable for all observations (as a vector).
Coding variable identifying which group each observation belongs to (as a factor or vector).
Deprecated. Use with() instead (see Examples).
The line fitting method:
standardised major axis (this is the default)
major axis
The desired confidence level for the 100(1-alpha)% confidence interval for the common elevation. (Default value is 0.05, which returns a 95% confidence interval.)
If TRUE, uses a robust method to fit the lines and construct the test statistic.
The estimated variance matrices of measurement error, for each group. This is a 3-dimensional array with measurement error in Y in the first row and column, error in X in the second row and column,and groups running along the third dimension. Default is that there is no measurement error.
(optional: rarely required). A vector containing the labels for `groups'. (Only actually useful for reducing computation time in simulation work).
The Wald statistic testing for no shift along the common axis
The P-value of the test. This is calculated assuming that stat has a chi-square distribution with (g-1) df, if there are g groups
The estimated common elevation
A 100(1-alpha)% confidence interval for the true common elevation
Separate elevation estimates for each group
Calculates a Wald statistic to test for equal elevation of several MA's or SMA's with a common slope. This is done by testing for equal mean residual scores across groups.
Note that this test is only valid if it is reasonable to assume that the axes for the different groups all have the same slope.
The test assumes the following:
each group of observations was independently sampled
the axes fitted to all groups have a common slope
y and x are linearly related within each group
residual scores independently follow a normal distribution with equal variance at all points along the line, within each group
Note that we do not need to assume equal variance across groups, unlike in tests comparing several linear regression lines.
The assumptions can be visually checked by plotting residual scores against
fitted axis scores, and by constructing a Q-Q plot of residuals against a
normal distribution, available using the plot.sma
function. On
a residual plot, if there is a distinct increasing or decreasing trend
within any of the groups, this suggests that all groups do not share a
common slope.
Setting robust=TRUE
fits lines using Huber's M estimation, and
modifies the test statistic as proposed in Taskinen & Warton (in review).
The common slope (\(\hat{\beta}\)) is estimated from a maximum of 100 iterations, convergence is reached when the change in \(\hat{\beta} < 10^{-6}\).
Warton D. I., Wright I. J., Falster D. S. and Westoby M. (2006) A review of bivariate line-fitting methods for allometry. Biological Reviews 81, 259--291.
Taskinen, S. and D.I. Warton. in review. Robust tests for one or more allometric lines.
# Load leaf longevity data
data(leaflife)
# Test for common SMA slope amongst species at low soil nutrient sites
# with different rainfall:
leaf.low.soilp <- subset(leaflife, soilp == 'low')
with(leaf.low.soilp, slope.com(log10(longev), log10(lma), rain))
#> $LR
#> [1] 2.366711
#>
#> $p
#> [1] 0.123948
#>
#> $b
#> [1] 1.5514
#>
#> $ci
#> [1] 1.109374 2.011726
#>
#> $varb
#> [1] 0.04001762
#>
#> $lambda
#> [1] 2.406841
#>
#> $bs
#> high low
#> slope 1.1768878 1.786551
#> lower.CI.lim 0.7631512 1.257257
#> upper.CI.lim 1.8149286 2.538672
#>
#> $df
#> [1] 1
#>
# Now test for common elevation of the groups fitted with an axis
# of common slope, at low soil nutrient sites:
with(leaf.low.soilp, elev.com(log10(longev), log10(lma), rain))
#> $stat
#> [,1]
#> [1,] 6.566201
#>
#> $p
#> [,1]
#> [1,] 0.01039336
#>
#> $a
#> [,1]
#> [1,] -2.969185
#>
#> $ci
#> [1] -3.822525 -2.115845
#>
#> $as
#> elevation lower CI limit upper CI limit
#> high -3.140896 -4.079825 -2.201966
#> low -3.304865 -4.353328 -2.256403
#>
#> $df
#> [1] 1
#>
# Or test for common elevation amongst the MA's of common slope,
# for low soil nutrient sites, and construct 99% a confidence interval
# for the common elevation:
with(leaf.low.soilp, elev.com(log10(longev), log10(lma), rain, method='MA',
alpha=0.01))
#> $stat
#> [,1]
#> [1,] 6.489554
#>
#> $p
#> [,1]
#> [1,] 0.01085102
#>
#> $a
#> [,1]
#> [1,] -3.32005
#>
#> $ci
#> [1] -4.888304 -1.751796
#>
#> $as
#> elevation lower CI limit upper CI limit
#> high -3.694360 -5.539928 -1.848792
#> low -3.878244 -6.049395 -1.707092
#>
#> $df
#> [1] 1
#>