Assignment

1.

Write a hypothesis for all primary independent variables

  • People with a higher financial satisfaction will be more satisfied.
  • People with a higher personal health satisfaction will be more satisfied.
  • People with a higher Age will be more satisfied.

2.

Decide what control variables you will include with brief description of why it is included

  • Sex q260 - Women show to have a higher level of satisfaction compared to men thus we need to control this impact.
  • Immigration q263 - Found 2 conflicting results showing an increase in satisfaction and a decrease thus we control.
  • Education educ - As education levels increase people are found to typically be more satisfied thus we control.
  • People of color poc - I believe these groups will show a different level of satisfaction compared to those who are not involved.

3.

Estimate the OLS model and fully interpret the results

  1. Display the results in nice table format with appropriate names of your independent and dependent variable

  2. Graph the impact of the primary independent variables with 95% confidence intervals

  3. Draw a conclusion on if financial well-being or personal health is more important to life satisfaction in the USA as well as the role of age

  • Looking at the model results we notice that Financial satisfaction has a larger coefficient(weight = .650, regular = .611) compared to personal health(weight = .372, regular = .390 ) and they both have the same level of significance. This would be our first evidence to say Financial, next we notice that the SE for Personal health satisfaction is half the size of Financial satisfaction showing we are more confident in those numbers. finally, when looking at the graph comparison and how they impact satisfaction we notice the 95% CI gets smaller as we climb up the personal health satisfaction graph however, it remains similar in the financial sat graph. The range is roughly the same going from 5 to roughly 7.8. Taking all of these facts into consideration I would say that Financial situation has a larger impact on satisfaction since its per unit increase is larger. I would say this is fair because if you do not have the funds you are unable to do a lot of the things you really want to do. It also takes a lot of stress off by being able to provide for your basic needs which would bring more satisfaction.

Age played a role in that as it increased we notice satisfaction growing then balancing out around the 50-65+ range. However, the difference is not large between the groups and the coefficient of this variable is .158 in weighted group and .164 in regular OLS. This is about half the size of impact per unit compared to personal health satisfaction.

4.

Re-estimate the model using robust standard errors

  1. Display the results in nice table format

  2. What impact did using robust standard errors have?

  3. On your conclusions?

    • It did not change my over all conclusion as the standard error did not change much and the coefficients did not change.
  1. On the size of the standard errors?
  • This increased most of my standard errors in comparison to the regular one without it which was interesting. The HC3 raised my intercept from 2.126 to 3.944 which was an interest jump as the coefficients in the model are the same roughly. However, overall not much changed which would be a sign that my original model was acceptable.
  1. On the beta weights?
  • The regression beta weights did not change between OLS model and HC1 however, there was a slight change compared to the HC3 model where they mostly decreased however, immigrant showed an increase. Small changes to how the variables interact/impact the DV however, no large changes resulting in different beliefs.

Bonus Work1

A reviewer or your future boss might argue that in fact you should estimate your model interacting personal health with financial satisfaction. Re-estimate your original model but interacting those two variables. Then complete the following:

1.

Write an interactive hypothesis for how you expect the interaction to influence your DV

Financial satisfaction interacting with Health satisfaction will increase the impact of both variables on Satisfaction.

  1. Decide which variable will be x and z – not that it matters in this case

I will use x as financial satisfaction and z will be personal health satisfaction.

2.

Estimate the model and fully interpret the results

  1. Display the results in nice table format with appropriate names of your independent and dependent variables

  2. Graph the impact of the interaction between personal health and financial satisfaction with 95% confidence intervals

  3. Pick a high and low value of Z for separate lines and have the x values across the x-axis

  • not too sure what this is asking for so I am unsure how to proceed with it!
  1. Interpret and describe what you see in the results

3.

Draw a conclusion on if you think the interactive model fit the data better than the non-interactive one estimated in part 1

  • Yes, With an increase to R2 and a reduction to std. error I would say that this fits better compared to the OLS model. There is also an increase in impact in the main two IV’s of financial satisfaction and health satisfaction.

Reading and adjusting data

wvs_data <- read_dta("wvs - wave 7 - usa only.dta")
# the items that I have selected to use before 
wvs <- data.frame(wvs_data$q49, wvs_data$q50,wvs_data$q47,wvs_data$age_group4, wvs_data$q260, wvs_data$q263,wvs_data$educ,wvs_data$poc, wvs_data$w_weight)

