R fitting to functions other than lines

Slides:



Advertisements
Similar presentations
The table and graph suggest another method of graphing a linear equation. This method is based on two numbers. The SLOPE This is the coefficient of x.
Advertisements

2.2 Linear Equations.
Linear Equations Review. Find the slope and y intercept: y + x = -1.
Chapter 2 Functions and Graphs
EGR 105 Foundations of Engineering I
Using Logs to Linearise Curves
Solving Exponential Equations. One-to-One Properties.
1 Learning Objectives for Section 1.3 Linear Regression The student will be able to calculate slope as a rate of change. The student will be able to calculate.
Chapter 1 Linear Equations and Graphs Section 3 Linear Regression.
Exponential Functions and an Introduction to Logarithmic Functions
Rules of Logs 1: A log with no base has a base of 10 Ex: log 100 = 2  log = 2  100 = 102 2: Domain of logs log (~)  ~ > 0.
The Simple Pendulum. Recall from lecture that a pendulum will execute simple harmonic motion for small amplitude vibrations. Recall from lecture that.
Linear regression exponential and power law relationships living with the lab how do we handle cases where x is not linearly related to y? a straight line.
Reducing Equations to a Linear Form Andrew Robertson.
Section 5.4 Logarithmic Functions. LOGARITHIMS Since exponential functions are one-to-one, each has an inverse. These exponential functions are called.
Section 2.3 – Graph Equations of Lines A family of functions is a group of functions with shared characteristics. The parent function is the most basic.
Exponential and Logarithmic Functions Do Now 2. Write as the sum or difference of logarithms with no exponents log a x 4 y 3 4log a x – 3log a y log a.
Chapter 2 Functions and Graphs
1. Write the equation in standard form.
or why I like to draw straight lines
Graphs of Equations © 2002 by Shawna Haider.
Chapter 1 Linear Equations and Graphs
OBJECTIVE I will solve absolute-value equations using inverse operations.
Chapter 1 Linear Equations and Graphs
Solving Exponential and Logarithmic Equations
Exponential Equations
F-IF.C.7a: Graphing a Line using Slope-Intercept, Part 2
ALGEBRA II ALGEBRA II HONORS/GIFTED - SECTION 2-3 (Linear Functions and Slope-Intercept Form) 7/16/2018 ALGEBRA II SECTION.
Logarithmic Functions and Their Graphs
linear regression exponential and power law relationships
F-IF.B.4: Using Intercepts of Linear Equations
Sec 11-1 Graphs of Exponential and Logarithmic Functions
Linear Equations Objectives: Find slope of a line
Graphing Linear Functions
Break even or intersection
Logarithmic Functions
Graphing Linear Equations
Logarithmic Functions
4.5 Point-Slope form of a linear equation
Exponents and Logarithms
Polynomial Fit in R.
Warm-up: Solve for x. 2x = 8 2) 4x = 1 3) ex = e 4) 10x = 0.1
and Logarithmic Functions
Solve Linear Systems By Elimination
Model Direct Variation
Logarithmic Equations
Standard Form of a Linear Equation
Model Direct Variation
Nuclear Decay Simulation
Graphs of Equations © 2002 by Shawna Haider.
Regression.
Exponential and Logarithmic Functions
Objective- To write a linear equation given a point
Logarithms 2 my dear Watson.
4.3 Graphing Equations of Lines From Intercepts
y = mx + b Linear Regression line of best fit REMEMBER:
Logarithmic Functions
Logarithmic Functions
Homework: pg. 276 #5, 6 5.) A. The relationship is strong, negative, and curved. The ratios are all Since the ratios are all the same, the exponential.
Logarithmic Functions
Logarithmic Functions
Model Direct Variation
Reducing Equations to a Linear Form (Linear Law)
5.6 - Solving Logarithmic and Exponential Equations
Data Frame and Hubble's Plot
Plot of results from a linearity experiment to determine reportable range. Plot of results from a linearity experiment to determine reportable range. Seven.
exponential equations
Solve Linear Systems By Elimination
Logarithms.
Graphing using Slope-Intercept Form
Presentation transcript:

R fitting to functions other than lines

Power-Law from log-log linear model

Recall the data used in an earlier lab that varied the length of a pendulum and measured its period (the time to swing back and forth) Length (cm) Period (s) 108 2.080 89 1.888 58 1.534 44 1.3352 25 1.0199

The Excel fit to a power-law yielded

Entering the same data into R looks like # copy and paste length = c(108, 89,58,44,25) period = c(2.080, 1.888, 1.534, 1.3352, 1.0199)

Plotting the data in R looks like

Log-log linear model That 0.4873 number looks familiar from the Excel Power-law fit. It was the power.

Can’t take log of 0 or negative numbers One cannot take the log of zero or a negative number Recall on the test we were plotting the kutosis of dice simulations versus how many dice were rolled. But the kurtosis was negative. Thus we had to take the absolute value and plot and fit that. Behind the scenes in Excel there are log’s being taken, and it cannot handle the negative numbers

Isolating the power

Breaking it down pend_fit is the name we gave to the model The model has coefficients (what we usually call slope and intercept) Our x’s are log(pendulum$length) so we are getting the coefficient associated with the x – what we would normally call the slope Originally it was the power

Breaking it down y = A x^b log(y) = log(A x^b) log(y) = log(A) +log(x^b) log(y) = log(A) + b log(x) We see that the slope in log(y) versus log(x) is b – what was originally the power in the power law By log() in R we mean the natural log ln() intercept = log(A) exp(intercept) = A The exponential function and natural log functions are inverses

Obtaining the Coefficient

Displaying fit equation

Displaying the fit curve

Exponential Fit from log linear model

Data from on how air pressure depends on altitude Altitude (miles) Pressure (psi) 14.696 1.708712 11.022 3.409091 7.348 5.204545 4.898177 10.02386 1.4696 19.20095 0.14696 30.1161 0.014696 43.16269 0.00147 53.61288 0.000147

Plot with Exponential fit from Excel

Enter the data into R #copy and paste altitude = c(0, 1.7087, 3.4091, 5.2045, 10.0239, 19.2010, 30.1161, 43.1627, 53.6129) pressure = c(14.696, 11.022, 7.348, 4.8982, 1.4696, 0.14696, 0.014696, 0.00147, 0.000147)

Plotting the data in R

This time take log(y) but not log(x) and obtain a linear model Once again the “slope” number looks familiar when compared to what we got from Excel

Cannot take log(0) When we used this data on the first test, some students got their x and y axes confused. In this data x=0 is perfectly fine, but y=0 is not. That is why for those with the wrong axes, the exponential fit was unavailable in Excel

Isolating the factor

Determining the coefficient

Displaying the equation

Displaying the curve