class: center, middle, inverse, title-slide .title[ # Multiple Linear Regression ] .subtitle[ ## Concerning Expenses for Farmers ] .author[ ### Connor McKee ] .institute[ ### West Chester University ] .date[ ### 02-15-2023 ] --- ## The research/practical questions The annual expenses of various livestock markets were monitored. How do these depend on the number of animals sold? ## Description of data This is a data set contains the annual expenses of various livestock markets that were monitored. It contains 19 observations with 7 variables. The variables include: --- .pull-left[ ## Variable - I - one - cattle - calves - pigs - lambs - expenses ] .pull-right[ ## Description - the index (nominal) - 1 (categorical) - Cattle in thousands (numerical) - Calves in thousands (numerical) - Pigs in thousands (numerical) - lambs in thousands (numerical) - expenses in thousands of dollars (numerical) ] --- ## Model and Diagnostics ```r farmers = read.table("https://people.sc.fsu.edu/~jburkardt/datasets/regression/x19.txt", skip=41) #above I read a text file in and skipped 41 lines which described the data set names(farmers) = c("Index", "one", "cattle", "calves", "pigs", "lambs", "expenses") #above I named the variables farmers[8,7] = 14.755 #was a missing value because of a comma expenses = as.numeric(farmers$expenses) #made expenses variable numerical value cattle = farmers$cattle #made all numeric values objects calves = farmers$calves pigs = farmers$pigs lambs = farmers$lambs #made new data set with numerical values, I left out variables Index and one. finalfarmers = data.frame(expenses, cattle, calves, pigs, lambs) ``` --- ## Building Model ``` ## ## Call: ## lm(formula = expenses ~ ., data = finalfarmers) ## ## Residuals: ## Min 1Q Median 3Q Max ## -9.3588 -3.9668 0.4735 2.6222 12.0169 ## ## Coefficients: ## Estimate Std. Error t value Pr(>|t|) ## (Intercept) 2.2831 3.3832 0.675 0.510781 *## cattle 3.2078 0.4221 7.600 2.48e-06 *** ## calves 1.6191 0.8508 1.903 0.077819 . ## pigs 0.8168 0.4699 1.738 0.104123 *## lambs 0.8048 0.1899 4.238 0.000828 *** ## --- ## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 ## ## Residual standard error: 6.151 on 14 degrees of freedom *## Multiple R-squared: 0.9374, Adjusted R-squared: 0.9196 *## F-statistic: 52.45 on 4 and 14 DF, p-value: 2.834e-08 ``` --- ```r knitr::include_graphics('./Assignment2Picture.png') ``` <img src="./Assignment2Picture.png" width="820" /> --- ## Final Model `$$expenses=2.2831+3.2078(cattle)+1.6191(calves)$$` `$$+0.8168(pigs)+0.8048(lambs)$$` ## Conclusion In conclusion, we see that cattle are the most expensive animal to buy. For every 1000 cattle bought, expenses increase by $3,207.80. Lambs are the least expensive animal to buy. For every 1000 lambs bought, expenses increase by $804.80.