setwd('~m/Dropbox/Documentos R/Datos')

billtips<-read.csv("MULT REGR BILL TIP LENGTH 2012")
allbt<-billtips
# str(billtips)


billtips<-subset(allbt,billtips$age.at.pic=="A")
billtips<-subset(billtips,billtips$sex=="M")
## Loading required package: plyr

plot of chunk unnamed-chunk-2

sma(billtips$sideview~ billtips$Weight,method="SMA",log="xy")
## Call: sma(formula = billtips$sideview ~ billtips$Weight, log = "xy", 
##     method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation   slope
## estimate        8.048 -10.746
## lower limit     6.054 -13.573
## upper limit    10.043  -8.508
## 
## H0 : variables uncorrelated
## R-squared : 0.007886 
## P-value : 0.46

plot of chunk unnamed-chunk-4

sma(billtips$sideview~billtips$tarsus,method="SMA",log="xy")
## Call: sma(formula = billtips$sideview ~ billtips$tarsus, log = "xy", 
##     method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation  slope
## estimate        5.309 -7.519
## lower limit     3.963 -9.491
## upper limit     6.656 -5.956
## 
## H0 : variables uncorrelated
## R-squared : 0.01305 
## P-value : 0.34

plot of chunk unnamed-chunk-6

sma(billtips$sideview~billtips$Flatened,method="SMA",log="xy")
## Call: sma(formula = billtips$sideview ~ billtips$Flatened, log = "xy", 
##     method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation slope
## estimate       -36.66 20.29
## lower limit    -45.23 16.06
## upper limit    -28.10 25.65
## 
## H0 : variables uncorrelated
## R-squared : 0.00323 
## P-value : 0.63

plot of chunk unnamed-chunk-8

sma(billtips$sideview~billtips$bill.l,method="SMA",log="xy")
## Call: sma(formula = billtips$sideview ~ billtips$bill.l, log = "xy", 
##     method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation slope
## estimate       -26.15 16.35
## lower limit    -32.17 12.97
## upper limit    -20.13 20.61
## 
## H0 : variables uncorrelated
## R-squared : 0.02429 
## P-value : 0.19

Exposed culmen allometry

Wing length

plot of chunk unnamed-chunk-10plot of chunk unnamed-chunk-10

sma(billtips$bill.l~billtips$Flatened,method="SMA",log="xy")
## Call: sma(formula = billtips$bill.l ~ billtips$Flatened, log = "xy", 
##     method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation  slope
## estimate      -0.6431 1.2413
## lower limit   -1.1541 0.9878
## upper limit   -0.1321 1.5598
## 
## H0 : variables uncorrelated
## R-squared : 0.05192 
## P-value : 0.053

Tarsus

plot of chunk unnamed-chunk-12plot of chunk unnamed-chunk-12

sma(billtips$bill.l~billtips$tarsus,method="SMA",log="xy")
## Call: sma(formula = billtips$bill.l ~ billtips$tarsus, log = "xy", 
##     method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation  slope
## estimate        1.225 0.4599
## lower limit     1.142 0.3641
## upper limit     1.307 0.5810
## 
## H0 : variables uncorrelated
## R-squared : 0.006995 
## P-value : 0.48

Body mass

plot of chunk unnamed-chunk-14plot of chunk unnamed-chunk-14

sma(billtips$bill.l~billtips$Weight,method="SMA",log="xy")
## Call: sma(formula = billtips$bill.l ~ billtips$Weight, log = "xy", 
##     method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation  slope
## estimate       1.0573 0.6573
## lower limit    0.9366 0.5217
## upper limit    1.1780 0.8283
## 
## H0 : variables uncorrelated
## R-squared : 0.02871 
## P-value : 0.15

PCA

str(billtips)
## 'data.frame':    73 obs. of  10 variables:
##  $ X         : int  45 48 49 50 51 53 58 63 68 69 ...
##  $ sex       : Factor w/ 2 levels "F","M": 2 2 2 2 2 2 2 2 2 2 ...
##  $ age.at.pic: Factor w/ 4 levels "?","A","J","J?": 2 2 2 2 2 2 2 2 2 2 ...
##  $ bill.l    : num  40.8 39.8 39.8 39.6 39.5 ...
##  $ sideview  : num  0.309 0.419 0.613 0.277 0.45 ...
##  $ Weight    : num  6.15 5.54 5.89 6.1 6.68 5.68 6.35 6.1 6.11 6.45 ...
##  $ Flatened  : num  62 61.5 63 65 60 61.5 63.5 61 61 61.5 ...
##  $ unflatened: num  61 61 61.5 64 59 61 63 61 60.5 61 ...
##  $ DFA       : num  3.86 2.12 3.48 4.78 3.07 ...
##  $ tarsus    : num  5.61 5.26 5.5 5.38 6.38 5.32 6.25 5.72 5.89 5.84 ...
pca<-princomp(log(billtips[,c(5:7,10)]),cor=TRUE)
summary(pca)
## Importance of components:
##                        Comp.1 Comp.2 Comp.3 Comp.4
## Standard deviation     1.1879 1.0278 0.9467 0.7978
## Proportion of Variance 0.3528 0.2641 0.2240 0.1591
## Cumulative Proportion  0.3528 0.6169 0.8409 1.0000
pca$loadings
## 
## Loadings:
##          Comp.1 Comp.2 Comp.3 Comp.4
## sideview  0.316 -0.573  0.756       
## Weight   -0.667 -0.163  0.180 -0.705
## Flatened        -0.803 -0.572  0.133
## tarsus   -0.668         0.263  0.696
## 
##                Comp.1 Comp.2 Comp.3 Comp.4
## SS loadings      1.00   1.00   1.00   1.00
## Proportion Var   0.25   0.25   0.25   0.25
## Cumulative Var   0.25   0.50   0.75   1.00

plot of chunk unnamed-chunk-17plot of chunk unnamed-chunk-17

pc1<-pca$scores[,1]+abs(min(pca$scores[,1]))+0.1
sma(billtips$bill.l~pc1,method="SMA",log="xy")
## Call: sma(formula = billtips$bill.l ~ pc1, log = "xy", method = "SMA") 
## 
## Fit using Standardized Major Axis 
## 
## These variables were log-transformed before fitting: xy 
## 
## Confidence intervals (CI) are at 95%
## 
## ------------------------------------------------------------
## Coefficients:
##             elevation    slope
## estimate        1.589 -0.04351
## lower limit     1.584 -0.05482
## upper limit     1.594 -0.03452
## 
## H0 : variables uncorrelated
## R-squared : 0.02818 
## P-value : 0.16