Question

I have data from two time periods (1999 and 2009). The data is in two columns, one called "values" (4.960001, 4.847222, ... 3.639985, 3.849003) and one called "time" (1999, 1999, ..., 2009, 2009):

There are 75,049 values for each year. I'd like to randomly select 30 values (without replacement) from each year and conduct a paired T-test and then input the results into a matrix. I'd like to run that procedure 1,000 times on the same dataset to get a distribution of T-test values. Any ideas on how to do that would be much appreciated! Thanks.

Was it helpful?

Solution

" ....two columns, one called "values" (4.960001, 4.847222, ... 3.639985, 3.849003) and one called "time" (1999, 1999, ..., 2009, 2009)" ..."75,049 values for each year."

Sounds like this could be done with:

 folded <- matrix(dfrm$values, ncol=2)
 replicate( 1000, { pick <- sample(1:75049, 30)
                    t.test(folded[pick, 1], folded[pick,2], paired=TRUE)$statistic
                   } )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top