Skip to contents

lm2 is used to fit bidimensional linear regression models using Euclidean and Affine transformations following the approach by Tobler (1965).

Usage

lm2(formula, data, transformation)

Arguments

formula

a symbolic description of the model to be fitted in the format A + B ~ C + D, where A and B are dependent and C and D are 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:

transformation

string with the transformation type (euclidean, affine, or projective)

npredictors

number of predictors used in the model: 4 for euclidean, 6 for affine, 8 for projective.

df_model, df_residual

degrees of freedom for the model and for the residuals

transformation_matrix

3x3 transformation matrix

coeff

transformation coefficients, with a denoting the intercept terms.

transformed_coeff

scale, angle, and sheer coefficients, depends on transformation.

fitted_values

data frame containing fitted values for the original data set

residuals

data frame containing residuals for the original fit

r.squared, adj.r.squared

R-squared and adjusted R-squared.

F, p.value

F-statistics and the corresponding p-value, given the df_model and df_residual degrees of freedom.

dAIC

Akaike 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_index

Distortion index following Waterman and Gordon (1984), as adjusted by Friedman and Kohler (2003)

lm

an underlying linear model for Euclidean and affine transformations.

formula

formula, describing input and output columns

data

data used to fit the model

Call

function call information, incorporates the formula, transformation, and data.

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*