Chapter 5 Week 1 - Home

Open the data file LifeSat.sav.

library(foreign)
data <- read.spss("LifeSat.sav", to.data.frame = TRUE)

5.0.1 Question 1.a

Make a table with descriptive statistics for the variables: LifSat, educ, ChildSup, SpouSup, and age.

What is the average age in the sample? And the range (youngest and oldest child)?

Hint: Use library(tidySEM); descriptives(); []

Click for explanation

The package tidySEM contains a function to describe data. Install and load the package, then use the descriptives() function. Alternatively, you can also use the describe() function in the psych package.

library(tidySEM)
descriptives(data[, c("LifSat", "educ", "ChildSup", "SpouSup", "age")])

<>

5.0.2 Question 1.b

Perform a simple regression with LifSat as the dependent variable and educ as the independent variable.

Hint: The function lm() (short for linear model) conducts linear regression. The functions summary() provides relevant summary statistics for the model. It can be helpful to store the results of your analysis in an object, too.

Click for explanation
results <- lm(LifSat ~ educ, data)
summary(results)
## 
## Call:
## lm(formula = LifSat ~ educ, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -43.781 -11.866   2.018  12.418  43.018 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   35.184      7.874   4.469 2.15e-05 ***
## educ           3.466      1.173   2.956  0.00392 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 17.64 on 96 degrees of freedom
## Multiple R-squared:  0.08344,    Adjusted R-squared:  0.0739 
## F-statistic:  8.74 on 1 and 96 DF,  p-value: 0.003918

<>

5.0.3 Question 1.c.

Do the same with age as the independent variable.

Click for explanation
results <- lm(LifSat ~ age, data)
summary(results)
## 
## Call:
## lm(formula = LifSat ~ age, data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -35.321 -14.184   3.192  13.593  40.626 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 200.2302    52.1385   3.840  0.00022 ***
## age          -2.0265     0.7417  -2.732  0.00749 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 17.75 on 96 degrees of freedom
## Multiple R-squared:  0.07215,    Adjusted R-squared:  0.06249 
## F-statistic: 7.465 on 1 and 96 DF,  p-value: 0.007487

<>

5.0.4 Question 1.d.

Again with ChildSup as the independent variable.

Click for explanation
results <- lm(LifSat ~ ChildSup, data)
summary(results)
## 
## Call:
## lm(formula = LifSat ~ ChildSup, data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -37.32 -12.14   0.66  12.41  44.68 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   37.559      8.342   4.502 1.89e-05 ***
## ChildSup       2.960      1.188   2.492   0.0144 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 17.86 on 96 degrees of freedom
## Multiple R-squared:  0.06076,    Adjusted R-squared:  0.05098 
## F-statistic: 6.211 on 1 and 96 DF,  p-value: 0.01441

<>

5.0.5 Question 1.e.

Perform a multiple regression with LifSat as the dependent variable and educ, age and ChildSup as the independent variables.

Hint: You can use the + sign to add multiple variables to a model.

Click for explanation
results <- lm(LifSat ~ educ + age + ChildSup, data)
summary(results)
## 
## Call:
## lm(formula = LifSat ~ educ + age + ChildSup, data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -32.98 -12.56   2.68  11.03  41.91 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept) 134.9801    53.2798   2.533   0.0130 *
## educ          2.8171     1.1436   2.463   0.0156 *
## age          -1.5952     0.7188  -2.219   0.0289 *
## ChildSup      2.4092     1.1361   2.121   0.0366 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 16.92 on 94 degrees of freedom
## Multiple R-squared:  0.1741, Adjusted R-squared:  0.1477 
## F-statistic: 6.603 on 3 and 94 DF,  p-value: 0.0004254

<>

5.0.6 Question 1.f.

Compare the results under 1.e with those obtained under 1.b-1.d. What do you notice when you compare the regression parameter for each of the three predictors in the multiple regression with the corresponding regression parameters obtained in the simple regressions?