# giving more intuitive names
new_names <- c("Satisfaction", "Fin_sat", "Per_health", "Age_group", "Sex", "Immigrant", "Educ", "Poc", "w_weight")

colnames(wvs) <- new_names

# flipping personal health to match the direction of financial satisfaction. They both touch towards the concept of satisfaction.
# I also want them to move in the same direction as numbers increase (more positive)
wvs <- wvs %>% 
  mutate(Per_health = case_when(
    Per_health ==1 ~ 5,
    Per_health ==2 ~ 4,
    Per_health ==3 ~ 3,
    Per_health ==4 ~ 2,
    Per_health ==5 ~ 1
  ))

wvs <- wvs %>% 
  mutate(fact_health = case_when(
    Per_health ==1 ~ "Very poor",
    Per_health ==2 ~ "Poor",
    Per_health ==3 ~ "Fair",
    Per_health ==4 ~ "Good",
    Per_health ==5 ~ "Very Good"
  ))

wvs$fact_health <- as.factor(wvs$fact_health)

wvs <- wvs %>%
  mutate(Age_fact = case_when(
    Age_group == 1 ~ "18-29",
    Age_group == 2 ~ "30-49",
    Age_group == 3 ~ "50-64",
    Age_group == 4 ~ "65+"
  ))

wvs$Age_fact <- as.factor(wvs$Age_fact)

wvs <- wvs %>% 
  mutate(fact_fin = case_when(
    Fin_sat ==1 ~ "Comp Dsat",
    Fin_sat ==2 ~ "Very Dsat",
    Fin_sat ==3 ~ "Mod Dsat",
    Fin_sat ==4 ~ "Slight Dsat",
    Fin_sat ==5 ~ "Neutral",
    Fin_sat == 6 ~ "Minor Sat",
    Fin_sat == 7 ~ "Slight Sat",
    Fin_sat == 8 ~ "Mod Sat",
    Fin_sat == 9 ~ "Very Sat",
    Fin_sat == 10 ~ "Comp Sat"
  ))

wvs$fact_fin <- as.factor(wvs$fact_fin)

wvs <- wvs %>%  
  mutate(female = case_when(
    Sex ==1 ~ 0,
    Sex ==2 ~ 1,
    Sex <=-1 ~ NA_real_)) #This code makes all values of -2 = NA for analysis purposes. 

# Weight and complete cases data frame
wvs_post <- wvs[complete.cases(wvs[, c("w_weight", "Satisfaction", "Fin_sat", "Per_health", "Immigrant", "Educ")]), ] #Creates new data frame that is has no missing cases
wvs_weighted <- svydesign(ids = ~1,
                          weights =~w_weight,
                          data = wvs_post)
# Checking to make sure there is no more missing data | all the lowest values are equal to the appropriate lowest value response. 
skim(wvs_post)
Data summary
Name wvs_post
Number of rows 2494
Number of columns 13
_______________________
Column type frequency:
factor 3
numeric 10
________________________
Group variables None

Variable type: factor

skim_variable n_missing complete_rate ordered n_unique top_counts
fact_health 0 1 FALSE 5 Goo: 1240, Ver: 575, Fai: 549, Poo: 111
Age_fact 0 1 FALSE 4 30-: 1034, 18-: 597, 50-: 532, 65+: 331
fact_fin 0 1 FALSE 10 Mod: 425, Sli: 404, Neu: 346, Min: 319

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Satisfaction 0 1 7.22 1.91 1.00 6.00 8.00 9.00 10 ▁▁▃▇▅
Fin_sat 0 1 6.08 2.41 1.00 5.00 6.00 8.00 10 ▂▃▆▇▃
Per_health 0 1 3.90 0.83 1.00 3.00 4.00 4.00 5 ▁▁▃▇▃
Age_group 0 1 2.24 0.96 1.00 2.00 2.00 3.00 4 ▅▇▁▅▂
Sex 0 1 1.46 0.50 1.00 1.00 1.00 2.00 2 ▇▁▁▁▇
Immigrant 0 1 1.10 0.31 1.00 1.00 1.00 1.00 2 ▇▁▁▁▁
Educ 0 1 2.35 1.02 1.00 2.00 2.00 3.00 4 ▆▇▁▆▃
Poc 0 1 0.33 0.47 0.00 0.00 0.00 1.00 1 ▇▁▁▁▃
w_weight 0 1 0.99 0.79 0.13 0.48 0.77 1.26 10 ▇▁▁▁▁
female 0 1 0.46 0.50 0.00 0.00 0.00 1.00 1 ▇▁▁▁▇

