Learn R Programming

smatr (version 2.1)

smatr: (Standardised) Major Axis Estimation and Testing Routines

Description

This package provides methods of fitting bivariate lines in allometry using the major axis (MA) or standardised major axis (SMA), and for making inferences about such lines. The available methods of inference include confidence intervals and one-sample tests for slope and elevation, testing for a common slope or elevation amongst several allometric lines, constructing a confidence interval for a common slope or elevation, and testing for no shift along a common axis, amongst several samples.

Arguments

Details

The key functions available in this package are the following.

For one sample: [object Object],[object Object],[object Object] For several samples: [object Object],[object Object],[object Object] Options are available for forcing lines through the origin (where appropriate), and all procedures have the option of correcting for measurement error (although only in an approximate fashion, valid in large samples).

Additional features of this package are listed below.

Measurement error estimation: [object Object]

Example datasets: [object Object],[object Object]

For more details, see the documentation for any of the individual functions listed above.

References

Warton D. I. and Weber N. C. (2002) Common slope tests for bivariate structural relationships. Biometrical Journal 44, 161--174.

Warton D. I., Wright I. J., Falster D. S. and Westoby M. (2006) A review of bivariate line-fitting methods for allometry. Biological Reviews (in press)

See Also

line.cis, slope.test, elev.test, slope.com, elev.com, shift.com, meas.est, leaflife, leafmeas

Examples

Run this code
#load the leaflife dataset:
    data(leaflife)

    #consider only the low rainfall sites:
    leaf.low.rain=leaflife[leaflife$rain=='low',]

    #construct a plot
    plot(log10(leaf.low.rain$lma), log10(leaf.low.rain$longev), xlab='leaf mass per area [log scale]', ylab='leaf longevity [log scale]')

    #test if the SMA slope amongst species at low rainfall sites is 1, for log (base 10) transformed data:
    slope.test(log10(longev), log10(lma), data=leaf.low.rain)
    
    #test if the MA slope is 2/3
    slope.test(log10(longev), log10(lma), data=leaf.low.rain, test.value = 2/3, method = 'MA')

    #produce CI's for MA slope and elevation:
    line.cis(log10(longev),log10(lma),data=leaf.low.rain, method=2)

    #now construct a scatterplot, with different colours for different sites
    plot(leaflife$lma,leaflife$longev,type="n",xlab="leaf mass per area [log scale]",ylab="leaf longevity [log scale]",log="xy")
    colours <- c("blue", "red", "green", "yellow")
    points(leaflife$lma,leaflife$longev,col=colours[as.numeric(leaflife$site)])
    legend(55,5,as.character(unique(leaflife$site)),col=colours,pch=rep(1,4))

    #test for a common SMA slope amongst species from sites with different rainfall/nutrients:
    fit.slopes <- slope.com(log10(longev), log10(lma), site, data = leaflife)

    #Test for common SMA slope amongst species at low rainfall sites with different levels of soil nutrients
    slope.com(log10(longev), log10(lma), soilp, data=leaf.low.rain)
    
    #Now test for common elevation of the groups fitted with an axis of common slope, at low rainfall sites:
    elev.com(log10(longev), log10(lma), soilp, data = leaf.low.rain)

    #Now test for no shift along the axes of common slope, for sites with different soil nutrient levels but low rainfall:
    shift.com(log10(longev), log10(lma), soilp, data=leaf.low.rain)

    #Test for common major axis slope, and construct 90% confidence intervals for common slope and each separate slope:
    slope.com(log10(longev), log10(lma), site, data=leaflife, method="MA", alpha=0.1)

    #Test for common elevation amongst the MA's of common slope, for low rainfall sites, and construct 99% confidence intervals for all elevation estimates:
    elev.com(log10(longev), log10(lma), soilp, method="MA", data = leaf.low.rain, alpha=0.01)

Run the code above in your browser using DataLab