0.10 Assignment 10: Factros and Dummy variables
Due: 20 April
This time we are looking at regression with factors (categorical variables). We often
treat them with what we call ‘dummy variables’ in econometrics. You will be showing
you can use and interpretregressions with factors(i,e., with dummy variables. Factors
and dummy variables are discussed in Chapter 7 of the current version of the text.
Setting Up
1.Load the LDC dataset used in assignment 2, LDC.csv. The dataset has two factors,
sizeandarea.
2.Write your student number. Divide your student number into three two-digit numbers, a, b, and c. If any of a, b, and c is greater than 72, divide it by 2. Delete
observations numbered a, b, and c from the dataset. Show the command you used.
The Assignment
3.PlotOMandAagainst the factors and reproduce the graphs. Explain what you get.
What kind of graphs do you get? What do they tell you? Are the differences significant?
4.RegressOMandAonArea. Show the results in a nice table.
5.Why does only one area appear in the regression results? Explain how R choses
which one to show.
6.Explain what the regression tells us?
7.RegressTotal.BillonCustomers, OMandA, and Area. Show the results in a nice
table.
8.You have just done a dummy-variable regression and found anintercept dummy,
Explain what it tells you. Why is only one value of Area presented in the table?
9.For your last trick, you will find aslopedummy. To test to see if there is an interaction between the number ofCustomersand theAreaaddOMand:Areato the
regression. Interpret the result.
For Bonus Marks
0.10. ASSIGNMENT 10: FACTROS AND DUMMY VARIABLES 29
10.Load library(effects)
11.define the modelM<-lm(Total.Bill Size:OMandA). (This really just asks R to come
up with a regression line for each of the categories. The colon is a shorthand way to
indicate all the interactions.)
12.Plot the result using theeffects package( it is designed to show the different regressions when there are interaction all on one graph.) There are two versions
>plot(allEffects(M))
>plot(allEffects(M), multiline=T)
Explain the resulting graphs briefly.
Miscellaneous notes
f<-file.choose()
d<-read.csv(f)
d<-d[-c(1,14,21),]
length(d[,2])
When you do a regression with a dummy, one category must be left out. (R will do it
automatically. It leaves out the first factor in alphabetical order so take care. You may want
to change the baseline case to make it easier to explain). You will have to think carefully
about the meaning of your results
Last Completed Projects
| topic title | academic level | Writer | delivered |
|---|
jQuery(document).ready(function($) { var currentPage = 1; // Initialize current page
function reloadLatestPosts() { // Perform AJAX request $.ajax({ url: lpr_ajax.ajax_url, type: 'post', data: { action: 'lpr_get_latest_posts', paged: currentPage // Send current page number to server }, success: function(response) { // Clear existing content of the container $('#lpr-posts-container').empty();
// Append new posts and fade in $('#lpr-posts-container').append(response).hide().fadeIn('slow');
// Increment current page for next pagination currentPage++; }, error: function(xhr, status, error) { console.error('AJAX request error:', error); } }); }
// Initially load latest posts reloadLatestPosts();
// Example of subsequent reloads setInterval(function() { reloadLatestPosts(); }, 7000); // Reload every 7 seconds });

