# 1.6: Modeling with Linear Functions - Mathematics

When modeling scenarios with a linear function and solving problems involving quantities changing linearly, we typically follow the same problem solving strategies that we would use for any type of function:

Problem Solving Strategy

1. Identify changing quantities, and then carefully and clearly define descriptive variables to represent those quantities. When appropriate, sketch a picture or define a coordinate system.
2. Carefully read the problem to identify important information. Look for information giving values for the variables, or values for parts of the functional model, like slope and initial value.
3. Carefully read the problem to identify what we are trying to find, identify, solve, or interpret.
4. Identify a solution pathway from the provided information to what we are trying to find. Often this will involve checking and tracking units, building a table or even finding a formula for the function being used to model the problem.
5. When needed, find a formula for the function.
6. Solve or evaluate using the formula you found for the desired quantities.
7. Reflect on whether your answer is reasonable for the given situation and whether it makes sense mathematically.
8. Clearly convey your result using appropriate units, and answer in full sentences when appropriate.

Example (PageIndex{1})

A company purchased $120,000 in new office equipment. Then expect the value to depreciate (decrease) by$16,000 per year. Find a linear model for the value, then find and interpret the horizontal intercept and determine a reasonable domain and range for this function.

Solution

In the problem, there are two changing quantities: time and value. The remaining value of the equipment depends on how long the company has had it. We can define our variables, including units.

Output: (V), value remaining, in dollars

Input: (t), time, in years

