楼主: KS_Teoh
1089 3

[问答] 新手,一个问题 [推广有奖]

  • 0关注
  • 1粉丝

已卖:21份资源

本科生

29%

还不是VIP/贵宾

-

威望
0
论坛币
1227 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
765 点
帖子
86
精华
0
在线时间
90 小时
注册时间
2013-3-11
最后登录
2013-6-8

楼主
KS_Teoh 发表于 2013-4-14 10:42:29 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
You are required to investigate the sampling distribution of the F-statistic for testing the overall significance of the regression (assuming the null hypothesis holds) in the following specific situation:

y-hat = b0 + b1*x1 + b2*x2 + b3*x3 + b4*x4
sigma = 2

Using this underlying model, you are required to write R code that will produce a histogram that illustrates the sampling distribution of the F-statistic. Your answer should include your R code and a histogram that illustrates the sampling distribution.

我作业的其中一题,我不会编程序。希望有好心人士帮帮忙。感激不尽!!!
二维码

扫码加我 拉你入群

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

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

关键词:distribution significance Illustrate underlying regression hypothesis following situation required specific

沙发
KS_Teoh 发表于 2013-4-14 10:46:27
x1=1:1000   
set.seed(99900)
x2=runif(length(x1),1,50000)
set.seed(1)
x3=runif(length(x1),2000,80000)
set.seed(500)
x4=runif(length(x1),3566,60000)
n=length(x1)
y=rep(0,n)
numsamp=1000
f=rep(0,numsamp)
for(i in 1:numsamp){errors=rnorm(n,0,2)
y=1+2*x1+3*x2+4*x3+5*x4+errors
slrfit=lm(y~x1+x2+x3+x4)
b=anova(slrfit)
f[i]=mean(b[1,2],b[2,2],b[3,2],b[4,2])/b[5,3]}
hist(f)

我的这个有什么问题?可是我就是解不到,因为我拿到的图是normal的,可是F distribution不应该是normal。

藤椅
水天一色DIY 在职认证  发表于 2013-4-14 11:49:20
代码过程写的比较简单,希望对你有用
  1. F_value=c()
  2. for(i in 1:1000){
  3.    error<-rnorm(1000,mean=0,sd=2)
  4.    x1<-runif(1000,1,5)
  5.    x2<-runif(1000,5,10)
  6.    x3<-runif(1000,10,20)
  7.    y_value<-x1+x2+x3+error
  8.    y<-x1+x2+x3
  9.    mymodel<-lm(y_fit~x1+x2+x3)
  10.    res<-residuals(mymodel)
  11.    mean_model<-mean(y_value)
  12.    SSR<-sum((fitted(mymodel)-mean_model)^2)
  13.    SSE<-sum((y_value-fitted(mymodel))^2)
  14.    F_value<-c(F_value,SSR/(SSE/(1000-2)))
  15.                    }
  16. hist(F_value,breaks=20)
复制代码

Rplot.jpeg (41.32 KB)

Rplot.jpeg

已有 1 人评分热心指数 收起 理由
qoiqpwqr + 1 热心帮助其他会员

总评分: 热心指数 + 1   查看全部评分

板凳
ntsean 发表于 2013-4-14 11:57:20
simF <- function(N) {
        X <- matrix(rnorm(N*4), nrow=N, ncol=4)
        y <- 1 + rnorm(N, 0, 2)
        fit <- lm(y~X)
        summary(fit)$fstatistic[1]       
}

Fs <- sapply(1:10000, function(x) simF(100))

hist(Fs, breaks=50, freq=F)
x <- seq(0, 6, length.out=1000)
y <- df(x, 4, 95)
lines(x, y, col=2)
已有 1 人评分热心指数 收起 理由
qoiqpwqr + 1 热心帮助其他会员

总评分: 热心指数 + 1   查看全部评分

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

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