Here is the problem: Run a regression predicting calories from saturated fat, fiber, and sugar. Based on standardized regression coefficients, identify the strongest predictor. Assign the unstandardized regression coefficient of the strongest predictor to Q4. (You can access the coefficients by indexing the model object) The outcome is simply supposed to be: sat_fat 30.84
I'm running this as R in RStudio. Here's my code:
Q4a <- lm(calories ~ sat_fat + fiber + sugar, data=fastfood)
Q4b <- lm(calories~sat_fat, data=fastfood)
Q4 <- round(coef(Q4b), 2)
My outcome is:
(Intercept) sat_fat
291.91 33.72
Any idea why it's different? And how to get rid of the (Intercept)? Here's my data:
structure(list(restaurant = c("Mcdonalds", "Mcdonalds", "Mcdonalds",
"Mcdonalds", "Mcdonalds", "Mcdonalds"), item = c("Artisan Grilled Chicken Sandwich",
"Single Bacon Smokehouse Burger", "Double Bacon Smokehouse Burger",
"Grilled Bacon Smokehouse Chicken Sandwich", "Crispy Bacon Smokehouse Chicken Sandwich",
"Big Mac"), calories = c(380, 840, 1130, 750, 920, 540), cal_fat = c(60,
410, 600, 280, 410, 250), total_fat = c(7, 45, 67, 31, 45, 28
), sat_fat = c(2, 17, 27, 10, 12, 10), trans_fat = c(0, 1.5,
3, 0.5, 0.5, 1), cholesterol = c(95, 130, 220, 155, 120, 80),
sodium = c(1110, 1580, 1920, 1940, 1980, 950), total_carb = c(44,
62, 63, 62, 81, 46), fiber = c(3, 2, 3, 2, 4, 3), sugar = c(11,
18, 18, 18, 18, 9), protein = c(37, 46, 70, 55, 46, 25),
vit_a = c(4, 6, 10, 6, 6, 10), vit_c = c(20, 20, 20, 25,
20, 2), calcium = c(20, 20, 50, 20, 20, 15), salad = c("Other",
"Other", "Other", "Other", "Other", "Other")), class = c("grouped_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L), groups = structure(list(
restaurant = "Mcdonalds", .rows = structure(list(1:6), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -1L), .drop = TRUE))