Learn R Programming

Morpho (version 2.1)

RegScore: calulate regression scores for linear model

Description

calulate regression scores for linear model as specified in Drake & Klingenberg(2008)

Usage

RegScore(model, x = NULL)

Arguments

model
linear model
x
optional: matrix containing new data to be projected onto the regression lines.

Value

  • returns a n x m matrix containing the regression scores for each specimen.

Warning

when model contains factors with more than 2 levels, R calculates one regression line per 2 factors. Check the colnames of the returned matrix to select the appropriate one. See examples for details.

Details

the data are orthogonally projected onto the regression lines associated with each factor.

References

Drake, AG. & Klingenberg, CP. The pace of morphological change: historical transformation of skull shape in St Bernard dogs. Proceedings of the Royal Society B: Biological Sciences, The Royal Society, 2008, 275, 71-76.

Examples

Run this code
model <- lm(as.matrix(iris[,1:2]) ~ iris[,3])
rs <- RegScore(model)
plot(rs,iris[,4])
data(boneData)
proc <- procSym(boneLM)
pop.sex <- name2factor(boneLM,which=3:4) # generate a factor with 4 levels
lm.ps.size <- lm(proc$PCscores ~ pop.sex+proc$size)
rs <- RegScore(lm.ps.size)
colnames(rs) # in this case, the last column contains the regression
# scores associated with proc$size

Run the code above in your browser using DataLab