Models (3.A)

# set seed for reproducing numbers
set.seed(110)
# regular linear model ols

ols_lm <- lm(Satisfaction ~ Per_health + Fin_sat + Age_group + Immigrant +  female + Educ + Poc, data = wvs_post, na.action = na.exclude)

# Linear model Factor 

ols_fact <- lm(Satisfaction ~ relevel(fact_health, ref = "Fair") + Fin_sat + Age_group + Immigrant +  female + Educ + Poc, data = wvs_post, na.action = na.exclude)

# weighted function using the svyglm function
ols_weight <- svyglm(Satisfaction ~ Per_health + Fin_sat + Age_group + Immigrant +  female + Educ + Poc, design = wvs_weighted)


# Linear model Factor age

ols_fact_age <- lm(Satisfaction ~ Per_health + Age_fact + Fin_sat + Immigrant +  female + Educ + Poc, data = wvs_post, na.action = na.exclude)



# Financial factor


ols_fact_fin <- lm(Satisfaction ~ Per_health + Age_group + fact_fin + Immigrant +  female + Educ + Poc, data = wvs_post, na.action = na.exclude)






# comparing factor to numeric
# Factor version has slightly better R2 and less standard error. 


stargazer(ols_lm, ols_fact, type="text",
          dep.var.labels=c("Satisfaction in Life"),
          covariate.labels = c("Personal Health Sat (str rep = 5)","Very Poor","Poor", "Fair", "Good", "Very Good", "Financial Satisfaction", "Age Groups", "Immigrant", "Sex", "Education Level", "Race/Ethnicity"), digits=3, 
          out=".txt")
## 
## ======================================================================================
##                                                   Dependent variable:                 
##                                   ----------------------------------------------------
##                                                   Satisfaction in Life                
##                                              (1)                       (2)            
## --------------------------------------------------------------------------------------
## Personal Health Sat (str rep = 5)         0.611***                                    
##                                            (0.038)                                    
##                                                                                       
## Very Poor                                                            0.707***         
##                                                                      (0.078)          
##                                                                                       
## Poor                                                                -0.594***         
##                                                                      (0.154)          
##                                                                                       
## Fair                                                                 1.153***         
##                                                                      (0.093)          
##                                                                                       
## Good                                                                -1.884***         
##                                                                      (0.344)          
##                                                                                       
## Very Good                                 0.390***                   0.389***         
##                                            (0.013)                   (0.013)          
##                                                                                       
## Financial Satisfaction                    0.164***                   0.164***         
##                                            (0.032)                   (0.032)          
##                                                                                       
## Age Groups                                 -0.132                     -0.138          
##                                            (0.102)                   (0.102)          
##                                                                                       
## Immigrant                                 0.226***                   0.220***         
##                                            (0.062)                   (0.062)          
##                                                                                       
## Sex                                        -0.001                     -0.001          
##                                            (0.031)                   (0.031)          
##                                                                                       
## Education Level                             0.060                     0.066           
##                                            (0.068)                   (0.068)          
##                                                                                       
## Race/Ethnicity                            2.126***                   3.944***         
##                                            (0.204)                   (0.171)          
##                                                                                       
## --------------------------------------------------------------------------------------
## Observations                                2,494                     2,494           
## R2                                          0.410                     0.412           
## Adjusted R2                                 0.408                     0.410           
## Residual Std. Error                   1.473 (df = 2486)         1.471 (df = 2483)     
## F Statistic                       246.437*** (df = 7; 2486) 173.906*** (df = 10; 2483)
## ======================================================================================
## Note:                                                      *p<0.1; **p<0.05; ***p<0.01
# comparing the weight to non weight
stargazer(ols_weight, ols_lm,
          dep.var.labels=c("Satisfaction in Life"),
          covariate.labels = c("Financial Satisfaction", "Personal Health Satisfaction", "Age Groups", "Immigrant", "Sex", "Education Level", "Race/Ethnicity"), type="text")