Reading the problem, we identify two important values. The first, 120,000, is the initial value for (V). The other value appears to be a rate of change – the units of dollars per year match the units of our output variable divided by our input variable. The value is depreciating, so you should recognize that the value remaining is decreasing each year and the slope is negative. Using the intercept and slope provided in the problem, we can write the equation: (V(t) = 120,000 - 16,000t). To find the horizontal intercept, we set the output to zero, and solve for the input: [egin{align*} 0 &= 120,000 - 16,000t t &= frac{120,000}{16,000} = 7.5 end{align*} ] The horizontal intercept is 7.5 years. Since this represents the input value where the output will be zero, interpreting this, we could say: The equipment will have no remaining value after 7.5 years. When modeling any real life scenario with functions, there is typically a limited domain over which that model will be valid – almost no trend continues indefinitely. In this case, it certainly doesn’t make sense to talk about input values less than zero. This model is also not valid after the horizontal intercept. The domain represents the set of input values and so the reasonable domain for this function is (0 leq t leqs 7.5). The range represents the set of output values and the value starts at120,000 and ends with $0 after 7.5 years so the corresponding range is (0 leq V(t) leqs 120,000). Most importantly remember that domain and range are tied together, and whatever you decide is most appropriate for the domain (the independent variable) will dictate the requirements for the range (the dependent variable). Example (PageIndex{2}) Jamal is choosing between two moving companies. The first, U-Haul, charges an up-front fee of$20, then 59 cents a mile. The second, Budget, charges an up-front fee of $16, then 63 cents a mile(Rates retrieved Aug 2, 2010 from www.budgettruck.com and http://www.uhaul.com/). When will U-Haul be the better choice for Jamal? Solution The two important quantities in this problem are the cost, and the number of miles that are driven. Since we have two companies to consider, we will define two functions: Input: (m), miles driven Outputs: (Y(m)): cost, in dollars, for renting from U-Haul (B(m)): cost, in dollars, for renting from Budget Reading the problem carefully, it appears that we were given an initial cost and a rate of change for each company. Since our outputs are measured in dollars but the costs per mile given in the problem are in cents, we will need to convert these quantities to match our desired units:$0.59 a mile for U-Haul, and $0.63 a mile for Budget. Looking to what we’re trying to find, we want to know when U-Haul will be the better choice. Since all we have to make that decision from is the costs, we are looking for when U-Haul will cost less, or when (Y(m) < B(m)). The solution pathway will lead us to find the equations for the two functions, find the intersection, then look to see where the (Y(m)) function is smaller. Using the rates of change and initial charges, we can write the equations: [Y(m) = 20 + 0.59m onumber ] [B(m) = 16 + 0.63m onumber ] These graphs are sketched to the right, with Y(m) drawn dashed. To find the intersection, we set the equations equal and solve: [egin{array} {rcl} {Y(m)} &= & {B(m)} {20 + 0.59m} &= & {16 + 0.63m} {4} &= & {0.04m} {m} &= & {100} end{array} onumber ] This tells us that the cost from the two companies will be the same if 100 miles are driven. Either by looking at the graph, or noting that (Y(m)) is growing at a slower rate, we can conclude that U-Haul will be the cheaper price when more than 100 miles are driven. Example (PageIndex{3}) A company’s revenue has been growing linearly. In 2012 their revenue was$1.45 million. By 2015 the revenue had grown to $1.81 million. If this trend continues, a. Predict the revenue in 2020. b. When will revenue reach$3 million?

Solution

The two changing quantities are the revenue and time. While we could use the actual year value as the input quantity, doing so tends to lead to very ugly equations, since the vertical intercept would correspond to the year 0, more than 2000 years ago!

To make things a little nicer, and to make our lives easier too, we will define our input as years since 2012:

Input: (t), years since 2012

Output: (R(t)), the company’s revenue, in millions of dollars

The problem gives us two input-output pairs. Converting them to match our defined variables, the year 2012 would correspond to (t = 0), giving the point ((0, 1.45)). Notice that through our clever choice of variable definition, we have “given” ourselves the vertical intercept of the function. The year 2015 would correspond to (t = 3), giving the point ((3, 1.81)).

To predict the population in 2020 ((t = 8)), we would need an equation for the population. Likewise, to find when the revenue would reach $3 million, we would need to solve for the input that would provide an output of 3. Either way, we need an equation. To find it, we start by calculating the rate of change: [m = frac{1.81 - 1.45}{3 - 0} = frac{0.36}{3} = 0.12 ext{ million dollars per year.} onumber] Since we already know the vertical intercept of the line, we can immediately write the equation: [R(t) = 1.45 + 0.12t] To predict the revenue in 2020, we evaluate our function at (t=8), [R(8) = 1.45 + 0.12(8) = 2.41 onumber] If the trend continues, our model predicts a revenue of$2.41 million in 2020.

To find when the population will reach 3 million, we can set (R(t)=3) and solve for (t). [egin{align*} 3 &= 1.45 + 0.12t 1.55 &= 0.12t t &approx 12.917 end{align*} ] Our model predicts the revenue will reach3 million in a little under 13 years after 2012, or just before the year 2025.

In business, a very common application of functions is to model cost, revenue, and profit.

Definition: Word

When a company produces q items, the total cost is the cost of total cost of producing those items. The total cost includes both fixed costs, which are startup costs, like equipment and buildings, and variable costs, which are costs that depend on the number of items produced, like materials and labor.

In the most simple case, Total Cost = (Fixed Costs) + (Variable Costs) ∙ q

Revenue is the amount of money a company brings in from sales.

In the most simple case, Revenue = (Price per item) ∙ q

Profit is the amount of money brings in, after expenses.

Profit = Revenue – Costs

We often talk about the break-even point. This is the level of production where Revenue equals Cost, or equivalently where Profit is zero. This is typically the minimum level of sales necessary for the company to make a profit.

Example (PageIndex{4})

A tech startup is looking at developing and launching a new mobile app. Initial development of the app will cost $300,000, and they estimate marketing and support for each user will cost$0.50. While the app will be free, they estimate they will be able to bring in $2 per user on average from in-app purchases. How many users will the company need to break even? We start by modeling the cost, revenue, and profit. Let q = number of users. The fixed (initial) costs are$300,000, and the variable (per-item) costs as $0.50 per user. We can write the total cost equation: [TC(q) = 300,000 + 0.50q onumber] The revenue will be$2 per user, so the revenue equation will be:

[R(q) = 2q onumber]

We could find the break-even point by setting the total cost equal to the revenue, which is equivalent to finding the intersection of the lines.

Alternatively, we could go ahead and find a profit equation first:

[P(q) = R(q) - TC(q) = 2q - left( {300,000 + 0.50q} ight) = 1.5q - 300,000 onumber]

The break even point can be found by setting the profit equal to zero:

[egin{align*} 0 &= 1.5q - 300,000 q &= 200,000 end{align*} ]

The company will have to acquire 200,000 users to break even.

Exercise (PageIndex{1})

A donut shop estimates their fixed daily expenses are $600. If each donut costs about$0.05 to make and sells for $0.60, how many donuts do they need to sell to break even? Answer Revenue: (R = 0.60q) Break even when (R=C), at a quantity of about 1091 donuts per day. In economics, there is a model for how prices are determined in a free market which states that supply and demand for a product is related to the price. The demand relationship shows the quantity of a certain product that consumers are willing to buy at a certain price. Typically the quantity demanded will decrease for an item if the price increases. The supply relationship shows the quantity of a product that suppliers are willing to produce at a certain sales price. Typically the supply demanded will increase if the price increases. Economic theory says that supply and demand will interact, and the intersection will be the equilibrium price, or market price, where the quantity supplied and demanded will be equal. Supply and Demand If (p) is the price of a product, then (Q_d) is the quantity demanded; (Q_s) is the quantity supplied. The demand curve is a decreasing function, while the supply curve is an increasing function. The intersection of the curves is the equilibrium price and quantity, also called the market price and quantity. This point is often notated as (p^*, Q^*). In later chapters you will explore supply and demand curves that are non-linear, but in this chapter we will focus on linear supply and demand functions. In most economic books, you will see the supply and demand curve written with price as the input and quantity as the output, like (Q_d = 140 - 2p). However, supply and demand graphs are drawn with price on the vertical axis and quantity on the horizontal. In an effort to avoid confusion, most of the time in this text we will instead write supply and demand curves with price as the output, to match its placement on the vertical axis. Example (PageIndex{5}) At a price of$2.50 per gallon, there is a demand in a certain town for 42.5 thousand gallons of gas and a supply of 20 thousand gallons. At a price of 3.50, there is demand for 25.5 thousand gallons and a supply of 28 thousand gallons. Assuming supply and demand are linear, find the equilibrium price and quantity. Solution We start by finding a linear equation for both supply and demand. We will use price, (p) in dollars, as the output and quantity, (q) in thousands of gallons, as the input. For supply, we have the points ((20, 2.50)) and ((28, 3.50)). Finding the slope: (m = frac{3.50 - 2.50}{28 - 20} = frac{1}{8}) We know the equation will look like (p = frac{1}{8}q + b), so substituting in ((20, 2.50)), [egin{align*} 2.5 &= frac{1}{8}(20) + b 2.5 &= 2.5 + b b &= 0 end{align*} ] The supply equation is: (p = frac{1}{8}q) For demand, we have the points ((42.5, 2.50)) and ((25.5, 3.50)). Using a similar approach, we can find the demand equation is: (p = -frac{1}{17}q + 5). To find the equilibrium, we set the supply equal to the demand: [egin{align*} frac{1}{8}q &= -frac{1}17q + 5 &quad ext{Multiplying through by 8(17) = 136 to clear the fractions} & 136left( frac{1}{8}q ight) &= 136left( -frac{1}{17}q + 5 ight)& 17q &= - 8q + 680& quad ext{Now we solve for } q & 25q &= 680& q &= 27.2& end{align*} ] To find the equilibrium price, we can substitute that value back into either equation: [p = frac{1}{8}(27.2) = 3.4 onumber] The equilibrium quantity will be 27.2 thousand gallons of gas at a price of3.40.

Exercise (PageIndex{1})

A company estimates that at a price of $140 there will demand for 4000 items, and for each$5 increase in price the demand will drop by 200 items. The supply curve is (p = frac{1}{20}q). Find the equilibrium price and quantity.

Demand: (p = - frac{1}{40}q + 240)

Supply = Demand when (q = 3200, p =$160) Important Topics of this Section The problem solving process 1. Identify changing quantities, and then carefully and clearly define descriptive variables to represent those quantities. Often this will involve checking and tracking units, building a table or even finding a formula for the function being used to model the problem. 2. When needed, find a formula for the function. 3. Solve or evaluate using the formula you found for the desired quantities. 4. Clearly convey your result using appropriate units, and answer in full sentences when appropriate. ## MODELING REAL WORLD SITUATIONS WITH LINEAR EQUATIONS A manufacturer produces 80 units of a product at$22000 and 125 units at a cost of $28750. Assuming the cost curve to be linear, find the equation of the line and then use it to estimate the cost of 95 units. Since the cost curve is linear, its equation will be (Here y = Total cost, x = no. of units) 80 units at$22000 -----> 22000  =  80A + B -----(1)

125 units at $28750 -----> 28750 = 125A + B -----(2) Solving (1) and (2), we get A = 150 and B = 10000 So, the equation of the line is To find the cost of 95 units, substitute x = 95 in (3). The cost of 95 units is$24250

A trader has 100 units of a product. A sells some of the units at $6 per unit and the remaining units at$8 per units. He receives a total of $660 for all 100 units. Find the number units sold in each category. x -----> number of units sold at$6/unit

y -----> number of units sold at $8/unit The number of tickets sold at$6 per unit is 70 and  the number of tickets sold at $8 per unit is 30. The wages of 8 men and 6 boys amount to$33. If 4 men earn $4.50 more than 5 boys, determine the wages of each man and boy. Let x and y be the wages of each man and boy. The wages of each man and each boy are$3 and $1.50 respectively Sum of incomes of A and B is$2640. If B's income is 20% more than A, find the income of A and B.

Let x and y be the incomes of A and B respectively.

Given :਋'s income is 20% more than A

The incomes of A and B are $1200 and$1440

A trader gains one third of the cost price as profit on a product and one fourth of the cost price as profit on other product. Total profit earned on these two products is $43. The sum of the cost prices of two products is$150. Find the cost price of each product.

Let x and y be the cost prices of the two products.

Given : One third of the cost price as profit on a product

So, profit on the first product = (1/3)x = x/3.

Given : One fourth of the cost price as profit on the other product.

So, profit on the second product = (1/4)y = y/4.

#### Solution

and then convert volume from liters to gallons:

Alternatively, the calculation could be set up in a way that uses all the conversion factors sequentially, as follows:

(b) Using the previously calculated volume in gallons, we find:

(a) What (average) fuel economy, in miles per gallon, did the Prius get during this trip?

### Math I need help ASAP!

1) Identify the function rule shown in the table. Function Table n - 3, 4, 5, 6 y - 2, 1, 0, -1 a. y = 2 + n b. y = 5n c. y = 5 - n d. not enough information ** 2) What is the values of the function y = -2x - 4 for x = 0,1,2 and

