0

I have data where there are numeric values (can be 0 also)for corresponding weekdays (1=monday, 2=tuesday, 7=sunday etc). I want to find out if my values (say, for temperature for example) depends on a weekday (like bigger values on mondays and smaller on sundays) by different statistical tests. I have simulated data but also measured. How can I test this possible dependence by kruskal-wallis test?

weekday    var
1       2.530400e+00  
4       8.576923e-09   
6       2.530400e+00   
1       7.541218e-06    
2       2.530400e+00    
1       4.360349e+01...

And second thing; By this table, is a weekday or "temperature" my dependent variable and what nature are they (ordinal, categorical..)?

Data:

df <- structure(list(weekday = c(1, 4, 6, 1, 2, 1), var = c(2.5304, 
8.576923e-09, 2.5304, 7.541218e-06, 2.5304, 43.60349)), .Names = c("weekday", 
"var"), row.names = c(NA, -6L), class = "data.frame")
Christoph
  • 6,841
  • 4
  • 37
  • 89
  • I am not sure, what your problem is. Concerning dates try `t <- 2.530400e+00` `date <- lubridate::ymd_hms(as.POSIXct(t, origin = "2016-01-01"))` and finally `lubridate::wday(date, label = T, abbr = T)` – Christoph Jul 08 '16 at 07:45
  • Well maybe I was somehow unclear. I would like to find out, how my measured variable depends on a weekday and I am trying to find out, how to do that by different methods. I have done some visual analysis like boxplots grouped by weekday, finding out averages for every weekday etc. – praseodyymi Jul 08 '16 at 07:56
  • Perhaps just read [(1)](http://stackoverflow.com/help/how-to-ask) how do I ask a good question, [(2)](http://stackoverflow.com/help/mcve) How to create a MCVE as well as [(3)](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610) how to provide a minimal reproducible example in R. ;-) – Christoph Jul 08 '16 at 08:20
  • any better? Unfortunately i dont have any code for this because at first I would like to know what kind of data input should I give to t.test and kruskal.test for example – praseodyymi Jul 08 '16 at 09:10
  • thanks for editing @Christoph. From where can I find help about how to put codes/data etc to those color blocks? I just started to use stackoverflow – praseodyymi Jul 08 '16 at 11:04
  • Just start to edit my edit and you will find some basic help and [here](http://stackoverflow.com/editing-help) – Christoph Jul 08 '16 at 11:10

1 Answers1

0

Without going into the package I tried stats::t.test(df$weekday, df$var). Does that look reasonable with the data given in your question?

Christoph
  • 6,841
  • 4
  • 37
  • 89
  • it gives reasonable results. By the documentation for t.test (http://127.0.0.1:20693/library/stats/html/t.test.html) there is also this "formula" usage, where the formula is explained as "a formula of the form lhs ~ rhs where lhs is a numeric variable giving the data values and rhs a factor with two levels giving the corresponding groups". What does this "factor with two levels"- mean? – praseodyymi Jul 08 '16 at 09:30
  • With formula usage t.test(var ~ weekday, data=df) it gives me error "grouping factor must have exactly 2 levels" – praseodyymi Jul 08 '16 at 09:31
  • t.test(df$weekday, df$var) gives also means for both var and weekday and for weekday calculating mean is poitless. That's why I wonder how to use these tests when my other variable (weekday) is categorical – praseodyymi Jul 08 '16 at 09:34
  • Perhaps it is best, if you just update your question to your real needs. FYI: There are also several `t.test`, just type `??t.test` – Christoph Jul 08 '16 at 11:22