## 
## ======================================================================
##                                         Dependent variable:           
##                              -----------------------------------------
##                                        Satisfaction in Life           
##                              survey-weighted            OLS           
##                                  normal                               
##                                    (1)                  (2)           
## ----------------------------------------------------------------------
## Financial Satisfaction          0.650***             0.611***         
##                                  (0.064)              (0.038)         
##                                                                       
## Personal Health Satisfaction    0.372***             0.390***         
##                                  (0.022)              (0.013)         
##                                                                       
## Age Groups                      0.158***             0.164***         
##                                  (0.048)              (0.032)         
##                                                                       
## Immigrant                        -0.150               -0.132          
##                                  (0.153)              (0.102)         
##                                                                       
## Sex                             0.276***             0.226***         
##                                  (0.085)              (0.062)         
##                                                                       
## Education Level                   0.004               -0.001          
##                                  (0.040)              (0.031)         
##                                                                       
## Race/Ethnicity                    0.090                0.060          
##                                  (0.099)              (0.068)         
##                                                                       
## Constant                        2.031***             2.126***         
##                                  (0.278)              (0.204)         
##                                                                       
## ----------------------------------------------------------------------
## Observations                      2,494                2,494          
## R2                                                     0.410          
## Adjusted R2                                            0.408          
## Log Likelihood                 -4,926.211                             
## Akaike Inf. Crit.               9,868.423                             
## Residual Std. Error                              1.473 (df = 2486)    
## F Statistic                                  246.437*** (df = 7; 2486)
## ======================================================================
## Note:                                      *p<0.1; **p<0.05; ***p<0.01

Graping

# numeric Personal health version
new_data <- expand.grid(Per_health = seq(1,5,1),  Fin_sat= mean(wvs$Fin_sat, na.rm = TRUE), Immigrant=mean(wvs_post$Immigrant, na.rm=TRUE), Poc=mean(wvs_post$Poc, na.rm=TRUE), Educ=mean(wvs_post$Educ, na.rm=TRUE), female = mean(wvs_post$female, na.rm = TRUE),Age_group=mean(wvs_post$Age_group))

# Creating 95% conf int
ols<-predict(ols_lm, newdata = new_data,  type = "response", se.fit = TRUE, interval = "confidence", level = 0.95)
new_data$predicted_n <- ols$fit [, "fit"]
new_data$se_n <- ols$se.fit
new_data$lower_ci <-  ols$fit [, "lwr"]
new_data$upper_ci <-  ols$fit [, "upr"]

# running again but for the factor version

#save new data frame for factor model 
new_data2 <- expand.grid(fact_health = c("Very poor", "Poor", "Fair", "Good", "Very Good"),  Fin_sat= mean(wvs$Fin_sat, na.rm = TRUE), Immigrant=mean(wvs_post$Immigrant, na.rm=TRUE), Poc=mean(wvs_post$Poc, na.rm=TRUE), Educ=mean(wvs_post$Educ, na.rm=TRUE), female = mean(wvs_post$female, na.rm = TRUE),Age_group=mean(wvs_post$Age_group))

ols_f<-predict(ols_fact, newdata = new_data2,  type = "response", se.fit = TRUE, interval = "confidence", level = 0.95)
new_data2$predicted_f <- ols_f$fit [, "fit"]
new_data2$se_f <- ols_f$se.fit
new_data2$lower_ci <-  ols_f$fit [, "lwr"]
new_data2$upper_ci <-  ols_f$fit [, "upr"]




# Making the data set for the age graph which is shown by each factor group against predicted satisfaction

new_data3 <- expand.grid(Age_fact=c("18-29", "30-49", "50-64", "65+"), Per_health = mean(wvs$Per_health, na.rm = TRUE),  Fin_sat= mean(wvs_post$Fin_sat, na.rm = TRUE), Immigrant=mean(wvs_post$Immigrant, na.rm=TRUE), Poc=mean(wvs_post$Poc, na.rm=TRUE), Educ=mean(wvs_post$Educ, na.rm=TRUE), female = mean(wvs_post$female, na.rm = TRUE))

#Next, use predict function to save predicted values
ols<-predict(ols_fact_age, newdata = new_data3,  type = "response", se.fit = TRUE, interval = "confidence", level = 0.95)
new_data3$predicted_f <- ols$fit [, "fit"]
new_data3$se_f <- ols$se.fit
new_data3$lower_ci <-  ols$fit [, "lwr"]
new_data3$upper_ci <-  ols$fit [, "upr"]





