楼主: zhaorong6
1893 3

R软件作业求答案 [推广有奖]

  • 0关注
  • 0粉丝

已卖:19份资源

本科生

91%

还不是VIP/贵宾

-

威望
0
论坛币
146 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
3032 点
帖子
108
精华
0
在线时间
61 小时
注册时间
2009-4-3
最后登录
2021-3-15

楼主
zhaorong6 发表于 2010-2-3 14:29:07 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
Exercise 4
In this exercise you are required to write simple code in R, and compare three di erent ways of
programming a simple multivariate OLS regression problem.
a. Create a dataset of 100 observations with four exogenous variables and a random error term.
The exogenous variables are: x1, a constant term; x2, a vector containing random draws
from a standard normal distribution; x3, a vector containing random draws from a uniform
distribution between -10 and +10; and x4, a dummy variable that has a value of 1 for the
rst 50 observations and 0 elsewhere. The error terms are independently normally distributed
with mean zero and variance 4. Group the variables xi in a matrix X.
b. Calculate y-observed on the basis of a simple linear speci cation assuming that the true betas
are 1. Group the x variables (except for the constant) and the dependent variable in a data
array and assign names for the variables.
c. Perform a regression using the command lm().
d. Calculate the estimated betas and standard errors yourself by writing simple code based on
standard econometric textbook notation. Compare your results to the lm() output.
e. Write alternative code based on ecient usage of solve() and the crossprod() operator.
See the General Principles 1 and 2 in Bates (2004) available at:
http://www.r-project.org/doc/Rnews/Rnews 2004-1.pdf
Compare your results to the lm() output, and discuss one advantage and one disadvantage
of using the solve operator eciently.
二维码

扫码加我 拉你入群

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

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

关键词:r软件 求答案 observations distribution disadvantage 软件 作业

沙发
ruiqwy 发表于 2010-2-3 16:33:48
呵呵,这个好像不难吧。
R is the second language for me!Using R is standing on the shoulders of giants!   Let\'s use R together!

藤椅
zhaorong6 发表于 2010-2-4 05:45:58
初学,好多问题搞不定

板凳
epoh 发表于 2010-2-4 22:48:25
Exercise 4.a

n=100
x1 <- rep(1, n)                  #constant term
x2 <- rnorm(n, mean=0,sd=1)      #standard normal distribution
x3 <- runif(n, min=-10, max=10)  #uniform distribution
x4 <- rep(1:0, c(50,50))         #dummy variable
x5 <- rnorm(n, mean=0,sd=2)      #error term
X  <- cbind(x1,x2,x3,x4,x5)
X

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

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