### Algebra

Which kind of function best models the data in the table? Use differences or ratios. x y 0 1.7 1 6.8 2 27.2 3 108.8 4 435.2 A.linear B.quadratic C.exponential D.none of the above I think it is C.

### Algebra 1

Does the data in the table represent a direct or inverse variation? Write an equation that models the data in the table. X | 1 | 3 | 5 | 10 Y | 4 | 12| 20| 40 A) direct variation y=4x B) direct variation y=1/4x C) inverse

### Algebra

kind of function best models the data on the table used to differences or ratios 0 0.6 1 4.2 2 29.4 3 205.8 4 1440.6

### Calculus

The function f is continuous on the interval [3, 13] with selected values of x and f(x) given in the table below. Use the data in the table to approximate f '(3.5) x 3 4 7 10 13 f(x) 2 8 10 12 22

## Linear Algebra: Gateway to Mathematics: Second Edition

Linear Algebra: Gateway to Mathematics uses linear algebra as a vehicle to introduce students to the inner workings of mathematics. The structures and techniques of mathematics in turn provide an accessible framework to illustrate the powerful and beautiful results about vector spaces and linear transformations.

The unifying concepts of linear algebra reveal the analogies among three primary examples: Euclidean spaces, function spaces, and collections of matrices. Students are gently introduced to abstractions of higher mathematics through discussions of the logical structure of proofs, the need to translate terminology into notation, and efficient ways to discover and present proofs. Application of linear algebra and concrete examples tie the abstract concepts to familiar objects from algebra, geometry, calculus, and everyday life.