# numeric financial sat version
new_data4 <- expand.grid(Fin_sat = seq(1,10,1), Per_health = mean(wvs$Per_health, na.rm = TRUE), Immigrant=mean(wvs_post$Immigrant, na.rm=TRUE), Poc=mean(wvs_post$Poc, na.rm=TRUE), Educ=mean(wvs_post$Educ, na.rm=TRUE), female = mean(wvs_post$female, na.rm = TRUE),Age_group=mean(wvs_post$Age_group))

# Creating 95% conf int
ols<-predict(ols_lm, newdata = new_data4,  type = "response", se.fit = TRUE, interval = "confidence", level = 0.95)
new_data4$predicted_n <- ols$fit [, "fit"]
new_data4$se_n <- ols$se.fit
new_data4$lower_ci <-  ols$fit [, "lwr"]
new_data4$upper_ci <-  ols$fit [, "upr"]

# Factor Version

#save new data frame for factor model 
new_data5 <- expand.grid(fact_fin = c("Comp Dsat", "Very Dsat", "Mod Dsat", "Slight Dsat", "Neutral", "Minor Sat", "Slight Sat", "Mod Sat", "Very Sat", "Comp Sat"),  Per_health= mean(wvs$Per_health, na.rm = TRUE), Immigrant=mean(wvs_post$Immigrant, na.rm=TRUE), Poc=mean(wvs_post$Poc, na.rm=TRUE), Educ=mean(wvs_post$Educ, na.rm=TRUE), female = mean(wvs_post$female, na.rm = TRUE),Age_group=mean(wvs_post$Age_group))

ols_f<-predict(ols_fact_fin, newdata = new_data5,  type = "response", se.fit = TRUE, interval = "confidence", level = 0.95)
new_data5$predicted_f <- ols_f$fit [, "fit"]
new_data5$se_f <- ols_f$se.fit
new_data5$lower_ci <-  ols_f$fit [, "lwr"]
new_data5$upper_ci <-  ols_f$fit [, "upr"]

Graphs(3.B)

Pretty interesting to see the difference between the factor and the numerical and it appears that it is not linear as the gaps between each point in the factor was not equal. This would have introduce bias into our results if we assumed they were equal distance to each other.

Personal health graphs

#Create GGPlots of the Predicted Values with Confidence Intervals
plot1<-ggplot(new_data2, aes(x=fact_health, y=predicted_f)) + 
  theme_classic(base_size = 10) + 
  geom_bar(position=position_dodge(), stat="identity", fill="grey", 
           colour="black", # Use black outlines,
           linewidth=.3) +      # Thinner lines
  geom_errorbar(aes(ymin=lower_ci, ymax=upper_ci),
                linewidth=.3,    # Thinner lines
                width=.2,
                position=position_dodge(.9))+
  xlab("Health Satisfaction") +
  ylab("Satisfaction") + 
  ggtitle("Factor Model") +
  theme(plot.title = element_text(hjust = 0.5)) 
  
plot2<-ggplot(new_data, aes(x=Per_health, y=predicted_n)) + 
  theme_classic(base_size = 10) + 
  geom_bar(position=position_dodge(), stat="identity", fill="grey",
           colour="black", # Use black outlines,
           linewidth=.3) +      # Thinner lines
  geom_errorbar(aes(ymin=lower_ci, ymax=upper_ci),
                linewidth=.3,    # Thinner lines
                width=.2,
                position=position_dodge(.9))+
  xlab("Health Satisfaction") +
  ylab("") + 
  ggtitle("Numeric Model") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_y_continuous(limits = c(0, 8))

combined_plot <- plot2 + plot1
combined_plot

Age group models

plot3 <-ggplot(new_data3, aes(x=Age_fact, y=predicted_f)) + 
  theme_classic(base_size = 10) + 
  geom_bar(position=position_dodge(), stat="identity", fill="grey",
           colour="black", # Use black outlines,
           linewidth=.3) +      # Thinner lines
  geom_errorbar(aes(ymin=lower_ci, ymax=upper_ci),
                linewidth=.3,    # Thinner lines
                width=.2,
                position=position_dodge(.9))+
  xlab("Age group") +
  ylab("") + 
  ggtitle("Factor Model") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_y_continuous(limits = c(0, 8))

plot3

