Question

Using the teengamb data from the faraway package in R, model gamble as the response and...

Using the teengamb data from the faraway package in R, model gamble as the response and the other variables as predictors. Take care to investigate the possibility of interactions between sex and the other predictors.

Please use R code. Thanks!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

>library(faraway) #loading library 'FARAWAY'
> teengamb
sex status income verbal gamble
1 1 51 2.00 8 0.00
2 1 28 2.50 8 0.00
3 1 37 2.00 6 0.00
4 1 28 7.00 4 7.30
5 1 65 2.00 8 19.60
6 1 61 3.47 6 0.10
7 1 28 5.50 7 1.45
8 1 27 6.42 5 6.60
9 1 43 2.00 6 1.70
10 1 18 6.00 7 0.10
11 1 18 3.00 6 0.10
12 1 43 4.75 6 5.40
13 1 30 2.20 4 1.20
14 1 28 2.00 6 3.60
15 1 38 3.00 6 2.40
16 1 38 1.50 8 3.40
17 1 28 9.50 8 0.10
18 1 18 10.00 5 8.40
19 1 43 4.00 8 12.00
20 0 51 3.50 9 0.00
21 0 62 3.00 8 1.00
22 0 47 2.50 9 1.20
23 0 43 3.50 5 0.10
24 0 27 10.00 4 156.00
25 0 71 6.50 7 38.50
26 0 38 1.50 7 2.10
27 0 51 5.44 4 14.50
28 0 38 1.00 6 3.00
29 0 51 0.60 7 0.60
30 0 62 5.50 8 9.60
31 0 18 12.00 2 88.00
32 0 30 7.00 7 53.20
33 0 38 15.00 7 90.00
34 0 71 2.00 10 3.00
35 0 28 1.50 1 14.10
36 0 61 4.50 8 70.00
37 0 71 2.50 7 38.50
38 0 28 8.00 6 57.20
39 0 51 10.00 6 6.00
40 0 65 1.60 6 25.00
41 0 48 2.00 9 6.90
42 0 61 15.00 9 69.70
43 0 75 3.00 8 13.30
44 0 66 3.25 9 0.60
45 0 62 4.94 6 38.00
46 0 71 1.50 7 14.40
47 0 71 2.50 9 19.20
> attach(teengamb)
> names(teengamb)
[1] "sex" "status" "income" "verbal" "gamble"
#Taking all probable interactions of sex and other predictors
> model=lm(gamble~sex+status+income+verbal+sex*status+sex*income+sex*verbal)
> summary(model)

Call:
lm(formula = gamble ~ sex + status + income + verbal + sex *
status + sex * income + sex * verbal)

Residuals:
Min 1Q Median 3Q Max
-56.654 -7.589 -1.016 3.323 83.903

Coefficients:
Estimate Std. Error t value Pr(>|t|)   
(Intercept) 27.6354 17.6218 1.568 0.1249   
sex -33.0132 35.0530 -0.942 0.3521   
status -0.1456 0.3316 -0.439 0.6631   
income 6.0291 1.0538 5.721 1.26e-06 ***
verbal -2.9748 2.4265 -1.226 0.2276   
sex:status 0.3529 0.5492 0.643 0.5243   
sex:income -5.3478 2.4244 -2.206 0.0334 *  
sex:verbal 2.8355 4.5973 0.617 0.5410   
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 20.98 on 39 degrees of freedom
Multiple R-squared: 0.6243, Adjusted R-squared: 0.5569
F-statistic: 9.26 on 7 and 39 DF, p-value: 1.06e-06

Among all the interactions, only sex*income interaction is significant since p-value < 0.05.
> model_final=lm(gamble~income+sex+status+verbal+sex*income) #Fitting final model
> summary(model_final)

Call:
lm(formula = gamble ~ income + sex + status + verbal + sex *
income)

Residuals:
Min 1Q Median 3Q Max
-57.109 -6.162 -0.938 2.267 86.503

Coefficients:
Estimate Std. Error t value Pr(>|t|)   
(Intercept) 19.25943 15.79635 1.219 0.22972   
income 6.19885 1.02591 6.042 3.77e-07 ***
sex 4.06362 11.51612 0.353 0.72600   
status -0.04876 0.25978 -0.188 0.85203   
verbal -2.60864 1.99386 -1.308 0.19805   
income:sex -6.43683 2.14337 -3.003 0.00454 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 20.79 on 41 degrees of freedom
Multiple R-squared: 0.6121, Adjusted R-squared: 0.5647
F-statistic: 12.94 on 5 and 41 DF, p-value: 1.417e-07

But most of the variables except income and income*sex are insignificant since p-value > 0.05 (which means failing to reject H0 : no significance of the particular variable)