Students will finish a course using this text with an understanding of the basic results of linear algebra and an appreciation of the beauty and utility of mathematics. They will also be fortified with a degree of mathematical maturity required for subsequent courses in abstract algebra, real analysis, and elementary topology. Students who have prior background in dealing with the mechanical operations of vectors and matrices will benefit from seeing this material placed in a more general context.

## Linear Equations Worksheet With Answers Pdf

1 6 r 7 13 7r 2 13 4x 1 x 3 7x 3x 2 8x 8 4 8 x x 4x. Let and represent algebraic expressions.

Solving Equations And Inequalities Worksheet Answers In 2020 Free Math Lessons 9th Grade Math School Algebra

### The diagram below is a rectangle.

Linear equations worksheet with answers pdf. You can customize the worksheets to include one step two step or multi step equations variable on both sides parenthesis and more. Test and worksheet generators for math teachers. 25 x y 6 26 x 3 27 x 5 28 8x 7y 17 29 x 2y 12 30 2x 5y 5 write the standard form of the equation of each line given the slope and y intercept.

B work out the length of the rectangle. Algebra worksheet solving linear equations including negative values form ax b c author. Systems of linear equations worksheet answers.

5x 50 x 10 4. The perimeter of the rectangle is 62 cm. Solving linear equations goal.