Financial satisfaction

#Create GGPlots of the Predicted Values with Confidence Intervals
plot4<-ggplot(new_data4, aes(x=Fin_sat, y=predicted_n)) + 
  theme_classic(base_size = 10) + 
  geom_bar(position=position_dodge(), stat="identity", fill="grey", 
           colour="black", # Use black outlines,
           linewidth=.3) +      # Thinner lines
  geom_errorbar(aes(ymin=lower_ci, ymax=upper_ci),
                linewidth=.3,    # Thinner lines
                width=.2,
                position=position_dodge(.9))+
  xlab("Financial Satisfaction") +
  ylab("Satisfaction") + 
  ggtitle("Numeric Model") +
  theme(plot.title = element_text(hjust = 0.5)) 

#Create GGPlots of the Predicted Values with Confidence Intervals
plot5<-ggplot(new_data5, aes(x=fact_fin, y=predicted_f)) + 
  theme_classic(base_size = 10) + 
  geom_bar(position=position_dodge(), stat="identity", fill="grey", 
           colour="black", # Use black outlines,
           linewidth=.3) +      # Thinner lines
  geom_errorbar(aes(ymin=lower_ci, ymax=upper_ci),
                linewidth=.3,    # Thinner lines
                width=.2,
                position=position_dodge(.9))+
  xlab("Financial Satisfaction") +
  ylab("") + 
  ggtitle("Factor Model") +
  theme(plot.title = element_text(hjust = 0.5)) 

combined2 <- plot4 + plot5
combined2

Robust 4.A

Not seeing any cone shaped graphs indicating that there probably isn’t heteroskadacity which would mean using the robust shouldn’t have the largest impact on my data. However, running it through and comparing would still be good practice to make sure everything is looking good.

set.seed(2938)
plot(ols_lm)

par(mfrow = c(1,2)); plot(ols_lm, which = 2) # Plot normally distributed
plot(ols_fact, which=2)#Adds same residual graph to plot but for the ordinal DV

# Robust SE

robust1<-coeftest(ols_lm, vcov =
vcovHC(ols_lm, type="HC1"))
robust3<-coeftest(ols_fact, vcov =
vcovHC(ols_lm, type="HC3"))

stargazer(ols_lm, robust1, robust3,
          dep.var.labels=c("Satisfaction in Life"),
          covariate.labels = c("Personal Health Satisfaction", "Financial Satisfaction", "Age Groups", "Immigrant", "Sex", "Education Level", "Race/Ethnicity"), type="text")
## 
## ========================================================================
##                                          Dependent variable:            
##                              -------------------------------------------
##                                Satisfaction in Life                     
##                                         OLS               coefficient   
##                                                              test       
##                                         (1)              (2)      (3)   
## ------------------------------------------------------------------------
## Personal Health Satisfaction         0.611***          0.611***         
##                                       (0.038)          (0.045)          
##                                                                         
## Financial Satisfaction               0.390***          0.390*** 0.389***
##                                       (0.013)          (0.016)  (0.016) 
##                                                                         
## Age Groups                           0.164***          0.164*** 0.164***
##                                       (0.032)          (0.034)  (0.034) 
##                                                                         
## Immigrant                             -0.132            -0.132   -0.138 
##                                       (0.102)          (0.103)  (0.104) 
##                                                                         
## Sex                                  0.226***          0.226*** 0.220***
##                                       (0.062)          (0.063)  (0.063) 
##                                                                         
## Education Level                       -0.001            -0.001   -0.001 
##                                       (0.031)          (0.030)  (0.030) 
##                                                                         
## Race/Ethnicity                         0.060            0.060    0.066  
##                                       (0.068)          (0.073)  (0.073) 
##                                                                         
## Constant                             2.126***          2.126*** 3.944***
##                                       (0.204)          (0.213)  (0.213) 
##                                                                         
## ------------------------------------------------------------------------
## Observations                           2,494                            
## R2                                     0.410                            
## Adjusted R2                            0.408                            
## Residual Std. Error              1.473 (df = 2486)                      
## F Statistic                  246.437*** (df = 7; 2486)                  
## ========================================================================
## Note:                                        *p<0.1; **p<0.05; ***p<0.01
lm.beta(ols_lm)
## 
## Call:
## lm(formula = Satisfaction ~ Per_health + Fin_sat + Age_group + 
##     Immigrant + female + Educ + Poc, data = wvs_post, na.action = na.exclude)
## 
## Standardized Coefficients::
##   (Intercept)    Per_health       Fin_sat     Age_group     Immigrant 
##            NA  0.2646307047  0.4903241716  0.0826947017 -0.0211290775 
##        female          Educ           Poc 
##  0.0588947174 -0.0005246516  0.0147264659

