lm2 is used to fit bidimensional linear regression models using Euclidean and Affine transformations following the approach by Tobler (1965).
Arguments
- formula
a symbolic description of the model to be fitted in the format
A + B ~ C + D, whereAandBare dependent andCandDare independent variables- data
a data frame containing variables for the model.
- transformation
the transformation to be used, either
'euclidean','affine', or'projective'.
Value
lm2 returns an object of class "lm2". An object of class "lm" is a list containing at least the following components:
transformationstring with the transformation type (
euclidean,affine, orprojective)npredictorsnumber of predictors used in the model: 4 for euclidean, 6 for affine, 8 for projective.
df_model, df_residualdegrees of freedom for the model and for the residuals
transformation_matrix3x3transformation matrixcoefftransformation coefficients, with
adenoting the intercept terms.transformed_coeffscale,angle, andsheercoefficients, depends on transformation.fitted_valuesdata frame containing fitted values for the original data set
residualsdata frame containing residuals for the original fit
r.squared, adj.r.squaredR-squared and adjusted R-squared.
F, p.valueF-statistics and the corresponding p-value, given the
df_modelanddf_residualdegrees of freedom.dAICAkaike Information Criterion (AIC) difference between the regression model and the null model. A negative values indicates that the regression model is better. See Nakaya (1997).
distortion_indexDistortion index following Waterman and Gordon (1984), as adjusted by Friedman and Kohler (2003)
lman underlying linear model for
Euclideanandaffinetransformations.formulaformula, describing input and output columns
datadata used to fit the model
Callfunction call information, incorporates the
formula,transformation, anddata.
Examples
lm2euc <- lm2(depV1 + depV2 ~ indepV1 + indepV2, NakayaData, 'euclidean')
lm2aff <- lm2(depV1 + depV2 ~ indepV1 + indepV2, NakayaData, 'affine')
lm2prj <- lm2(depV1 + depV2 ~ indepV1 + indepV2, NakayaData, 'projective')
anova(lm2euc, lm2aff, lm2prj)
#> Bidimensional regression:
#> dAIC df1 df2 F p.value
#> euclidean vs. affine -13.29021 2 32 9.2189 0.0006891 ***
#> euclidean vs. projective -11.66134 4 30 5.0825 0.0030072 **
#> affine vs. projective 1.62887 2 30 0.9658 0.3922043
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
predict(lm2euc)
#> depV1 depV2
#> 1 -0.10714634 0.7355034
#> 2 0.76751919 0.1777630
#> 3 0.71377356 1.5461024
#> 4 0.97343384 0.8287322
#> 5 2.32044682 -0.1858853
#> 6 3.66895537 -0.8335199
#> 7 -1.10962809 1.7756851
#> 8 -1.16310065 1.2187896
#> 9 -1.63076109 1.8346422
#> 10 0.11495606 -0.4178982
#> 11 0.90314950 -0.6598266
#> 12 1.82560030 -0.8248245
#> 13 -0.07100152 -0.8971433
#> 14 1.60705225 -1.8426904
#> 15 -0.19372050 -2.8581066
#> 16 0.62693595 -2.6027024
#> 17 2.68465593 0.8439124
#> 18 3.51168672 0.2106835
#> 19 2.11119272 1.9577835
summary(lm2euc)
#> Call:
#> lm2.formula(formula = depV1 + depV2 ~ indepV1 + indepV2, data = NakayaData, transformation = "euclidean")
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> a1 0.140769 0.095863 1.4684 0.1512
#> a2 -0.010582 0.095863 -0.1104 0.9127
#> b1 1.348680 0.064359 20.9557 < 2.2e-16 ***
#> b2 0.565693 0.064359 8.7897 2.848e-10 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Transformed coefficients:
#> scale1 scale2 angle
#> 1.4625 1.4625 0.3972
#>
#> Distortion index:
#> Dependent Independent
#> Distortion distance, squared 5.169255 0.000
#> Maximal distortion distance, squared 83.680948 36.706
#> Distortion index, squared 0.061773 0.000
#>
#> Multiple R-squared: 0.9382266 Adjusted R-squared: 0.8906729
#> F-statistic: 258.1994 on 2 and 34 DF, p-value: < 2.22e-16
#> Difference in AIC to the null model: -101.8027*