I am getting an error that is stating "(subscript) logical subscript too long. Traceback: median(permsamples2.91[business2.91$yrqtr == "20201", i]).
I am attempting to do a permutation test that looks at the difference in median wages between 2019Q1 and 2020Q1. Below is a sample of my code and some of the details wit it.
business2.91<-rbind(business.20122.27, business.20122.31)
set.seed(20204)
p<-100000
n2.91<-length(business2.91)
variable2.91<-business2.91$wage.adjusted
permsamples2.91<- matrix(0,nrow=n2.91, ncol=p)
for(i in 1:p){
permsamples2.91[,i] <- sample(variable2.91, size= n2.91, replace=FALSE)
}
perm.test.stat2.91<-rep(0,p)
for (i in 1:p){
# calculate the perm-test-stat2 and save it
perm.test.stat2.91[i] <- abs( median(permsamples2.91[business2.91$yrqtr=='20201',i]) -
median(permsamples2.91[business2.91$yrqtr=="20191",i]) )
}
For business.2.91 there are 617 rows that have 20201 as their yrqtr while 20191 has 582 rows. Is the discrepancy is rows the issue?