Version: 2.0.1
Date: 2022-02-17
Title: Calculates the Bidimensional Regression Between Two 2D Configurations
Imports: Formula, methods
Depends: R (≥ 4.1.0)
Description: Calculates the bidimensional regression between two 2D configurations following the approach by Tobler (1965).
License: GPL-3
URL: https://CRAN.R-project.org/package=BiDimRegression/, https://github.com/alexander-pastukhov/bidim-regression/, https://alexander-pastukhov.github.io/bidim-regression/
BugReports: https://github.com/alexander-pastukhov/bidim-regression/issues/
Encoding: UTF-8
NeedsCompilation: no
Repository: CRAN
RoxygenNote: 7.1.2
LazyData: true
Suggests: testthat, knitr, rmarkdown, dplyr, ggplot2
VignetteBuilder: knitr
Packaged: 2022-02-17 12:16:04 UTC; sasha
Author: Claus-Christian Carbon ORCID iD [aut], Alexander Pastukhov ORCID iD [aut, cre]
Maintainer: Alexander Pastukhov <pastukhov.alexander@gmail.com>
Date/Publication: 2022-02-17 13:02:10 UTC

Calculates the bidimensional regression between two 2D configurations

Description

Calculates the bidimensional regression between two 2D configurations using both Euclidean and Affine transformations following the approach by Tobler (1965). This function assumes strict data format and returns all coefficients and statistics in a single structure. Same functionality is now re-implemented in a R-friendly style, see lm2 function.

Usage

BiDimRegression(coord)

Arguments

coord

table that must contain two columns for dependent variables (named depV1 and depV2) and two columns for independent variables (named indepV1 and indepV2).

Value

an S3 class BiDimRegression containing all essential measures of the bidimensional regression

See Also

lm2

Examples

resultingMeasures <- BiDimRegression(NakayaData)
print(resultingMeasures)


