mutate(dev_en=case_when(
dev_encoding.heading=="B"~"B",
dev_encoding.heading=="F"~"F",
dev_encoding.heading=="L"~"S",
dev_encoding.heading=="R"~"S"
))
ggplot(TrialFeature,aes(x=dev_en,y=IRTDifficulty))+
geom_boxplot()
TrialFeature <- TrialFeature%>%
mutate(dev_en=case_when(
dev_encoding.heading=="B"~"B",
dev_encoding.heading=="F"~"F",
dev_encoding.heading=="L"~"S",
dev_encoding.heading=="R"~"S"
))%>%
mutate(dev_map=case_when(
dev_map_heading=="B"~"B",
dev_map_heading=="F"~"F",
dev_map_heading=="L"~"S",
dev_map_heading=="R"~"S"
))
ggplot(TrialFeature,aes(x=dev_map,y=IRTDifficulty))+
geom_boxplot()
ggplot(TrialFeature,aes(x=dev_en,y=IRTDifficulty))+
geom_boxplot()
en_head.aov <- aov(IRTDifficulty ~ dev_en, data = TrialFeature)
summary(en_head.aov)
en_head.aov <- aov(IRTDifficulty ~ dev_map, data = TrialFeature)
summary(en_head.aov)
learn.lm <- lm(IRTDifficulty~learned_Route,data=TrialFeature)
learn.lm <- lm(IRTDifficulty~Learned_Route,data=TrialFeature)
summary(learn.lm)
learn.lm <- lm(IRTDifficulty~Shortcut,data=TrialFeature)
summary(learn.lm)
setwd("~/Documents/Third Year Project/Pointing Task/PointingAngleVisualization")
library(tidyverse)
library(psych)
library(lme4)## for linear mixed model
library(car)## for significance of linear mixed model
library(rcompanion)
library(TAM) ## Rasch Analysis
library(PerformanceAnalytics)
#correlateion
chart.Correlation(TrialFeature[,c(4,5,8,9,10,11,12,13,14,17)], histogram=TRUE, pch=19)
names(TrialFeature)
#correlateion
chart.Correlation(TrialFeature[,c(4,5,8,9,10,11,12,15)], histogram=TRUE, pch=19)
rm(learn.lm)
feature.lm <- lm(IRTDifficulty~Shortcut+TopSeq+TopCenter+TargetSeq,data=TrialFeature)
summary(feature.lm)
feature.lm <- lm(IRTDifficulty~TopSeq+TopCenter+TargetSeq,data=TrialFeature)
summary(feature.lm)
feature.lm <- lm(IRTDifficulty~TopCenter,data=TrialFeature)
summary(feature.lm)
feature.lm <- lm(IRTDifficulty~TopCenter+TopSeq,data=TrialFeature)
summary(feature.lm)
feature.lm <- lm(IRTDifficulty~TopCenter+TargetCenter,data=TrialFeature)
summary(feature.lm)
TrialFeature <- TrialFeature%>%
mutate(Savestep=Learned_Route-Shortcut)
#correlateion
chart.Correlation(TrialFeature[,c(4,5,8,9,10,11,12,15,18)], histogram=TRUE, pch=19)
ggplot(TrialFeature,aes(x=dev_en,y=IRTDifficulty))+
geom_boxplot()
ggplot(TrialFeature,aes(x=dev_map,y=IRTDifficulty))+
geom_boxplot()
ggplot(TrialFeature,aes(x=TopCenter,y=IRTDifficulty,fill=dev_en))+
geom_point()
ggplot(TrialFeature,aes(x=TopCenter,y=IRTDifficulty,))+
geom_point(color=dev_en)
ggplot(TrialFeature,aes(x=TopCenter,y=IRTDifficulty))+
geom_point(color=dev_en)
ggplot(TrialFeature,aes(x=TopCenter,y=IRTDifficulty,color=dev_en))+
geom_point()
ggplot(TrialFeature,aes(x=TargetCenter,y=IRTDifficulty,color=dev_en))+
geom_point()
ggplot(TrialFeature,aes(x=TopCenter,y=IRTDifficulty,color=dev_en))+
geom_point()
ggplot(TrialFeature,aes(x=dev_map,y=IRTDifficulty,color=dev_en))+
geom_boxplot()
ggplot(TrialFeature,aes(x=dev_map,y=IRTDifficulty,color=dev_en))+
geom_point()
ggplot(TrialFeature,aes(x=dev_map,y=IRTDifficulty,color=dev_en,alpha=0.3))+
geom_point()
setwd("~/Documents/2019Summer/SNAG/Carol_Visualization")
library(foreign)
library(ggplot2)
library(RColorBrewer)
library(tidyverse)
YMaze <- read.csv("YoungData.csv")
YMaze_female <- YMaze[YMaze$Gender=="F",]
YMaze_male <- YMaze[YMaze$Gender=="M",]
MMaze<- read.csv("MidAgeData.csv")
MMaze_female<- MMaze[MMaze$Gender=="F",]
MMaze_male<- MMaze[MMaze$Gender=="M",]
length(unique(YMaze_female$SubNum))
length(unique(YMaze_male$SubNum))
length(unique(MMaze_female$SubNum))
length(unique(MMaze_male$SubNum))
pd1 <- as.data.frame(table(MMaze_female$Xcord,MMaze_female$Ycord)/nrow(MMaze_female))
colnames(pd1) <- c("Xcoord","Ycoord","Prop")
pd2 <- as.data.frame(table(MMaze_male$Xcord,MMaze_male$Ycord)/nrow(MMaze_male))
colnames(pd2) <- c("Xcoord","Ycoord","Prop")
pd3 <- as.data.frame(table(YMaze_female$Xcord,YMaze_female$Ycord)/nrow(YMaze_female))
colnames(pd3) <- c("Xcoord","Ycoord","Prop")
pd4 <- as.data.frame(table(YMaze_male$Xcord,YMaze_male$Ycord)/nrow(YMaze_male))
colnames(pd4) <- c("Xcoord","Ycoord","Prop")
pd1 <- cbind(pd1,c(rep("Female",156)),c(rep("MidAge",156)))
colnames(pd1)[4] <- "Gender"
colnames(pd1)[5] <-"Age"
pd2 <- cbind(pd2,c(rep("Male",156)),c(rep("MidAge",156)))
colnames(pd2)[4] <- "Gender"
colnames(pd2)[5] <-"Age"
pd3 <- cbind(pd3,c(rep("Female",156)),c(rep("Young",156)))
colnames(pd3)[4] <- "Gender"
colnames(pd3)[5] <-"Age"
pd4 <- cbind(pd4,c(rep("Male",156)),c(rep("Young",156)))
colnames(pd4)[4] <- "Gender"
colnames(pd4)[5] <-"Age"
MazeDataVisual <- rbind(pd1,pd2,pd3,pd4)
colnames(MazeDataVisual)[3] <- "Exploration_Proprotion"
View(MazeDataVisual)
View(MMaze_female)
#indivudal total moves
MazeExplorTotalMovesF <- MMaze_female%>%
group_by(SubNum)%>%
summarize(
n=n()
)
View(MazeExplorTotalMovesF)
View(MMaze_female)
MazeExplorTotalMovesM <- MMaze_male%>%
group_by(SubNum)%>%
summarize(
n=n()
)
View(MazeExplorTotalMovesM)
#indivudal total moves
MazeExplorTotalMovesF <- MMaze_female%>%
group_by(SubNum)%>%
summarize(
n=n(),
Gender="Female",
Age="Midlife"
)
MazeExplorTotalMovesM <- MMaze_male%>%
group_by(SubNum)%>%
summarize(
n=n(),
Gender="Male",
Age="Midlife"
)
View(MazeExplorTotalMovesF)
View(MazeExplorTotalMovesM)
#indivudal total moves
MazeExplorTotalMovesF <- MMaze_female%>%
group_by(SubNum)%>%
summarize(
n=n(),
Gender="Female",
Age="Midlife"
)
MazeExplorTotalMovesM <- MMaze_male%>%
group_by(SubNum)%>%
summarize(
n=n(),
Gender="Male",
Age="Midlife"
)
MazeExplorTotalMovesYF <- YMaze_female%>%
group_by(SubNum)%>%
summarize(
n=n(),
Gender="Female",
Age="Young"
)
MazeExplorTotalMovesYM <- YMaze_male%>%
group_by(SubNum)%>%
summarize(
n=n(),
Gender="Male",
Age="Young"
)
MazeExplorTotalMoves <- as.data.frame(rbind(MazeExplorTotalMovesF,MazeExplorTotalMovesYF,MazeExplorTotalMovesM,MazeExplorTotalMovesYM))
rm(MazeExplorTotalMovesF)
rm(MazeExplorTotalMovesYF)
rm(MazeExplorTotalMovesM)
rm(MazeExplorTotalMovesYM)
View(MazeExplorTotalMoves)
#indivudal total moves
MazeExplorTotalMovesF <- MMaze_female%>%
group_by(SubNum)%>%
summarize(
Totalmoves=n(),
Gender="Female",
Age="Midlife"
)
MazeExplorTotalMovesM <- MMaze_male%>%
group_by(SubNum)%>%
summarize(
Totalmoves=n(),
Gender="Male",
Age="Midlife"
)
MazeExplorTotalMovesYF <- YMaze_female%>%
group_by(SubNum)%>%
summarize(
Totalmoves=n(),
Gender="Female",
Age="Young"
)
MazeExplorTotalMovesYM <- YMaze_male%>%
group_by(SubNum)%>%
summarize(
Totalmoves=n(),
Gender="Male",
Age="Young"
)
MazeExplorTotalMoves <- as.data.frame(rbind(MazeExplorTotalMovesF,MazeExplorTotalMovesYF,MazeExplorTotalMovesM,MazeExplorTotalMovesYM))
rm(MazeExplorTotalMovesF)
rm(MazeExplorTotalMovesYF)
rm(MazeExplorTotalMovesM)
rm(MazeExplorTotalMovesYM)
write.csv(MazeExplorTotalMoves,"Maze_TotalMoves_Explor.csv")
setwd("~/Documents/Third Year Project/Pointing Task/PointingTaskAnalysis")
library(tidyverse)
library(psych)
library(lme4)## for linear mixed model
library(car)## for significance of linear mixed model
library(rcompanion)
library(TAM) ## Rasch Analysis
library(PerformanceAnalytics)
df <- as.data.frame(read_csv("DSP_19Fall_PointingAngle_Analysis.csv"))
df$Subject <- as.factor(df$Subject)
df$Gender <- as.factor(df$Gender)
df$TrialID <- as.factor(df$TrialID)
df_nomultiple <- df %>% distinct(Subject,Age,Gender,TrialID,.keep_all = T)
df_nomultiple$TrialSeq <- c(rep(seq(1:27),56))
df_nomultiple[df_nomultiple$TrialID=="3",]$TargetAngle <- 195.5
df_nomultiple <- mutate(df_nomultiple,
AngularError2=ifelse(
abs(EstimateAngle-TargetAngle)>180,
360-abs(EstimateAngle-TargetAngle),
abs(EstimateAngle-TargetAngle)))
summary(df_nomultiple$AngularError2)
df_nomultiple%>%
group_by(Gender)%>%
summarise(
number = length(Subject)/27
)
df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2)
)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2)
)
write.csv(file="Trialaverageerror.csv",Trialerror)
View(Trialerror)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2)
)
write.csv(file="Trialerror.csv",Trialerror)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2),
Se_error=se(AngularError2)
)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2),
Count=count(AngularError2),
Se_error=sd(AngularError2)/sqrt(count(AngularErrorse))
)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2),
Count=length(AngularError2),
Se_error=sd(AngularError2)/sqrt(length(AngularErrorse))
)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2),
Count=length(AngularError2),
Se_error=sd(AngularError2)/sqrt(length(AngularErrors2))
)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2),
Count=length(AngularError2),
Se_error=sd(AngularError2)/sqrt(length(AngularError2))
)
#write.csv(file="Trialerror.csv",Trialerror)
View(Trialerror)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2),
Se_error=sd(AngularError2)/sqrt(length(AngularError2))
)
write.csv(file="Trialerror2.csv",Trialerror)
install.packages("simr")
setwd("~/Documents/Third Year Project/Pointing Task/ShortcuttingTaskAnalysis")
library(foreign)
library(TAM)
library(WrightMap)
library(tidyverse)
library(lme4)
library(car)
library(simr)# for power analysis
#library(GGally)
library(PerformanceAnalytics)
setwd("~/Documents/Third Year Project/Pointing Task/PointingTaskAnalysis")
library(tidyverse)
library(psych)
library(lme4)## for linear mixed model
library(car)## for significance of linear mixed model
library(rcompanion)
library(TAM) ## Rasch Analysis
library(PerformanceAnalytics)
library(simr)# for power analysis
df <- as.data.frame(read_csv("DSP_19Fall_PointingAngle_Analysis.csv"))
df$Subject <- as.factor(df$Subject)
df$Gender <- as.factor(df$Gender)
df$TrialID <- as.factor(df$TrialID)
df_nomultiple <- df %>% distinct(Subject,Age,Gender,TrialID,.keep_all = T)
df_nomultiple$TrialSeq <- c(rep(seq(1:27),56))
df_nomultiple[df_nomultiple$TrialID=="3",]$TargetAngle <- 195.5
df_nomultiple <- mutate(df_nomultiple,
AngularError2=ifelse(
abs(EstimateAngle-TargetAngle)>180,
360-abs(EstimateAngle-TargetAngle),
abs(EstimateAngle-TargetAngle)))
summary(df_nomultiple$AngularError2)
df_nomultiple%>%
group_by(Gender)%>%
summarise(
number = length(Subject)/27
)
Trialerror <- df_nomultiple%>%
group_by(TrialID)%>%
summarise(
Average_error=mean(AngularError2),
Sd_error=sd(AngularError2),
Se_error=sd(AngularError2)/sqrt(length(AngularError2))
)
#write.csv(file="Trialerror2.csv",Trialerror)
df_nomultiple$T.AngularError2<-transformTukey(
df_nomultiple$AngularError2,
plotit=FALSE)
hist(df_nomultiple$T.AngularError2)
#the effect of centerailty
df_nomultiple$Top <- as.factor(df_nomultiple$Top)
df_nomultiple$Target <- as.factor(df_nomultiple$Target)
df_nomultiple <-
df_nomultiple %>%
mutate(TargetCenter = case_when(
Target =="well" ~ 8.636,
Target =="chair" ~ 10.273,
Target =="bookshelf" ~ 7.909,
Target =="harp"~ 7.364,
Target =="mailbox" ~ 10.636,
Target =="piano" ~9.727,
Target =="picnic table" ~ 7.182,
Target =="plant" ~ 7.727,
Target =="stove" ~ 10.273,
Target =="telescope" ~ 9.000,
Target =="trash can"~ 8.818,
Target =="wheelbarrow" ~ 6.273))%>%
mutate(TopCenter = case_when(
Top =="well" ~ 8.636,
Top =="chair" ~ 10.273,
Top =="bookshelf" ~ 7.909,
Top =="harp"~ 7.364,
Top =="mailbox" ~ 10.636,
Top =="piano" ~9.727,
Top =="picnic table" ~ 7.182,
Top =="plant" ~ 7.727,
Top =="stove" ~ 10.273,
Top =="telescope" ~ 9.000,
Top =="trash can"~ 8.818,
Top =="wheelbarrow" ~ 6.273))%>%
mutate(TopSeq = case_when(
Top =="well" ~ 12,
Top =="chair" ~ 1,
Top =="bookshelf" ~ 9,
Top =="harp"~ 11,
Top =="mailbox" ~ 2,
Top =="piano" ~7,
Top =="picnic table" ~ 5,
Top =="plant" ~ 4,
Top =="stove" ~ 6,
Top =="telescope" ~ 3,
Top =="trash can"~ 8,
Top =="wheelbarrow" ~ 10))%>%
mutate(TargetSeq = case_when(
Target =="well" ~ 12,
Target =="chair" ~ 1,
Target =="bookshelf" ~ 9,
Target =="harp"~ 11,
Target =="mailbox" ~ 2,
Target =="piano" ~7,
Target =="picnic table" ~ 5,
Target =="plant" ~ 4,
Target =="stove" ~ 6,
Target =="telescope" ~ 3,
Target =="trash can"~ 8,
Target =="wheelbarrow" ~ 10))
cent.eff <- lmer(T.AngularError2 ~ TargetCenter + TopCenter+ (1|Subject), data = df_nomultiple)
summary(cent.eff)
#power analysis:
powerSim(cent.eff)
View(cent.eff)
#power analysis:
powerSim(cent.eff)
polyroot(c(1,-2.5,2,-0.5))
polyroot(c(0.687,-0.687,-1))
polyroot(c(0.687,-1,-0.687))
polyroot(c(-0.687,1,0.687))
6.06*(1-min(polyroot(c(-0.687,1,0.687)))*0.678-min(polyroot(c(-0.687,1,0.687)))^3*0.678-min(polyroot(c(-0.687,1,0.687)))^4)
min(polyroot(c(0.687,-1,-0.687)))
max(1,2)
min(1,2)
polyroot(c(0.687,-1,-0.687))
min(polyroot(c(0.687,-1,-0.687)))
polyroot(c(0.687,-1,-0.687))[2]
6.06*(1-polyroot(c(-0.687,1,0.687))[2]*0.678-polyroot(c(-0.687,1,0.687))[2]^3*0.678-polyroot(c(-0.687,1,0.687))[2]^4)
polyroot(c(-0.687,1,0.687))[2]*0.678
polyroot(c(-0.687,1,0.687))[2]^3
polyroot(c(-0.687,1,0.687))[2]^4
1+1.97*0.678
1.96^3*0.678
1.96^4
$X_t=Z_t+\theta Z_{t-1}$, $\{Z_t\}\sim WN(0,\sigma^2)$, and $Y_t=\tilde{Z}_t+\frac{1}{\theta}\tilde{Z}_{t-1}$, $\{\tilde{Z}_t\}\sim WN(0,\sigma^2\theta^2)$, where $0<|\theta|<1$, have the same autocovariance functions.
\newline
For $\{X_t\}$ with lag k:
\begin{align*}
\gamma_X(k) & = E[(Z_t+\theta Z_{t-1})(Z_{t+k}+\theta Z_{t+k-1})]-E[Z_t+\theta Z_{t-1}]E[Z_{t+k}+\theta Z_{t+k-1}] \\
& = E[Z_tZ_{t+k}+\theta^2Z_{t-1}Z_{t+k-1}+\theta Z_{t-1}Z_{t+k}+\theta Z_{t+k-1}Z_t]+0*0
\end{align*}
((-1.97)^2+(-1.97)^2(1-(-1.97)^2))/(1-(-1.97)^2)
((-1.97)^2+(-1.97)^2*(1-(-1.97)^2))/(1-(-1.97)^2)
6.06*(1-(-1.97)*0.687-(1.97)^2*2.53)
polyroot(c(0.687,-1,-0.687))
1-sqrt(5)/-2
1+sqrt(5)/-2
(0.51^2+0.51^2(1-0.51^2))/(1-0.51^2)
(0.51^2+0.51^2*(1-0.51^2))/(1-0.51^2)
6.06*(1-0.51*0.687-0.51^2*0.61)
sqrt(5)
setwd("~/Documents/MAT259/Homework2/data")
#install.packages("imputeTS")
library(imputeTS)
library(tidyverse)
df <- read.csv("Checkouts copy.csv");
x <- c(1:120)
plot(x,df$novels.,type="l",ylim=c(0,0.0015))
df_fillna = na_interpolation(df, option ="spline")
plot(x,df_fillna$novels.,type="l",ylim=c(0,0.0015))
#install.packages("imputeTS")
library(imputeTS)
library(tidyverse)
df <- read.csv("Checkouts copy 2.csv");
x <- c(1:120)
plot(x,df$novels.,type="l",ylim=c(0,0.0015))
df_fillna = na_interpolation(df, option ="spline")
plot(x,df_fillna$novels.,type="l",ylim=c(0,0.0015))
novel_ts <- ts(df_fillna$novels.,start=2010,f=12)
ts.plot(novel_ts)
novel_decom <- decompose(novel_ts)
plot(novel_decom,xlab="Time in months")
model_novel <- as.data.frame(cbind(novel_decom[[1]],novel_decom[[2]],novel_decom[[3]],novel_decom[[4]]))
colnames(model_novel) <- c("nv_observations","nv_seasonal","nv_trend","nv_random")
plot(x,df$dvds.,type="l",ylim=c(0,0.006))
plot(x,df_fillna$dvds.,type="l",ylim=c(0,0.006))
dvd_ts <- ts(df_fillna$dvds.,start=2010,f=12)
ts.plot(dvd_ts)
dvd_decom <- decompose(dvd_ts)
plot(dvd_decom,xlab="Time in months")
model_dvd <- as.data.frame(cbind(dvd_decom[[1]],dvd_decom[[2]],dvd_decom[[3]],dvd_decom[[4]]))
colnames(model_dvd) <- c("dvd_observations","dvd_seasonal","dvd_trend","dvd_random")
#write.csv(model_dvd,"model_dvd.csv")
year <- NULL
for (i in c(0:9)){year=c(year,rep(2010+i,12))}
month <- c(rep(seq(1:12),10))
model <- as.data.frame(cbind(year,month,model_novel,model_dvd))
model_dvd <- as.data.frame(cbind(dvd_decom[[1]],dvd_decom[[2]],dvd_decom[[3]],dvd_decom[[4]]))
colnames(model_dvd) <- c("dvd_observations","dvd_seasonal","dvd_trend","dvd_random")
year <- NULL
for (i in c(0:9)){year=c(year,rep(2010+i,12))}
month <- c(rep(seq(1:12),10))
model <- as.data.frame(cbind(year,month,model_novel,model_dvd))
write.csv(model,"decompose_model.csv")