Add a comment
Know the answer?
Add Answer to:
Using the teengamb data from the faraway package in R, model gamble as the response and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The Motor Trend Car Road Tests dataset mtcars, in faraway R package, was extracted from the...

    The Motor Trend Car Road Tests dataset mtcars, in faraway R package, was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973–74 models). The data frame has 32 observation on 11 (numeric) variables: mpg: Miles/(US) gallon; cyl: Number of cylinders; disp: Displacement (cu.in.); hp: Gross horsepower; drat: Rear axle ratio; wt: Weight (1000 lbs); qsec: 1/4 mile time; vs: Engine (0 = V-shaped, 1 =...

  • Exercise 1. For this exercise use the bdims data set from the openintro package. Type ?bdims to r...

    Exercise 1. For this exercise use the bdims data set from the openintro package. Type ?bdims to read about this data set in the help menu. Of interest are the variables hgt (height in centimeters), wgt (weight in kilograms), and sex (dummy variable with 1-male, 0-female). Since ggplotO requires that a categorical variable be coded as a factor type in R, run the following code: library (openintro) bdíms$sex2 <-factor (bdins$sex, levels-c (0,1), labels=c('F', 'M')) (a) Use ggplot2 to make a...

  • Please use RStudio, thanks! 3. This problem uses the prostate data set in the faraway package....

    Please use RStudio, thanks! 3. This problem uses the prostate data set in the faraway package. (a) Plot lpsa against lcavol. Use the R function lm() to fit the regressions of lpsa on lcavol and lcavol on lpsa. (b) Display both regression lines on the plot. At what point do the two lines intersetct? Give a brief explanation.

  • 2. The data set prostate in the faraway package is from a study on 97 men...

    2. The data set prostate in the faraway package is from a study on 97 men with prostate cancer who were due to receive a radical prostatectomy. We are interest is in predicting lpsa (log prostate specific antigen) with lcavol (log cancer volume). (a) Draw a scatterplot - does a simple linear regression model seem reasonable? (b) Without using the R function Im(0, compute the values , Y,Sxx, Syy and Sxy. Com pute the ordinary least squares estimates of the...

  • 2. R programming 2·The data set prostate in the faraway package is froma study on 97...

    2. R programming 2·The data set prostate in the faraway package is froma study on 97 men with prostate cancer who were due to receive a radical prostatectomy We are interest is in predicting lpsa (log prostate specific antigen) with Icavol (log cancer volume). (a) Draw a scatterplot -does a simple linear regression model seem reasonable? (b) Without using the R function Im), compute the values T,Y, Sxx, Syy and Sxy. Com- pute the ordinary least squares estimates of the...

  • Please Use R programming language to answers these question and please show me the code as...

    Please Use R programming language to answers these question and please show me the code as well. Thank You 1. Problem: dataset: savings; package : faraway Use R, perform the calculations and answer the following questions (a) Calculate the design matrix X, and all regression coefficients estimates, as shown in (3). (b) Calculate the Residuals standard error , as in (5). (c) ANOVA table: Calculate SST, SSE, SSR, ?2, as in (6).      Calculate the ANOVA F-statistic and p-value. (d)...

  • Exercise 2. Consider the iris data set. (a) Fit a linear regression model for Sepal.Width using S...

    Exercise 2. Consider the iris data set. (a) Fit a linear regression model for Sepal.Width using Sepal.Length and Species as predictors. Recall that Species is a categorical variable with 3 levels (setosa versicolor, and virginica). Use summary) to print the results. What is the base- line level for Species in the model? (b) Fit a linear regression model for Sepal.Width using Sepal.Length, Species, and the interaction between Sepal.Length and Species as predictors. Use summary ) to print the results. (c)...

  • For the following exercises you can use the 'Wooldridge' package in R to load the data 9. (7 marks) (using data...

    For the following exercises you can use the 'Wooldridge' package in R to load the data 9. (7 marks) (using dataset: "k401k") The data in 401K are a subset of data analyzed by Papke (1995) to study the relationship between participation in a 401(k) pension plan and the generosity of the plan. The variable prate is the percentage of eligible workers with an active account; this is the variable we would like to explain. The dummy variable sole represents whether...

  • The Book of R (Question 20.2) Please answer using R code. Continue using the survey data...

    The Book of R (Question 20.2) Please answer using R code. Continue using the survey data frame from the package MASS for the next few exercises. The survey data set has a variable named Exer , a factor with k = 3 levels describing the amount of physical exercise time each student gets: none, some, or frequent. Obtain a count of the number of students in each category and produce side-by-side boxplots of student height split by exercise. Assuming independence...

  • Using the RateMy Professor (Rateprof) dataset from alr4, we will explore the process of the stepw...

    Using the RateMy Professor (Rateprof) dataset from alr4, we will explore the process of the stepwise method quality is the response variable. gender, numYears, numRaters, numCourses, pepper, discipline, dept, helpfulness, clarity, easiness, raterInterest are the predictor variables. For simplicity, interactions are not considered. To understand the meaning of the variables, please use the code ?Rateprof after you import the library alr4. Consider quality ~1 to be the simplest model under consideration, and quality~ 1 + gender+ numYears+numRaters+ numCourse s +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT