讲解:ETF5952、Python,c/c++、JavaR|SQL

SAMPLE-Exam AETF5952Questions for Final ExamINSTRUCTIONS TO STUDENTS1. Answer ALL questions and type all your answers. Any answers by image or handwriting will received zeromark.2. When certain decimal places for answers are stated, your answer should be rounded.3. When word limits for answers are stated, your answers should satisfy the limits. If your answer exceedsthe stated limit, you will receive zero mark for the question.1Question 1 (25 points=5+5+5+10)We consider a data set on weekly stock return. The variables in the data set are as follows:• Year: The year that the observation was recorded• Lag1: Percentage return for previous week• Lag2: Percentage return for 2 weeks previous• Lag3: Percentage return for 3 weeks previous• Lag4: Percentage return for 4 weeks previous• Lag5: Percentage return for 5 weeks previous• Volume: Volume of shares traded (average number of daily shares traded in billions)• Today: Percentage return for this week• Direction: A factor with levels Down and Up indicating whether the market had a positive or negativereturn on a given week1. We obtain the sample statistics. Answer the average weekly return.Year Lag1 Lag2 Lag3 Lag4 Lag51996 : 53 Min. :-18.1950 Min. :-18.1950 Min. :-18.1950 Min. :-18.1950 Min. :-18.19502007 : 53 1st Qu.: -1.1540 1st Qu.: -1.1540 1st Qu.: -1.1580 1st Qu.: -1.1580 1st Qu.: -1.16601991 : 52 Median : 0.2410 Median : 0.2410 Median : 0.2410 Median : 0.2380 Median : 0.23401992 : 52 Mean : 0.1506 Mean : 0.1511 Mean : 0.1472 Mean : 0.1458 Mean : 0.13991993 : 52 3rd Qu.: 1.4050 3rd Qu.: 1.4090 3rd Qu.: 1.4090 3rd Qu.: 1.4090 3rd Qu.: 1.40501994 : 52 Max. : 12.0260 Max. : 12.0260 Max. : 12.0260 Max. : 12.0260 Max. : 12.0260(Other):775Volume Today Direction timeMin. :0.08747 Min. :-18.1950 Down:484 Min. : 11st Qu.:0.33202 1st Qu.: -1.1540 Up :605 1st Qu.: 273Median :1.00268 Median : 0.2410 Median : 545Mean :1.57462 Mean : 0.1499 Mean : 5453rd Qu.:2.05373 3rd Qu.: 1.4050 3rd Qu.: 817Max. :9.32821 Max. : 12.0260 Max. :10892. We estimate an autoregressitve with lag order of 1 or AR(1) model as reported below. Explain the effectof Lag1 on Today.glm(formula = Today ~ Lag1, data = DATA)Deviance Residuals:Min 1Q Median 3Q Max-19.061 -1.271 0.113 1.280 11.235Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) 0.16120 0.07140 2.258 0.0242 *Lag1 -0.07503 0.03024 -2.481 0.0133 *---Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 13. We estimate an autoregressitve with lag order of 5 or AR(5) model as reported below. Explain the effectof Volume on Today (no more than 20 words).2glm(formula = Today ~ Lag1 + Lag2 + Lag3 + Lag4 + Lag5 + Volume,data = DATA)Deviance Residuals:Min 1Q Median 3Q Max-18.5410 -1.2622 0.0873 1.2579 11.9316Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) 0.25050 0.09964 2.514 0.0121 *Lag1 -0.07143 0.03046 -2.346 0.0192 *Lag2 0.04760 0.03058 1.556 0.1199Lag3 -0.06857 0.03045 -2.252 0.0245 *Lag4 -0.02215 0.03047 -0.727 0.4674Lag5 0.01406 0.03039 0.463 0.6437Volume -0.05441 0.04274 -1.273 0.2033---Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 14. We estimate the model with more variables and also obtain the AIC for all three models, as reportedbelow (fit1, fit2 and fit3 are estimation results from Question1.2, Question1.3, Question1.4, respectively).In terms of R2, the model here is better. Explain why this model is better or worse for predicting stockreturn. (no more than 30 words).glm(formula = Today ~ Lag1 + Lag2 + Lag3 + Lag4 + Lag5 + Volume +Year, data = DATA)Deviance Residuals:Min 1Q Median 3Q Max-18.0478 -1.2246 0.0719 1.2435 12.4662Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) -0.05787 0.34205 -0.169 0.86569Lag1 -0.09849 0.03104 -3.173 0.00155 **Lag2 0.02080 0.03149 0.661 0.50907Lag3 -0.09284 0.03101 -2.994 0.00281 **Lag4 -0.04905 0.03100 -1.582 0.11394Lag5 -0.01007 0.03080 -0.327 0.74389Volume -0.06976 0.15874 -0.439 0.66043Year1991 0.68642 0.47174 1.455 0.14594Year1992 0.20143 0.47144 0.427 0.66926Year1993 0.24403 0.47139 0.518 0.60478Year1994 0.04760 0.47122 0.101 0.91956Year1995 0.78668 0.47503 1.656 0.09800 .Year1996 0.55581 0.47238 1.177 0.23961Year1997 0.74433 0.47768 1.558 0.11948Year1998 0.69017 0.48118 1.434 0.15177Year1999 0.58028 0.48512 1.196 0.23190Year2000 -0.04876 0.49021 -0.099 0.92079Year2001 -0.09390 0.49905 -0.188 0.85078Year2002 -0.39523 0.50943 -0.776 0.43803Year2003 0.64860 0.51383 1.262 0.20712Year2004 0.38829 0.51445 0.755 0.45056Year2005 0.28258 0.54832 0.515 0.60641Year2006 0.52796 0.59237 0.891 0.372993Year2007 0.31644 0.67343 0.470 0.63853Year2008 -0.48258 0.88789 -0.544 0.58689Year2009 0.97455 0.99170 0.983 0.32598Year2010 0.69020 0.84774 0.814 0.41573---Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 1> c(AIC(fit1), AIC(fit2), AIC(fit3) )[1] 4956.627 4956.663 4969.6274Question 2 (25 points=5+5+5+10)We consider a data set on credit card default. The variables in the data set are• default: A factor with levels No and Yes indicating whether the customer defaulted on their debt• student: A factor with levels No and Yes indicating whether the customer is a student• balance: The average balance that the customer has remaining on their credit card after making theirmonthly payment• income: Income of customer1. We obtain summary statistics and a frequency table as below. Obtain the probability of default = YESand Student = NO and the probability of default = YES condition on student = NO (2 decimal places).> summary(DATA)default student balance incomeNo :9667 No :7056 Min. : 0.0 Min. : 772Yes: 333 Yes:2944 1st Qu.: 481.7 1st Qu.:21340Median : 823.6 Median :34553Mean : 835.4 Mean :335173rd Qu.:1166.3 3rd Qu.:43808Max. :2654.3 Max. :73554> table(DATA$default, DATA$student)No YesNo 6850 2817Yes 206 1272. We obtain an estimate result as below. Interpret the estimated coefficient of income.glm(formula = default ~ balance + income + student, family = binomial, data = DATA)Deviance Residuals:Min 1Q Median 3Q Max-2.4691 -0.1418 -0.0557 -0.0203 3.7383Coefficients:Estimate Std. Error z value Pr(>|z|)(Intercept) -1.087e+01 4.923e-01 -22.080 balance 5.737e-03 2.319e-04 24.738 income 3.033e-06 8.203e-06 0.370 0.71152studentYes -6.468e-01 2.363e-01 -2.738 0.00619 **---Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 13. Using the previous estimation result, interpret the estimated coefficient of student.4. We obtain another estimate result as below. Interpret the effect of balance in the result (no more than 30words, 4 decimal places).glm(formula = default ~ balance * student + income, family = binomial, data = DATA)Deviance Residuals:Min 1Q Median 3Q Max-2.4949 -0.1417 -0.0555 -0.0202 3.75765Coefficients:Estimate Std. Error z value Pr(>|z|)(Intercept) -1.099e+01 5.667e-01 -19.399 balance 5.817e-03 2.938e-04 19.801 studentYes -2.856e-01 8.239e-01 -0.347 0.729income 3.016e-06 8.226e-06 0.367 0.714balance:studentYes -2.184e-04 4.781e-04 -0.457 0.648---Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 16Question 3 (25 points=5+5+5+10)We consider a data set on cars. The data set includes the following variables:• mpg: miles per gallon• cylinders: Number of cylinders between 4 and 8• displacement: Engine displacement (cu. inches)• horsepower: Engine horsepower• weight: Vehicle weight (lbs.)• acceleration: Time to accelerate from 0 to 60 mph (sec.)• year: Model year (modulo 100)• origin: Origin of car (1. American, 2. European, 3. Japanese)• name: Vehicle nameThe summary statistics is as follows:mpg cylinders displacement horsepower weight acceleration yearMin. : 9.00 Min. :3.000 Min. : 68.0 Min. : 46.0 Min. :1613 Min. : 8.00 73 : 401st Qu.:17.00 1st Qu.:4.000 1st Qu.:105.0 1st Qu.: 75.0 1st Qu.:2225 1st Qu.:13.78 78 : 36Median :22.75 Median :4.000 Median :151.0 Median : 93.5 Median :2804 Median :15.50 76 : 34Mean :23.45 Mean :5.472 Mean :194.4 Mean :104.5 Mean :2978 Mean :15.54 75 : 303rd Qu.:29.00 3rd Qu.:8.000 3rd Qu.:275.8 3rd Qu.:126.0 3rd Qu.:3615 3rd Qu.:17.02 82 : 30Max. :46.60 Max. :8.000 Max. :455.0 Max. :230.0 Max. :5140 Max. :24.80 70 : 29(Other):193origin nameMin. :1.000 amc matador : 51st Qu.:1.000 ford pinto : 5Median :1.000 toyota corolla : 5Mean :1.577 amc gremlin : 43rd Qu.:2.000 amc hornet : 4Max. :3.000 chevrolet chevette: 4(Other) :3651. We obtain a regression result as below. Explain the effect of weight on miles per gallon (no more than 30words.)glm(formula = log(mpg) ~ log(weight) + cylinders + displacement +horsepower + weight + acceleration + year, data = DATA)Deviance Residuals:Min 1Q Median 3Q Max-0.34100 -0.05913 0.00180 0.05995 0.37563Coefficients:Estimate Std. Error t value Pr(>|t|)(Intercept) 1.133e+01 1.097e+00 10.334 log(weight) -1.056e+00 1.560e-01 -6.772 4.96e-11 ***cylinders -2.045e-02 1.062e-02 -1.924 0.055082 .displacement 1.166e-04 2.351e-04 0.496 0.620209horsepower -1.656e-03 4.706e-04 -3.520 0.000485 ***weight 1.280e-04 5.935e-05 2.157 0.031676 *acceleration -3.262e-03 3.236e-03 -1.008 0.314127year71 1.542e-03 3.095e-02 0.050 0.960290year72 -2.846e-02 2.996e-02 -0.950 0.342860year73 -5.343e-02 2.721e-02 -1.964 0.050319 .year74 3.420e-02 3.222e-02 1.061 0.2892947year75 3.843e-02 3.131e-02 1.227 0.220567year76 6.273e-02 3.010e-02 2.084 0.037830 *year77 1.163e-01 3.067e-02 3.791 0.000175 ***year78 1.316e-01 2.903e-02 4.533 7.84e-06 ***year79 2.196e-01 3.072e-02 7.148 4.67e-12 ***year80 3.328e-01 3.238e-02 10.280 year81 2.518e-01 3.186e-02 7.904 3.07e-14 ***year82 2.926e-01 3.105e-02 9.423 ---Signif. codes: 0 *** 0.001 ** 0.01 * 0.05 . 0.1 12. We apply the lasso procedure, where the dependent variables is log of mpg and the rest of variables in thedata are used as regressors. Explain why we should not simply run standard regression.> x = sparse.model.matrix(log(mpg) ~ ., data=DATA)[,-1]> y = log(DATA$mpg)> dim(x)[1] 392 321> x = sparse.model.matrix(log(mpg) ~ ., data=DATA)[,-1]> x = sparse.model.matrix(log(mpg) ~ ., data=DATA)[,-1]> y = log(DATA$mpg)> dim(x)[1] 392 321> sclasso = gamlr(x, y, family = gaussian, nfold=10)> sum(coef(sclasso) !=0)[1] 583. In outputs from the lasso above, explain whether the lasso works properly (no more than 20 words).4. We obtain a plot after we implement the lasso procedure above. This plot shows trajectories of estimatedcoefficients. Explain why lines spread widely on the left side and does not on the right side (no more than40 words).8Question 4 (25 points=5+5+5+10)We have a data set collected from 506 geographical areas and the data set contains a list of variables:• price: median housing price in US$1,000,• crime: crimes committed per capita• nox: nitric oxide pollution per 100m• rooms: average number of rooms• dist: weighted distance to city center• radial: access index to radial highways (radial),• stratio: average student-teacher ratioWe estimate a regression tree by using price as the dependent variable and the other variables as regressors.The estimation result is reported in Figure 1.Figure 1: Regression Tree Result1. The far-right node has 45 and 6%. Explain those numbers (no more than 20 words.)2. Interpret prediction from the above estimation result for an area with rooms = 4, stratio = 15, dist = 2,crime = 8 and nox = 3 (no more than 20 words).3. Find the node with 18 and 8% and explain characters of observations in the node.4. Explain what possibly causes low housing prices at the far-left terminal node of the regression tree result.9转自:http://www.6daixie.com/contents/13/5216.html

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 204,053评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,527评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,779评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,685评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,699评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,609评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,989评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,654评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,890评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,634评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,716评论 1 330
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,394评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,976评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,950评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,191评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,849评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,458评论 2 342