Data from Carbon, C. C. (2013). BiDimRegression: Bidimensional Regression Modeling Using R. \ Journal of Statistical Software, Code Snippets, 52(1), 1-11 (URL http://www.jstatsoft.org/v52/c01/)\

Description

Example 1 from the domain of aesthetics to show how the method can be utilized for assessing the similarity of two portrayed persons, actually the Mona Lisa in the world famous Louvre version and the only recently re-discovered Prado version

Usage

data(CarbonExample1Data)

Format

A data frame with 36 observations on the following 4 variables.

depV1

a numeric vector

depV2

a numeric vector

indepV1

a numeric vector

indepV2

a numeric vector

Examples

data(CarbonExample1Data)
## maybe str(CarbonExample1Data) ; plot(CarbonExample1Data) ...

Data from Carbon, C. C. (2013). BiDimRegression: Bidimensional Regression Modeling Using R. \ Journal of Statistical Software, Code Snippets, 52(1), 1-11 (URL http://www.jstatsoft.org/v52/c01/)\

Description

Example 2 originates from the area of geography and inspects the accuracy of different maps of the city of Paris which were created over the last 350 years as compared to a recent map

Usage

data(CarbonExample2Data)

Format

A data frame with 13 observations on the following 4 variables.

depV1

a numeric vector

depV2

a numeric vector

indepV1

a numeric vector

indepV2

a numeric vector

Examples

data(CarbonExample2Data)
## maybe str(CarbonExample2Data) ; plot(CarbonExample2Data) ...

Data from Carbon, C. C. (2013). BiDimRegression: Bidimensional Regression Modeling Using R. \ Journal of Statistical Software, Code Snippets, 52(1), 1-11 (URL http://www.jstatsoft.org/v52/c01/)\

Description

Example 3 focuses on demonstrating how good a cognitive map recalculated from averaged cognitive distance data fits with a related real map

Usage

data(CarbonExample3Data)

Format

A data frame with 10 observations on the following 4 variables.

depV1

a numeric vector

depV2

a numeric vector

indepV1

a numeric vector

indepV2

a numeric vector

Examples

data(CarbonExample3Data)
## maybe str(CarbonExample3Data) ; plot(CarbonExample3Data) ...

Eye gaze calibration data

Description

A dataset containing a monocular eye gaze recording with calibration sequence. Courtesy of Bamberger Baby Institut (BamBI).

Usage

EyegazeData

Format

A data frame with 365 rows and 6 variables:

time

sample timestamp, in milliseconds

x, y

recorded gaze, in internal eye tracker units

target_x, target_y

location of the calibration target on the screen, in pixels

target

index of the target within the sequence

...


Data from Friedman, A., & Kohler, B. (2003). Bidimensional regression: Assessing the configural similarity and accuracy of cognitive maps and other two-dimensional data sets. Psychological Methods, 8(4), 468-491.

Description

Data from Friedman, A., & Kohler, B. (2003). Bidimensional regression: Assessing the configural similarity and accuracy of cognitive maps and other two-dimensional data sets. Psychological Methods, 8(4), 468-491.

Usage

data(FriedmanKohlerData1)

Format

A data frame with 4 observations on the following 4 variables.

depV1

a numeric vector

depV2

a numeric vector

indepV1

a numeric vector

indepV2

a numeric vector

Examples

data(FriedmanKohlerData1)
## maybe str(FriedmanKohlerData1) ; plot(FriedmanKohlerData1) ...

Data from Friedman, A., & Kohler, B. (2003). Bidimensional regression: Assessing the configural similarity and accuracy of cognitive maps and other two-dimensional data sets. Psychological Methods, 8(4), 468-491.

Description

Data from Friedman, A., & Kohler, B. (2003). Bidimensional regression: Assessing the configural similarity and accuracy of cognitive maps and other two-dimensional data sets. Psychological Methods, 8(4), 468-491.

Usage

data(FriedmanKohlerData2)

Format

A data frame with 4 observations on the following 4 variables.

depV1

a numeric vector

depV2

a numeric vector

indepV1

a numeric vector

indepV2

a numeric vector

Examples

data(FriedmanKohlerData2)
## maybe str(FriedmanKohlerData2) ; plot(FriedmanKohlerData2) ...

Data from Nakaya, T. (1997). Statistical inferences in bidimensional regression models. Geographical Analysis, 29(2), 169-186.

Description

Data from Nakaya, T. (1997). Statistical inferences in bidimensional regression models. Geographical Analysis, 29(2), 169-186.

Usage

data(NakayaData)

Format

A data frame with 19 observations on the following 4 variables.

depV1

a numeric vector

depV2

a numeric vector

indepV1

a numeric vector

indepV2

a numeric vector

Examples

data(NakayaData)
## maybe str(NakayaData) ; plot(NakayaData) ...

Anova for lm2 objects

Description

Anova for lm2 objects, returns a table with pairwise comparisons between models or, if only one model was supplied, with the null model.

Usage

## S3 method for class 'lm2'
anova(object, ...)

Arguments

object

an object of class "lm2"

...

further objects of class "lm2"

Value

an anova data frame

See Also

lm2

Examples

lm2euc <- lm2(depV1+depV2~indepV1+indepV2, NakayaData, transformation = 'Euclidean')
lm2aff <- lm2(depV1+depV2~indepV1+indepV2, NakayaData, transformation = 'Affine')
anova(lm2euc, lm2aff)

Fitting Bidimensional Regression Models

Description

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.

See Also

anova.lm2 BiDimRegression

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)
predict(lm2euc)
summary(lm2euc)

Computes model for the affine transformation

Description

Computes model for the affine transformation

Usage

lm2affine(data)

Arguments

data

the preprocessed data frame from lm2 function, so that the first two columns are the dependent variables and the other two are independent variables

Value

object with transformation specific data to be supplemented with further stats


Computes model for the euclidean transformation

Description

Computes model for the euclidean transformation

Usage

lm2euclidean(data)

Arguments

data

the preprocessed data frame from lm2 function, so that the first two columns are the dependent variables and the other two are independent variables

Value

object with transformation specific data to be supplemented with further stats


Fits the specified model and computes stats

Description

Calls a specific transformation model function and then computes statistics that is common across all transformations. This function should not be called directly, please use lm2.

Usage

lm2fit(data, transformation)

Arguments

data

the preprocessed data frame from lm2 function, so that the first two columns are the dependent variables and the other two are independent variables

transformation

the transformation to be used, either 'euclidean' or 'affine'.

Value

returns an object of class "lm2", see lm2 for the description.


Computes model for the projective transformation

Description

Computes model for the projective transformation

Usage

lm2projective(data)

Arguments

data

the preprocessed data frame from lm2 function, so that the first two columns are the dependent variables and the other two are independent variables

Value

object with transformation specific data to be supplemented with further stats


Predict method for Bidimensional Regression Model Fits

Description

Predicted values based on the bidimensional regressional model object.

Usage

## S3 method for class 'lm2'
predict(object, newdata, ...)

Arguments

object

an object of class "lm2"

newdata

An optional two column data frame with independent variables. If omitted, the fitted values are used.

...

optional arguments

Value

a two column data frame with predicted values for dependent variables.

See Also

lm2

Examples

lm2euc <- lm2(depV1+depV2~indepV1+indepV2, NakayaData, transformation = 'Euclidean')
predict(lm2euc, NakayaData[, 3:4])

Makes a lightweight summary lm2 object

Description

Drops heavy bits, like the data frame with predicted values or the lm object. However, the print tells more! :)

Usage

## S3 method for class 'lm2'
summary(object, ...)

Arguments

object

an object of class "lm2", see lm2