This is the key function in the smatr-package; all the key
estimation and testing functionality in the package can all be accessed
using this function, via different usages of the formula and other
arguments, as described below.
One-sample testing The below options allow estimation of a (S)MA,
confidence intervals for parameters, and hypothesis testing of parameters,
from a single sample of two variables y and x. Use the
sma function to fit a standardised major axis (SMA), or use ma
in combination with the below options in order to fit major axis (MA)
instead.
- list("sma(y~x)")
Fits a SMA and constructs
confidence intervals for the true slope and elevation. Replaces the
line.cis function from previous versions of smatr.
- list("ma(y~x)")
Fits a MA and constructs confidence intervals for
the true slope and elevation. All the below functions also work for MA, if
the ma function is called instead of the sma function.
- list("sma(y~x, slope.test=B)")
Tests if the slope of a SMA equals
B.
- list("sma(y~x, elev.test=A)")
Tests if the elevation of
a SMA equals A.
- list("sma(y~x, robust=T)")
Fits a SMA using
Huber's M estimation and constructs confidence intervals for the true slope
and elevation. This offers robustness to outliers in estimation and
inference, and can be used in combination with the slope.test and
elev.test arguments.
- list("sma(y~x-1)")
Fits a SMA where
the line is forced through the origin, and constructs confidence intervals
for the true slope. This type of formula can be used in combination with the
slope.test argument.
For several samples: The below options allow estimation of several
(S)MA lines, confidence intervals for parameters, and hypothesis testing of
parameters, from two variables y and x for observations that
have been classified into several different samples using the factor
groups. Use the sma function to fit a standardised major axis
(SMA), or use the ma in combination with the below options in order
to fir major axis (MA) instead.
- list("sma(y~x*groups)")
Test if several SMA lines share a common slope, and construct a confidence
interval for the true common slope.
- list("sma(y~x+groups,
type="elevation")")
Test if several common slope SMA lines also share a
common elevation, and construct a confidence interval for the true common
elevation.
- list("sma(y~x+groups, type="shift")")
Test if several
groups of observations have no shift in location along common slope SMA
lines.
- list("sma(y~x*groups, slope.test=B)")
Test if several SMA
lines share a common slope whose true value is exactly equal to B.
- list("sma(y~x+groups, elev.test=A)")
Test if several common-slope
SMA lines share a common elevation whose true value is exactly equal to
A.
- list("sma(y~x*groups-1)")
Test if several SMA lines
forced through the origin share a common slope. This can also be used in
combination with the slope.test argument or when testing for no shift
along common (S)MA lines.
In all cases, estimates and confidence intervals for key parameters are
returned, and if a hypothesis test is done, results will be returned and
stored in the slope.test or elev.test output arguments.
The plot function can be applied to objects produced using the
sma and ma functions, which is highly recommended to visualise
results and check assumptions.
Multiple comparisons If multcomp=TRUE, pair-wise comparisons are made
between levels of the grouping variable for differences in slope, elevation
or shift, depending on the formula used. The P values can be adjusted for
multiple comparisons (using the Sidak correction). See also
multcompmatrix for visualization of the results.
Warning: When using the multiple comparisons (multcomp=TRUE), you
must specify a data statement. If your variables are not in a
dataframe, simply combine them in a dataframe before calling sma.