Skip to main content
United States
Jump To
Support
Register or Log In
Support
Register or Log In
Instructors
Browse Products
Getting Started
Students
Browse Products
Getting Started
Return to Research Methods Using R 1e Student Resources
Chapter 9 Multiple choice questions
Quiz Content
*
not completed
.
Create the following variables and function:
a <<- 1:10
b <<- c(2.08, 2.75, 3.54, 4.78, 7.02, 3.65,
7.01, 9.59, 9.95, 8.43)
errorfit <- function(p){
y <- p[1]*a + p[2]
rms <- sqrt(sum((y-b)^2)/length(b))
return(rms)}
The variables are an increasing sequence, and the function fits a straight line (y = mx + c) to the data. Use the simplex algorithm to fit the function to the data using starting values of c(1,1). You might find it useful to plot the data and the fitted line to check it is working. The best fitting parameters are:
2.08 and 1.36
correct
incorrect
1.22 and 1.18
correct
incorrect
0.86 and 1.18
correct
incorrect
1.72 and 2.96
correct
incorrect
*
not completed
.
What is the RMS error of the best fit from question 1?
1.14
correct
incorrect
0.96
correct
incorrect
1.18
correct
incorrect
1.22
correct
incorrect
*
not completed
.
Now change the
b
variable to hold the following numbers:
b <<- c(9, 45, 8, 752,1003, 253, 589, 2301, 5440, 8277)
Also edit the first line of the errorfit function so that it returns an exponential function, as follows: y <- p[1]*a^p[2]
The best fitting exponent for the data is:
5.44
correct
incorrect
0.03
correct
incorrect
1.18
correct
incorrect
3.79
correct
incorrect
*
not completed
.
Make a note of the RMS error returned by the fitting in question 3. Now fit the data again using the straight line model from question 1. How much worse is the RMS error with a straight line fit?
462
correct
incorrect
1123
correct
incorrect
1584
correct
incorrect
2959
correct
incorrect
*
not completed
.
The following values produce data that can be fit by a Gaussian:
a <<- 1:10
b <<- c(0.00, 0.01, 0.06, 0.15, 0.25, 0.26, 0.16, 0.06, 0.02, 0.01)
Use the following equation to fit these data:
y <- p[1]*exp(-((a-p[2])^2)/(2*p[3]^2))
Notice that the function requires three free parameters. You should plot the data and the fit to check the fit quality. The best fitting parameter for the width of the Gaussian is:
5.55
correct
incorrect
0.27
correct
incorrect
1.44
correct
incorrect
0.01
correct
incorrect
*
not completed
.
If the output structure of the simplex algorithm is stored in a variable called
sout
, you can find the number of iterations the simplex went through by looking at sout$count. How many fewer iterations are required when starting the search from question 5 with the parameters c(1,5,1), compared with c(1,1,1)?
159
correct
incorrect
81
correct
incorrect
210
correct
incorrect
57
correct
incorrect
*
not completed
.
The following data are approximately sinusoidal:
a <<- 1:10
b <<- c(1.85, 0.26, 0.82, 2.00, 0.59, 0.49, 2.08, 0.76, 0.32, 2.00) Use the following simplified sine wave equation to fit a sine function to the data:
y <- p[1]+sin(a*p[2]) You may need to experiment with different starting parameters to get a good fit – plot your data to check if the fit is reasonable. The best fitting parameters are:
1.06 and 0.01
correct
incorrect
1.10 and 1.29
correct
incorrect
1.07 and 0.69
correct
incorrect
1.05 and 2.00
correct
incorrect
*
not completed
.
What is the increase in RMS error using the code in question 7 when a cosine function is used instead of a sine function?
0.41
correct
incorrect
0.46
correct
incorrect
0.52
correct
incorrect
0.05
correct
incorrect
*
not completed
.
What type of model would you expect to best predict future observations?
A model with the same number of free parameters as data points
correct
incorrect
A descriptive model such as a polynomial function
correct
incorrect
A functional model that attempts to represent the data generating process
correct
incorrect
A model with the largest RMS value
correct
incorrect
*
not completed
.
Which other function in the
pracma
package might be used for optimization?
sigmoid
correct
incorrect
hooke_jeeves
correct
incorrect
polyval
correct
incorrect
strfind
correct
incorrect
Previous Question
Submit Quiz
Next Question
Reset
Exit Quiz
Review all Questions
Submit Quiz
Are you sure?
You have some unanswered questions. Do you really want to submit?
Back to top
Printed from , all rights reserved. © Oxford University Press, 2024
Select your Country