pacckages
if(!require(FSA)){install.packages("FSA")}
if(!require(psych)){install.packages("psych")}
if(!require(lme4)){install.packages("lme4")}
if(!require(lmerTest)){install.packages("lmerTest")}
if(!require(nlme)){install.packages("nlme")}
if(!require(car)){install.packages("car")}
#
library(googlesheets4); gs4_deauth()
library(AICcmodavg)
library(ggplot2)
library(lme4)
library(psych)
sheet="Hoja4"
range="A1:C33"
hands <- read_sheet("https://docs.google.com/spreadsheets/d/1CMPY0Bjm6Kc3XUq0mZtgIoyXAacdWVkv2KONh0T-inU/edit?usp=sharing",
col_names = TRUE,
sheet=sheet,
range=range,
col_types = NULL,
na= "NA")
## Reading from "Regres_datos"
## Range "'Hoja4'!A1:C33"
hands$Hand <- as.factor(hands$Hand)
hands$Individual <- as.factor(hands$Individual)
dim(hands)
## [1] 32 3
headTail(hands)
## Individual Hand Length
## 1 A Left 17.5
## 2 B Left 18.4
## 3 C Left 16.2
## 4 D Left 14.5
## 5 <NA> <NA> ...
## 6 M Right 19.5
## 7 N Right 16.5
## 8 O Right 17.4
## 9 P Right 15.6
str(hands)
## tibble [32 x 3] (S3: tbl_df/tbl/data.frame)
## $ Individual: Factor w/ 16 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ Hand : Factor w/ 2 levels "Left","Right": 1 1 1 1 1 1 1 1 1 1 ...
## $ Length : num [1:32] 17.5 18.4 16.2 14.5 13.5 18.9 19.5 21.1 17.8 16.8 ...
summary(hands)
## Individual Hand Length
## A : 2 Left :16 Min. :13.50
## B : 2 Right:16 1st Qu.:16.35
## C : 2 Median :17.50
## D : 2 Mean :17.48
## E : 2 3rd Qu.:18.90
## F : 2 Max. :21.50
## (Other):20
p <- ggplot(data=hands,
aes(x=Hand, y= Length, col=Hand ))
p +
geom_boxplot(aes(col=Hand))
Length ~ HandIndividual nos dice que no hay diferencias entre el largo de las manos. Como se ve en la figura de arribaaov <- aov(Length ~ Hand, data=hands)
summary(aov)
## Df Sum Sq Mean Sq F value Pr(>F)
## Hand 1 0.45 0.451 0.117 0.734
## Residuals 30 115.27 3.842
##
p <- ggplot(data=hands,
aes(x=Hand, y= Length, col=Individual ))
p +
geom_point(size=3,position = position_jitter(width= 0.1, height=0))
Length ~ Hand + (1|Individual)individuo. Se logra detectar que s[i hay diferencia entre el largo de la mano derecha y la izquierdamixed.Model = lmer(Length ~ Hand + (1|Individual),
data=hands, REML=TRUE)
anova(mixed.Model)
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Hand 0.45125 0.45125 1 15 11.497 0.004034 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
mixed.Model.glm = glmer(Length ~ Hand + (1|Individual),
data=hands)
## Warning in glmer(Length ~ Hand + (1 | Individual), data = hands): calling
## glmer() with family=gaussian (identity link) as a shortcut to lmer() is
## deprecated; please call lmer() directly
summary(mixed.Model.glm)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Length ~ Hand + (1 | Individual)
## Data: hands
##
## REML criterion at convergence: 72.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.39345 -0.49825 -0.05118 0.54100 1.31960
##
## Random effects:
## Groups Name Variance Std.Dev.
## Individual (Intercept) 3.80304 1.9501
## Residual 0.03925 0.1981
## Number of obs: 32, groups: Individual, 16
##
## Fixed effects:
## Estimate Std. Error t value
## (Intercept) 17.35625 0.49004 35.418
## HandRight 0.23750 0.07004 3.391
##
## Correlation of Fixed Effects:
## (Intr)
## HandRight -0.071