Elementary algebra skill solving linear equations. The goal of solving a linear equation is to find the value of the variable that will make the statement equation true. Diagram not drawn to scale 2x 10 x 3 a work out the value of x.

Math drills com free math worksheets subject. Worksheets for linear equations find here an unlimited supply of printable worksheets for solving linear equations available as both pdf and html files. Perform operations to both sides of the equation in order to isolate the variable.

Linear equations word problems worksheet with answers pdf september 4 2020 by admin 21 posts related to linear equations word problems worksheet with answers pdf. Algebra worksheet solving linear equations form ax c. X z jm9aqdvey tw 1i 0t uhz picn lfnisn iet 8eo fa al cg gexbhr qay m14 k worksheet by kuta software llc write the slope intercept form of the equation of each line.

Moreover behind you finish this book you may not only solve your curiosity but after that find the genuine meaning. Algebra mathematics math solving linear equations created date. Variable on both sides solve each equation.

Free algebra 1 worksheets created with infinite algebra 1. Linear equations and inequalities finding slope from a graph finding slope from two points. Answer in its simplest form.

B hence work out the perimeter and area of the rectangle. All measurements are in centimeters. Printable in convenient pdf format.

Create no mistake this collection is essentially recommended for you. Simple linear equations a answers solve for each variable.

Algebra 2 Worksheets Systems Of Equations And Inequalities Worksheets Graphing Inequalities Linear Inequalities Algebra 2 Worksheets

The Solving Linear Equations Form Ax B C A Math Worksheet From The Algebra Worksheet Page Solving Linear Equations Algebra Worksheets Linear Equations

Solving Linear Equations Worksheet Pdf Awesome 25 Best Ideas About Solving Equations On Pinterest In 2020 Teaching Math Math School Teaching Mathematics

Solving Equations Maths Worksheet Algebra Worksheets Solving Linear Equations Pre Algebra Worksheets

Algebra 1 Worksheets Inequalities Worksheets Algebra Worksheets Pre Algebra Worksheets Graphing Inequalities

Algebra Worksheets Pre Algebra Algebra 1 And Algebra 2 Worksheets In 2020 Graphing Inequalities Algebra Worksheets Pre Algebra Worksheets

28 Square Root Exercises With Answers Solving Equations Worksheets Math In 2020 Algebra Worksheets Solving Linear Equations Solving Equations

