楼主: iyiyilsl
4990 15

[学习分享] 小女子跪求一道R语言的题解答。!! [推广有奖]

  • 0关注
  • 0粉丝

小学生

50%

还不是VIP/贵宾

-

威望
0
论坛币
10 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
47 点
帖子
10
精华
0
在线时间
4 小时
注册时间
2011-11-13
最后登录
2011-11-14

楼主
iyiyilsl 发表于 2011-11-13 18:06:10 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
kew.rar (4.05 KB) 本附件包括:
  • kew.dat


我真的无力了~!

一道R语言的题。。。各位大侠大哥美女牛人。。。能否帮我解答一下。。

关于Kruskal Wallis test。

这样子的。。
这个test statistic 有 X^{2} 分布, I - 1 的df, 至少3个groups,每个至少4个observation,
数据是关于每个月下雨量。

问题是
(a)用graph表示这个分布 in each month of the year,(命令month.abb可能会用的)
(b)不用命令kruskal.test,用其他方法,来test这个,来看是否有足够证据来说明每个月之间的下雨量有差、
必须有test statistic的值,degree of freedom,5%和1%的critical value,p值。
感谢!!

我已经快不行。。。。。求求你们了!!数据在附件。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:R语言 小女子 observation statistic Critical 小女子

沙发
lovezxx366 发表于 2011-11-13 18:23:46
给你顶一个 求高手
好好学习 天天向上
有事向人大经济论坛提问 没事逛人大经济论坛

藤椅
jacosis 发表于 2011-11-13 19:36:26
我先来试试第一个问题

我对第一个问题的理解是,画出各年每个月分里面的下雨量的图。
首先,生成一个名为date的日期变量:
Sys.setlocale("LC_TIME", "C") #set the time zone;
kew$date <- as.Date(paste(1, kew$Month, kew$Year), format="%d %b %Y")
为了便于分析,我们把变量里面的月分提取出来,这样可以得到一个数字形式的月分:
kew$month <- substr(as.character(kew$date),6,7)
现在得到如下形式的数据:
Month Year       Rain             date       month
1      Jan 1900  74.400000 1900-01-01    01
2      Feb 1900  80.500000 1900-02-01    02
3      Mar 1900  23.600000 1900-03-01    03
4      Apr 1900  23.600000 1900-04-01    04
5      May 1900  25.100000 1900-05-01    05
6      Jun 1900  53.300000 1900-06-01    06
7      Jul 1900  31.700000 1900-07-01    07
8      Aug 1900  67.300000 1900-08-01    08
9      Sep 1900  26.400000 1900-09-01    09
10     Oct 1900  40.900000 1900-10-01    10
然后,统计每个月里面的平均下雨量(这里用到的是doBy Package里面的summaryBy函数):
library(doBy)
myFun <- Function(x) {c(ave=mean(x), sd=sd(x))}
a <- summaryBy(Rain~month,data=kew, FUN=myFun)
下面就a进行画图:
library(ggplot2)
p <- ggplot(a, aes(x=month,y=Rain.ave))
p+geom_point()
得到如下图所示的图:
1.png

把图修饰修饰得到如下的图:
1.png

再研究研究第二个问题。

板凳
iyiyilsl 发表于 2011-11-13 23:54:43
jacosis 发表于 2011-11-13 19:36
我先来试试第一个问题

我对第一个问题的理解是,画出各年每个月分里面的下雨量的图。
是。。。。

太感谢你了、/。/。/。。我等你接下来的答案!

报纸
iyiyilsl 发表于 2011-11-14 00:55:52
jacosis 发表于 2011-11-13 19:36
我先来试试第一个问题

我对第一个问题的理解是,画出各年每个月分里面的下雨量的图。
是不是需要先定义kew是什么。。因为

Error in paste(1, kew$Month, kew$Year) : object "kew" not found

地板
iyiyilsl 发表于 2011-11-14 01:04:22
jacosis 发表于 2011-11-13 19:36
我先来试试第一个问题

我对第一个问题的理解是,画出各年每个月分里面的下雨量的图。
大神,您能把所有步骤都发出来吗。。。

恩,关于第二个问,可以用aov (ANOVA)来解答吗?

7
iyiyilsl 发表于 2011-11-14 01:37:05
我真的快绝望了

8
iyiyilsl 发表于 2011-11-14 02:03:19

The Kruskal-Wallis test is a nonparametric equivalent of the 1-way analysis of variance, that may be appropriate when your data are markedly non-normal. There are I groups of observations, and in group i we collect Ji observations of some variable of

interest (so the total number of observations is , say). Call these observations {Yij : j = 1, . . . , Ji}. We are interested in testing for distributional differences between the groups. The Kruskal-Wallis test procedure is as follows:

Combine all of the Y s and rank them. Let Rij be the rank of Yij in the combined sample.

Perform a conventional 1-way analysis of variance using the ranks {Rij} as data, and extract the between-groups sum of squares; call this SSB.

Calculate the test statistic K = 12SSB/ [N (N + 1)].、

Under the null hypothesis of no distributional differences between the groups, K has approximately a X^2 distribution with I 1 degrees of freedom. This approximation is generally regarded as adequate providing there are at least 3 groups, each with at

least 4 observations.

The data are monthly rainfall amounts recorded at Kew Gardens near London, between 1900 and 1987. There are 3 columns: Month (as a 3-character abbreviation), Year and Rain (in mm).

(a) Use a suitable graphical technique to display the distributions of rainfall amounts in each month of the year. If possible, ensure that the months appear in the right order (the command month.abb may be useful).

(b) Without using the built-in command kruskal.test, perform a Kruskal-Wallis test to see whether there is evidence for differences in rainfall distribution between months. Your output should include (i) the value of the test statistic (ii) the degrees of freedom for the x^2 approximation you’re using (iii) the critical values for 5% and 1% tests (iv) the p value for this particular test.

9
jacosis 发表于 2011-11-14 14:26:35
第一步你要先把数据导入,比如你把数据存在E盘,我把文件后缀改为了txt
kew <- read.table("E:\\kew.txt", header=T)
就可以了。

10
kurtloveicy 发表于 2011-11-14 15:05:58
帮顶下

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 03:19