In: Computer Science
Write a computer program that stores and tracks information about high school students. The first piece of information is what grade the student is in. Since this is for high school, the available values are 9, 10, 11, and 12. We also want to track the student’s GPA. Examples of GPAs are 2.2, 2.6, and 4.0. Finally, we want to track the letter grade that the student got on his or her final exam. These values are A, B, C, D, and F. Using the programming language(s) that you select, write a program that creates variables to store these values. Devise with good names for these variables. In addition to creating the variables, set the values as follows: Grade 9 GPA 3.5 Final grade B When finished, your program should run without errors. It won’t do anything, because we have not included anything to be printed on the screen. So, when you run the program it should just terminate without errors. I am running on windows and already have Java installed
Learning Objectives 1. Define linear regression 2. Identify errors of prediction in a scatter plot with a regression line In simple linear regression, we predict scores on one variable from the scores on a second variable. The variable we are predicting is called the criterion variable and is referred to as Y. The variable we are basing our predictions on is called the predictor variable and is referred to as X. When there is only one predictor variable, the prediction method is called simple regression. In simple linear regression, the topic of this section, the predictions of Y when plotted as a function of X form a straight line. The example data in Table 1 are plotted in Figure 1. You can see that there is a positive relationship between X and Y. If you were going to predict Y from X, the higher the value of X, the higher your prediction of Y.
monika = {
"name": "monika",
"homework": [89.0, 97.0, 95.0, 92.0],
"quizzes": [88.0, 40.0, 94.0],
"tests": [95.0, 89.0]
}
shailini = {...
}
Linear regression consists of finding the best-fitting straight line through the points. The best-fitting line is called a regression line. The black diagonal line in Figure 2 is the regression line and consists of the predicted score on Y for each possible value of X. The vertical lines from the points to the regression line represent the errors of prediction. As you can see, the red point is very near the regression line; its error of prediction is small. By contrast, the yellow point is much higher than the regression line and therefore its error of prediction is large.
Figure 2. A scatter plot of the example data. The black line consists of the predictions, the points are the actual data, and the vertical lines between the points and the black line represent errors of prediction. The error of prediction for a point is the value of the point minus the predicted value (the value on the line). Table 2 shows the predicted values (Y') and the errors of prediction (Y-Y'). For example, the first point has a Y of 1.00 and a predicted Y of 1.21.
used to find the line in Figure 2. The last column in Table 2 shows the squared errors of prediction. The sum of the squared errors of prediction shown in Table 2 is lower than it would be for any other regression line. The formula for a regression line is Y' = bX + A where Y' is the predicted score, b is the slope of the line, and A is the Y intercept. The equation for the line in Figure 2 is Y' = 0.425X + 0.785 For X = 1, Y' = (0.425)(1) + 0.785 = 1.21. For X = 2, Y' = (0.425)(2) + 0.785 = 1.64.
Computing the Regression Line In the age of computers, the regression line is typically computed with statistical software. However, the calculations are relatively easy are given here for anyone who is interested. The calculations are based on the statistics shown in Table 3. MX is the mean of X, MY is the mean of Y, sX is the standard deviation of X, sY is the standard deviation of Y, and r is the correlation between X and Y.