Legal Simple Algebra Worksheets

Solving Linear Equations Worksheet Pdf Best Of Solving Equations Worksheets In 2020 Algebra Worksheets Solving Linear Equations College Algebra

30 Solving Two Step Equations Worksheet Answers Two Step Equations And Inequalities W In 2020 Algebra Worksheets Pre Algebra Worksheets Multi Step Equations Worksheets

Linear Equations Graphs Graphing Linear Equations Graphing Worksheets Linear Equations

Solving Equations Sudoku Solving Equations Solving Linear Equations Math Expressions

Ks3 Ks4 Maths Worksheets Printable With Answers Year 7 Math Pdf Al 5 Uk Algebra Fractions An Algebra Worksheets Solving Linear Equations Pre Algebra Worksheets

Solving Linear Equations Form Ax C C 10 06 B Solving Linear Equations Linear Equations Algebra Worksheets

Systems Of Linear Equations By Elimination From Dawnmbrown On Teachersnotebook Com 2 Pages Linear Equations Systems Of Equations Solving Linear Equations

Graphing Linear Equations Worksheet Pdf Graphing Linear Equations Linear Function Graphing Worksheets

Solving Linear Equations Worksheet Pdf Best Of Solving Equations Worksheets Chessmuseum Templ In 2020 Algebra Worksheets Word Problem Worksheets Free Math Worksheets

Solving Equations Worksheets Cazoom Maths Worksheets Solving Linear Equations School Algebra Algebra Worksheets

Graphing Linear Equations With Color Worksheet Graphing Linear Equations Linear Equations Algebra Lessons

## Understanding the Cost Function

Let’s do an analysis using the squared error cost function.

Remember a cost function maps event or values of one or more variables onto a real number. In this case, the event we are finding the cost of is the difference between estimated values, or the difference between the hypothesis and the real values — the actual data we are trying to fit a line to.

Let’s unwrap the mess of greek symbols above. On the far left, we have 1/2*m. m is the number of samples — in this case, we have three samples for X. Those are 1 , 2 and 3 . So 1/2*m is a constant. It turns out to be 1/6 , or 0.1667 .

This means the sum. In this case, the sum from i to m , or 1 to 3 . We repeat the calculation to the right of the sigma, that is:

The actual calculation is just the hypothesis value for h(x) , minus the actual value of y . Then you square whatever you get.

The final result will be a single number. We repeat this process for all the hypothesis, in this case best_fit_1 , best_fit_2 and best_fit_3 . Whichever has the lowest result, or the lowest “cost” is the best fit of the three hypothesis.

Let’s go ahead and see this in action to get a better intuition for what’s happening.

## Slope of Linear Functions

The concept of slope is important in economics because it is used to measure the rate at which changes are taking place. Economists often look at how things change and about how one item changes in response to a change in another item.

It may show for example how demand changes when price changes or how consumption changes when income changes or how quickly sales are growing.

Slope measures the rate of change in the dependent variable as the independent variable changes. The greater the slope the steeper the line.

Consider the linear function:

b is the slope of the line. Slope means that a unit change in x, the independent variable will result in a change in y by the amount of b.

slope = change in y/change in x = rise/run

Slope shows both steepness and direction. With positive slope the line moves upward when going from left to right. With negative slope the line moves down when going from left to right.

If two linear functions have the same slope they are parallel.

Slopes of linear functions

The slope of a linear function is the same no matter where on the line it is measured. (This is not true for non-linear functions.)

An example of the use of slope in economics

Demand might be represented by a linear demand function such as

Q(d) represents the demand for a good

P represents the price of that good.

Economists might consider how sensitive demand is to a change in price.

 This is a typical downward sloping demand curve which says that demand declines as price rises.

 This is a special case of a horizontal demand curve which says at any price above P* demand drops to zero. An example might be a competitor's product which is considered just as good.

 This is a special case of a vertical demand curve which says that regardless of the price quantity demanded is the same. An example might be medicine as long as the price does not exceed what the consumer can afford.

Supply might be represented by a linear supply function such as