Interaction terms

Model bonus.A

ols_lm_int <- lm(Satisfaction ~ (Per_health * Fin_sat) + Age_group + Immigrant +  female + Educ + Poc, data = wvs_post, na.action = na.exclude)


stargazer(ols_lm, ols_lm_int,
          dep.var.labels=c("Satisfaction in Life"),
          column.labels = c("OLS", "Interaction"),
          covariate.labels = c("Personal Health Satisfaction", "Financial Satisfaction", "Age Groups", "Immigrant", "Sex", "Education Level", "Race/Ethnicity", "Health and Finance satisfaction"), type="text")
## 
## ===================================================================================
##                                                 Dependent variable:                
##                                 ---------------------------------------------------
##                                                Satisfaction in Life                
##                                            OLS                   Interaction       
##                                            (1)                       (2)           
## -----------------------------------------------------------------------------------
## Personal Health Satisfaction            0.611***                  1.023***         
##                                          (0.038)                   (0.086)         
##                                                                                    
## Financial Satisfaction                  0.390***                  0.665***         
##                                          (0.013)                   (0.053)         
##                                                                                    
## Age Groups                              0.164***                  0.166***         
##                                          (0.032)                   (0.032)         
##                                                                                    
## Immigrant                                -0.132                    -0.139          
##                                          (0.102)                   (0.101)         
##                                                                                    
## Sex                                     0.226***                  0.227***         
##                                          (0.062)                   (0.062)         
##                                                                                    
## Education Level                          -0.001                     0.002          
##                                          (0.031)                   (0.030)         
##                                                                                    
## Race/Ethnicity                            0.060                     0.060          
##                                          (0.068)                   (0.067)         
##                                                                                    
## Health and Finance satisfaction                                   -0.073***        
##                                                                    (0.014)         
##                                                                                    
## Constant                                2.126***                   0.616*          
##                                          (0.204)                   (0.349)         
##                                                                                    
## -----------------------------------------------------------------------------------
## Observations                              2,494                     2,494          
## R2                                        0.410                     0.416          
## Adjusted R2                               0.408                     0.414          
## Residual Std. Error                 1.473 (df = 2486)         1.465 (df = 2485)    
## F Statistic                     246.437*** (df = 7; 2486) 221.545*** (df = 8; 2485)
## ===================================================================================
## Note:                                                   *p<0.1; **p<0.05; ***p<0.01

Graph bonus.b

# numeric Personal health version
new_data6 <- expand.grid(Per_health = seq(1,5,1),  Fin_sat= mean(wvs$Fin_sat, na.rm = TRUE), Immigrant=mean(wvs_post$Immigrant, na.rm=TRUE), Poc=mean(wvs_post$Poc, na.rm=TRUE), Educ=mean(wvs_post$Educ, na.rm=TRUE), female = mean(wvs_post$female, na.rm = TRUE),Age_group=mean(wvs_post$Age_group))

# Creating 95% conf int
ols<-predict(ols_lm_int, newdata = new_data6,  type = "response", se.fit = TRUE, interval = "confidence", level = 0.95)
new_data6$predicted_n <- ols$fit [, "fit"]
new_data6$se_n <- ols$se.fit
new_data6$lower_ci <-  ols$fit [, "lwr"]
new_data6$upper_ci <-  ols$fit [, "upr"]

plot5<-ggplot(new_data6, aes(x=Per_health, y=predicted_n)) + 
  theme_classic(base_size = 10) + 
  geom_bar(position=position_dodge(), stat="identity", fill="grey", 
           colour="black", # Use black outlines,
           linewidth=.3) +      # Thinner lines
  geom_errorbar(aes(ymin=lower_ci, ymax=upper_ci),
                linewidth=.3,    # Thinner lines
                width=.2,
                position=position_dodge(.9))+
  xlab("Financial Satisfaction") +
  ylab("") + 
  ggtitle("Factor Model") +
  theme(plot.title = element_text(hjust = 0.5)) 

plot5