Q(s) represents the supply for a good

P represents the price of that good.

Economists might consider how sensitive supply is to a change in price.

 This is a typical upward sloping supply curve which says that supply rises as price rises.

An example of the use of slope in economics

The demand for a breakfast cereal can be represented by the following equation where p is the price per box in dollars:

This means that for every increase of \$1 in the price per box, demand decreases by 1,500 boxes.

Calculating the slope of a linear function

Slope measures the rate of change in the dependent variable as the independent variable changes. Mathematicians and economists often use the Greek capital letter D or D as the symbol for change. Slope shows the change in y or the change on the vertical axis versus the change in x or the change on the horizontal axis. It can be measured as the ratio of any two values of y versus any two values of x.

## Generalized Linear Models (GLMs) in R, Part 4: Options, Link Functions, and Interpretation

Last year I wrote several articles (GLM in R 1, GLM in R 2, GLM in R 3) that provided an introduction to Generalized Linear Models (GLMs) in R.

As a reminder, Generalized Linear Models are an extension of linear regression models that allow the dependent variable to be non-normal.

In our example for this week we fit a GLM to a set of education-related data.

Let’s read in a data set from an experiment consisting of numeracy test scores (numeracy), scores on an anxiety test (anxiety), and a binary outcome variable (success) that records whether or not the students eventually succeeded in gaining admission to a prestigious university through an admissions test.

We will use the glm() command to run a logistic regression, regressing success on the numeracy and anxiety scores.

The variable ‘success’ is a binary variable that takes the value 1 for individuals who succeeded in gaining admission, and the value 0 for those who did not. Let’s look at the mean values of numeracy and anxiety.

We begin by fitting a model that includes interactions through the asterisk formula operator. The most commonly used link for binary outcome variables is the logit link, though other links can be used.

glm() is the function that tells R to run a generalized linear model.

Inside the parentheses we give R important information about the model. To the left of the

is the dependent variable: success. It must be coded 0 & 1 for glm to read it as binary.

, we list the two predictor variables. The * indicates that not only do we want each main effect, but we also want an interaction term between numeracy and anxiety.

And finally, after the comma, we specify that the distribution is binomial. The default link function in glm for a binomial outcome variable is the logit. More on that below.

We can access the model output using summary() .

The estimates (coefficients of the predictors – numeracy and anxiety) are now in logits. The coefficient of numeracy is: 1.94556, so that a one unit change in numeracy produces approximately a 1.95 unit change in the log odds (i.e. a 1.95 unit change in the logit).

From the signs of the two predictors, we see that numeracy influences admission positively, but anxiety influences survival negatively.

We can’t tell much more than that as most of us can’t think in terms of logits. Instead we can convert these logits to odds ratios.

We do this by exponentiating each coefficient. (This means raise the value e –approximately 2.72–to the power of the coefficient. e^b).

So, the odds ratio for numeracy is:

However, in this version of the model the estimates are non-significant, and we have a non-significant interaction. Model1 produces the following relationship between the logit (log odds) and the two predictors:

logit(p) = 0.88 + 1.95* numeracy – 0.45 * anxiety – 1.0* interaction term

The output produced by glm() includes several additional quantities that require discussion.

We see a z value for each estimate. The z value is the Wald statistic that tests the hypothesis that the estimate is zero. The null hypothesis is that the estimate has a normal distribution with mean zero and standard deviation of 1. The quoted p-value, P(>|z|), gives the tail area in a two-tailed test.

For our example, we have a Null Deviance of about 68.03 on 49 degrees of freedom. This value indicates poor fit (a significant difference between fitted values and observed values). Including the independent variables (numeracy and anxiety) decreased the deviance by nearly 40 points on 3 degrees of freedom. The Residual Deviance is 28.2 on 46 degrees of freedom (i.e. a loss of

About the Author: David Lillis has taught R to many researchers and statisticians. His company, Sigma Statistics and Research Limited, provides both on-line instruction and face-to-face workshops on R, and coding services in R. David holds a doctorate in applied statistics.